Skip to content

Commit

Permalink
Add EAB Config options (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilathedragon authored Aug 22, 2022
1 parent 769911d commit d00dc59
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions charts/caddy-ingress-controller/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ The command removes all the Kubernetes components associated with the chart and
| image.tag | string | `"latest"` | |
| imagePullSecrets | list | `[]` | |
| ingressController.config.acmeCA | string | `""` | |
| ingressController.config.acmeEABKeyId | string | `""` | |
| ingressController.config.acmeEABMacKey | string | `""` | |
| ingressController.config.debug | bool | `false` | |
| ingressController.config.email | string | `""` | |
| ingressController.config.metrics | bool | `true` | |
Expand Down
8 changes: 8 additions & 0 deletions charts/caddy-ingress-controller/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@
}
]
},
"acmeEABKeyId": {
"$id": "#/properties/ingressController/properties/config/properties/acmeEABKeyId",
"type": "string"
},
"acmeEABMacKey": {
"$id": "#/properties/ingressController/properties/config/properties/acmeEABMacKey",
"type": "string"
},
"debug": {
"$id": "#/properties/ingressController/properties/config/properties/debug",
"type": "boolean"
Expand Down
2 changes: 2 additions & 0 deletions charts/caddy-ingress-controller/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ ingressController:
classNameRequired: false
leaseId: ""
config:
acmeEABKeyId: ""
acmeEABMacKey: ""
# -- Acme Server URL
acmeCA: ""
debug: false
Expand Down
9 changes: 9 additions & 0 deletions internal/caddy/global/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package global

import (
"encoding/json"

caddy2 "github.com/caddyserver/caddy/v2"
"github.com/caddyserver/caddy/v2/caddyconfig"
"github.com/caddyserver/caddy/v2/modules/caddytls"
"github.com/caddyserver/ingress/pkg/converter"
"github.com/caddyserver/ingress/pkg/store"
"github.com/mholt/acmez/acme"
)

type ConfigMapPlugin struct{}
Expand Down Expand Up @@ -39,6 +41,13 @@ func (p ConfigMapPlugin) GlobalHandler(config *converter.Config, store *store.St
acmeIssuer.CA = cfgMap.AcmeCA
}

if cfgMap.AcmeEABKeyId != "" && cfgMap.AcmeEABMacKey != "" {
acmeIssuer.ExternalAccount = &acme.EAB{
KeyID: cfgMap.AcmeEABKeyId,
MACKey: cfgMap.AcmeEABMacKey,
}
}

if cfgMap.Email != "" {
acmeIssuer.Email = cfgMap.Email
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/store/configmap_parser.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
package store

import (
"reflect"
"time"

"github.com/caddyserver/caddy/v2"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
apiv1 "k8s.io/api/core/v1"
"reflect"
"time"
)

// ConfigMapOptions represents global options set through a configmap
type ConfigMapOptions struct {
Debug bool `json:"debug,omitempty"`
AcmeCA string `json:"acmeCA,omitempty"`
AcmeEABKeyId string `json:"acmeEABKeyId,omitempty"`
AcmeEABMacKey string `json:"acmeEABMacKey,omitempty"`
Email string `json:"email,omitempty"`
ExperimentalSmartSort bool `json:"experimentalSmartSort,omitempty"`
ProxyProtocol bool `json:"proxyProtocol,omitempty"`
Expand Down

0 comments on commit d00dc59

Please sign in to comment.