-
Notifications
You must be signed in to change notification settings - Fork 797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support to customizing certbot cert command #2019
base: master
Are you sure you want to change the base?
Conversation
- Added getCertbotCertCommand method in CertbotManager for dynamic cert commands - Refactored enableSsl method to use the new dynamic cert command generator - Introduced certbotCertCommand configuration in CaptainConstants for customizable commands
- Extracted certificate success logic into isCertCommandSuccess function - Ensured compatibility with previous certbot success messages
- Removed a redundant comma in function arguments - Added a space before function declaration for consistency
- Introduced CertbotCertCommandRule for dynamic command generation - Refactored CertbotManager to utilize a CertCommandGenerator - Added new tests for the CertCommandGenerator logic
@githubsaturn Could you please let me know when you might have time to review the latest pull request? I appreciate your feedback on it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shoot! So sorry for the late review!!
src/utils/CaptainConstants.ts
Outdated
|
||
certbotImageName: 'caprover/certbot-sleeping:v1.6.0', | ||
|
||
certbotCertCommand: undefined as CertbotCertCommandRule[] | undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename certbotCertCommand
to certbotCertCommandRules
src/utils/CaptainConstants.ts
Outdated
/** | ||
* The Certbot command to execute, in Docker exec form, uses `${domain}` as the placeholder for the actual domain name | ||
*/ | ||
command?: string[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use command?: string
, when passing to exec, we can do command.trim().split(' ')
This will make it much easier to override and read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good! We can use shell-quote to parse the command string before passing it to exec. It's more robust than using String.split
.
src/user/system/CertbotManager.ts
Outdated
} | ||
return this.defaultCommand | ||
} | ||
getCertbotCertCommand(domainName: string, variables: Record<string, string> = {}): string[] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only place this command gets called we have:
const cmd = self.certCommandGenerator.getCertbotCertCommand(domainName, {
domain: domainName,
webroot: WEBROOT_PATH_IN_CERTBOT + '/' + domainName
})
Looks like the flexibility in the args is really not needed and causes more confusion. Let's just change the signature to be explicit. i.e.,
getCertbotCertCommand(domainName: string, webroot:string)
@@ -12,8 +12,36 @@ const WEBROOT_PATH_IN_CAPTAIN = | |||
|
|||
const shouldUseStaging = false // CaptainConstants.isDebug; | |||
|
|||
function isCertCommandSuccess(output: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Hi @ZeekoZhu |
Sorry for not getting back to you sooner, I missed the email notifications from GitHub, I will update the changes this weekend. |
PR updated, but I haven't tested the new changes yet, I will test it next week. |
Please see comments on #1761 for more details.
Most important items
These rules are strictly enforced to make sure that we can maintain the project moving forward.