Skip to content

Commit

Permalink
[SP-4263 | Abhishek/Anuja] Used KubectlCommandBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
anujachaitanya committed Nov 11, 2024
1 parent 3976980 commit a86e164
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ static String[] getDeleteSecretCommand(final String secretName) {
if (!StringUtil.hasText(secretName)) {
throw new IllegalArgumentException("secretName is required.");
}
return new String[] {"kubectl", "--namespace", K8SUtil.getWorkloadNamespace(), "delete", "secret", secretName};
return KubectlCommandBuilder.command("delete")
.namespace(K8SUtil.getWorkloadNamespace())
.option("secret", secretName)
.build();
}

static String[] getRegistryCreateSecretCommand(final ImageRegistryAuth registryAuth, final String secretName) {
Expand All @@ -142,18 +145,13 @@ static String[] getRegistryCreateSecretCommand(final ImageRegistryAuth registryA
throw new IllegalArgumentException("secretName is required.");
}

return new String[] {
"kubectl",
"--namespace",
K8SUtil.getWorkloadNamespace(),
"create",
"secret",
"docker-registry",
secretName,
"--docker-server=" + registryAuth.getHost(),
"--docker-username=" + registryAuth.getUsername(),
"--docker-password=" + new String(registryAuth.getSecret())
};
return KubectlCommandBuilder.command("create")
.namespace(K8SUtil.getWorkloadNamespace())
.argument("secret")
.option("docker-registry", secretName)
.argument("--docker-server=" + registryAuth.getHost())
.argument("--docker-username=" + registryAuth.getUsername())
.argument("--docker-password=" + new String(registryAuth.getSecret())).build();
}

public static JSONObject getSecretData(final String secretName, final String secretNamespace) throws Exception {
Expand Down

0 comments on commit a86e164

Please sign in to comment.