Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ passwordSecret: "secret containing the password to sign JKS keystore with - requ
passwordSecretKey: "key within the passwordSecret containing the password data - required only for JKS type only"
addClusterCA: "(true/false) include the cluster CA in the certificate store. Default: false"
selector: "label selector that selects which secrets contain the source trusted certificates"
annotations: "label selector that selects which secrets contain the source trusted certificates"
```

### Source Trusted Certificates
Expand Down
1 change: 1 addition & 0 deletions api/v1/certificatepackage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type CertificatePackageSpec struct {
AddClusterCA string `json:"addClusterCA,omitempty"`
PasswordSecret string `json:"passwordSecret,omitempty"`
PasswordSecretKey string `json:"passwordSecretKey,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
}

// CertificatePackageStatus defines the observed state of CertificatePackage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ spec:
properties:
addClusterCA:
type: string
annotations:
description: Custom annotations map that will be added to the output object
additionalProperties:
type: string
type: object
key:
type: string
packageType:
Expand Down
20 changes: 13 additions & 7 deletions controllers/certificatepackage_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,20 @@ import (
"encoding/pem"
oserrors "errors"
"fmt"
"io/ioutil"
"os"
"sort"
"strconv"
"strings"
"time"

"github.com/go-logr/logr"
"github.com/pavel-v-chernykh/keystore-go/v4"
"io/ioutil"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
v12 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/util/retry"
"os"
"sort"
"strconv"
"strings"
"time"

"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -407,10 +408,15 @@ func (r *CertificatePackageReconciler) applyCertBytesToSecret(ctx context.Contex
return fmt.Errorf("failed to get destination secret: %s", err.Error())
}
}
if targetSecret.Annotations == nil {

if cp.Annotations != nil {
targetSecret.Annotations = cp.Spec.Annotations
} else if targetSecret.Annotations == nil {
targetSecret.Annotations = map[string]string{}
}

targetSecret.Annotations[CurrentCertificateHashAnnotation] = certHash

if targetSecret.Data == nil {
targetSecret.Data = map[string][]byte{}
}
Expand Down