Add enableAdmin and enableACME to Helm values.yml generation

This commit is contained in:
Herman Slatman 2022-09-29 15:08:32 +02:00
parent 9d4bef8cc9
commit acdf080308
No known key found for this signature in database
GPG key ID: F4D8A44EA0A75A4F

View file

@ -17,6 +17,7 @@ type helmVariables struct {
Defaults *linkedca.Defaults Defaults *linkedca.Defaults
Password string Password string
EnableSSH bool EnableSSH bool
EnableAdmin bool
TLS authconfig.TLSOptions TLS authconfig.TLSOptions
Provisioners []provisioner.Interface Provisioners []provisioner.Interface
} }
@ -35,7 +36,11 @@ func (p *PKI) WriteHelmTemplate(w io.Writer) error {
} }
// Convert provisioner to ca.json // Convert provisioner to ca.json
provisioners := make([]provisioner.Interface, len(p.Authority.Provisioners)) numberOfProvisioners := len(p.Authority.Provisioners)
if p.options.enableACME {
numberOfProvisioners++
}
provisioners := make([]provisioner.Interface, numberOfProvisioners)
for i, p := range p.Authority.Provisioners { for i, p := range p.Authority.Provisioners {
pp, err := authority.ProvisionerToCertificates(p) pp, err := authority.ProvisionerToCertificates(p)
if err != nil { if err != nil {
@ -44,11 +49,25 @@ func (p *PKI) WriteHelmTemplate(w io.Writer) error {
provisioners[i] = pp provisioners[i] = pp
} }
// Add default ACME provisioner if enabled. Note that this logic is similar
// to what's in p.GenerateConfig(), but that codepath isn't taken when
// writing the Helm template. The default JWK provisioner is added earlier in
// the process and that's part of the provisioners above.
// TODO(hs): consider refactoring the initialization, so that this becomes
// easier to reason about and maintain.
if p.options.enableACME {
provisioners[len(provisioners)-1] = &provisioner.ACME{
Type: "ACME",
Name: "acme",
}
}
if err := tmpl.Execute(w, helmVariables{ if err := tmpl.Execute(w, helmVariables{
Configuration: &p.Configuration, Configuration: &p.Configuration,
Defaults: &p.Defaults, Defaults: &p.Defaults,
Password: "", Password: "",
EnableSSH: p.options.enableSSH, EnableSSH: p.options.enableSSH,
EnableAdmin: p.options.enableAdmin,
TLS: authconfig.DefaultTLSOptions, TLS: authconfig.DefaultTLSOptions,
Provisioners: provisioners, Provisioners: provisioners,
}); err != nil { }); err != nil {
@ -88,6 +107,7 @@ inject:
type: badgerv2 type: badgerv2
dataSource: /home/step/db dataSource: /home/step/db
authority: authority:
enableAdmin: {{ .EnableAdmin }}
provisioners: provisioners:
{{- range .Provisioners }} {{- range .Provisioners }}
- {{ . | toJson }} - {{ . | toJson }}