Skip to content

Commit

Permalink
Adds error output to ssl_script/index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
DougReeder committed Sep 10, 2024
1 parent 35752a0 commit 891b045
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions community-edition/ssl_script/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ function generate_ssl(config, template, url) {
config.HUB_DOMAIN = url;
const replacedContent = utils.replacePlaceholders(template, config);
utils.writeOutputFile(replacedContent, "ssl_script", "cbb.yaml");
try {execSync(`kubectl apply -f cbb.yaml`, {cwd: "ssl_script"})} catch {
try {execSync(`kubectl apply -f cbb.yaml`, {cwd: "ssl_script"})} catch (error) {
console.error(`while executing kubectl apply -f cbb.yaml:`, error);
process.exit(1);
}
// check the status of the SSL certificate generation
Expand All @@ -21,26 +22,29 @@ function generate_ssl(config, template, url) {
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 10000);
// Get the status of the certbotbot-http pod
try {
output = execSync(`kubectl get pod certbotbot-http -n ${config.Namespace} --no-headers -o custom-columns=STATUS:.status.phase`);
} catch {
process.exit(1);
}
if (output.toString().trim() == "Running") {
process.stdout.write(".");
}
else if (output.toString().trim() == "Succeeded") {
console.log(":");
try {
output = execSync(`kubectl get secret cert-${url} -n ${config.Namespace}`);
console.log(output.toString());
} catch {
process.exit(1);
let output = execSync(`kubectl get pod certbotbot-http -n ${config.Namespace} --no-headers -o custom-columns=STATUS:.status.phase`);

if (output.toString().trim() === "Running") {
process.stdout.write(".");
}
return
}
else {
console.log(`bad pod status: ${output.toString().trim()}`)
return
else if (output.toString().trim() === "Succeeded") {
console.log(":");
try {
output = execSync(`kubectl get secret cert-${url} -n ${config.Namespace}`);
console.log(output.toString());
return;
} catch (error) {
console.error(`while executing kubectl get secret cert-${url} -n ${config.Namespace}:`, error);
process.exit(1);
}
}
else {
console.log(`bad pod status: ${output.toString().trim()}`)
return;
}
} catch (error) {
console.error(`while executing kubectl get pod certbotbot-http -n ${config.Namespace} --no-headers -o custom-columns=STATUS:.status.phase:`, error);
process.exit(1);
}
}
}
Expand Down

0 comments on commit 891b045

Please sign in to comment.