Skip to content

Commit

Permalink
fixed type scope as requested
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Ward committed Oct 28, 2020
1 parent c715833 commit 64a7cfc
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
6 changes: 4 additions & 2 deletions api/v1/syncedsecret_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ type SyncedSecretSpec struct {
// DataFrom
// +optional
DataFrom *DataFrom `json:"dataFrom,omitempty"`

// Type
// +optional
Type corev1.SecretType `json:"type,omitempty"`
}

// SyncedSecretStatus defines the observed state of SyncedSecret
Expand All @@ -105,8 +109,6 @@ type SyncedSecret struct {

Spec SyncedSecretSpec `json:"spec,omitempty"`
Status SyncedSecretStatus `json:"status,omitempty"`

Type corev1.SecretType `json:"type,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
5 changes: 3 additions & 2 deletions config/crd/bases/secrets.contentful.com_syncedsecrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ spec:
secretMetadata:
description: Secret Metadata
type: object
type:
description: Type
type: string
type: object
status:
description: SyncedSecretStatus defines the observed state of SyncedSecret
Expand All @@ -107,8 +110,6 @@ spec:
required:
- currentVersionID
type: object
type:
type: string
type: object
version: v1
versions:
Expand Down
2 changes: 1 addition & 1 deletion config/samples/secrets_v1_syncedsecret_specified_type.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: secrets.contentful.com/v1
kind: SyncedSecret
type: kubernetes.io/dockerconfigjson
metadata:
name: syncedsecret-sample-ks
namespace: kube-secret-syncer
spec:
type: kubernetes.io/dockerconfigjson
secretMetadata:
name: demo-service-secret
namespace: kube-secret-syncer
Expand Down
4 changes: 2 additions & 2 deletions pkg/k8ssecret/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ func GenerateK8SSecret(
}

secretType := corev1.SecretTypeOpaque
if cs.Type != "" {
secretType = cs.Type
if cs.Spec.Type != "" {
secretType = cs.Spec.Type
}

secret := &corev1.Secret{
Expand Down
5 changes: 3 additions & 2 deletions pkg/k8ssecret/secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ func TestGenerateSecret(t *testing.T) {
"field2": []byte("value2"),
},
},
}, {
},
{
name: "it should support fields with a hardcoded value for Secret Type",
have: have{
SyncedSecret: secretsv1.SyncedSecret{
Expand All @@ -187,8 +188,8 @@ func TestGenerateSecret(t *testing.T) {
},
},
IAMRole: _s("iam_role"),
Type: "kubernetes.io/dockerconfigjson",
},
Type: "kubernetes.io/dockerconfigjson",
},
err: nil,
cachedSecrets: secretsmanager.Secrets{"cachedSecret1": {}, "cachedSecret2": {}},
Expand Down

0 comments on commit 64a7cfc

Please sign in to comment.