Skip to content

Commit

Permalink
optionally specify secretName for autoregistrated issuer, updated con…
Browse files Browse the repository at this point in the history
…troller-manager-library dependency
  • Loading branch information
MartinWeindel committed Sep 9, 2019
1 parent c97a849 commit e80835b
Show file tree
Hide file tree
Showing 55 changed files with 2,585 additions and 972 deletions.
20 changes: 13 additions & 7 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ required = [

[[constraint]]
name = "github.com/gardener/external-dns-management"
version = "0.6.1"
version = "0.7.0"

[[constraint]]
name = "k8s.io/api"
Expand Down
1 change: 1 addition & 0 deletions examples/20-issuer-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ spec:
server: https://acme-staging-v02.api.letsencrypt.org/directory
email: some.user@mydomain.com
autoRegistration: true
autoRegistrationSecretName: issuer-staging-secret
25 changes: 22 additions & 3 deletions pkg/apis/cert/v1alpha1/issuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,35 @@ type Issuer struct {
}

type IssuerSpec struct {
// +optional
ACME *ACMESpec `json:"acme,omitempty"`

// +optional
SelfSigned *SelfSignedSpec `json:"selfSigned,omitempty"`

// +optional
CA *CASpec `json:"ca,omitempty"`
}

type ACMESpec struct {
Server string `json:"server"`
Email string `json:"email"`
AutoRegistration bool `json:"autoRegistration,omitempty"`
Server string `json:"server"`
Email string `json:"email"`

// +optional
AutoRegistration bool `json:"autoRegistration,omitempty"`
AutoRegistrationSecretName string `json:"autoRegistrationSecretName,omitempty"`

// +optional
PrivateKeySecretRef *corev1.SecretReference `json:"privateKeySecretRef,omitempty"`
}

type SelfSignedSpec struct {
}

type CASpec struct {
SecretRef *corev1.SecretReference `json:"secretRef,omitempty"`
}

type IssuerStatus struct {
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
State string `json:"state"`
Expand Down
47 changes: 47 additions & 0 deletions pkg/apis/cert/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 0 additions & 80 deletions pkg/cert/source/class.go

This file was deleted.

86 changes: 0 additions & 86 deletions pkg/cert/source/finalizer.go

This file was deleted.

6 changes: 3 additions & 3 deletions pkg/cert/source/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ func SourceReconciler(sourceType CertSourceType, rtype controller.ReconcilerType
return nil, err
}
copt, _ := c.GetStringOption(OPT_CLASS)
classes := NewClasses(copt)
c.SetFinalizerHandler(NewFinalizer(c, c.GetDefinition().FinalizerName(), classes))
classes := controller.NewClasses(c, copt, ANNOT_CLASS, DefaultClass)
c.SetFinalizerHandler(controller.NewFinalizerForClasses(c, c.GetDefinition().FinalizerName(), classes))
targetclass, _ := c.GetStringOption(OPT_TARGETCLASS)
if targetclass == "" {
if !classes.Contains(DefaultClass) && classes.Main() != DefaultClass {
Expand Down Expand Up @@ -81,7 +81,7 @@ type sourceReconciler struct {
*reconcilers.NestedReconciler
*reconcilers.SlaveAccess
source CertSource
classes *Classes
classes *controller.Classes
targetclass string
namespace string
nameprefix string
Expand Down
15 changes: 10 additions & 5 deletions pkg/controller/issuer/acme/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,16 @@ func (r *acmeIssuerHandler) Reconcile(logger logger.LogContext, obj resources.Ob
return r.failedAcme(logger, obj, api.STATE_ERROR, fmt.Errorf("creating registration user failed with %s", err.Error()))
}

secretRef, err := r.support.WriteIssuerSecret(issuer.ObjectMeta, user, secret)
if err != nil {
return r.failedAcme(logger, obj, api.STATE_ERROR, fmt.Errorf("writing issuer secret failed with %s", err.Error()))
}
if secretRef != nil {
if secret != nil {
err = r.support.UpdateIssuerSecret(issuer.ObjectMeta, user, secret)
if err != nil {
return r.failedAcme(logger, obj, api.STATE_ERROR, fmt.Errorf("updating issuer secret failed with %s", err.Error()))
}
} else {
secretRef, err := r.support.WriteIssuerSecretFromRegistrationUser(issuer.ObjectMeta, user, acme.AutoRegistrationSecretName)
if err != nil {
return r.failedAcme(logger, obj, api.STATE_ERROR, fmt.Errorf("writing issuer secret failed with %s", err.Error()))
}
issuer.Spec.ACME.PrivateKeySecretRef = secretRef
r.support.RememberIssuerSecret(obj.ObjectName(), issuer.Spec.ACME.PrivateKeySecretRef)
}
Expand Down
Loading

0 comments on commit e80835b

Please sign in to comment.