Skip to content

Commit

Permalink
fix: reverting #63 binaryData change for now to fix reconciliation lo…
Browse files Browse the repository at this point in the history
…op (#66)
  • Loading branch information
isindir authored Apr 29, 2021
1 parent e1d0900 commit 6f57f2e
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 97 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ jobs:
export SECRETS_NUMBER=$( kubectl get secrets --namespace sops \
| awk '$0!~/default-token/ && $0!~/NAME/ { print $1; }' \
| wc -l )
if [[ $SECRETS_NUMBER -ne 6 ]]; then
if [[ $SECRETS_NUMBER -ne 4 ]]; then
echo "Expected number of secrets in sops namespace is 4 - Failed"
tail -40 nohup.out
exit 1
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SHELL := /bin/bash
GO := GO15VENDOREXPERIMENT=1 GO111MODULE=on GOPROXY=https://proxy.golang.org go
SOPS_SEC_OPERATOR_VERSION := 0.1.16
SOPS_SEC_OPERATOR_VERSION := 0.1.17

# https://github.com/kubernetes-sigs/controller-tools/releases
CONTROLLER_TOOLS_VERSION := "v0.3.0"
Expand Down
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,6 @@ spec:
- name: some-token
data:
token: Wb4ziZdELkdUf6m6KtNd7iRjjQRvSeJno5meH4NAGHFmpqJyEsekZ2WjX232s4Gj
- name: secret-with-base64-encoded-binary-data
binaryData:
datakey: c29tZSBiaW5hcnkgZGF0YQ==
example: YW5vdGhlciBleGFtcGxlIG9mIGJpbmFyeSBkYXRh
- name: secret-with-mixed-data
data:
textdata: example data
binaryData:
bindata: YW5vdGhlciBleGFtcGxlIG9mIGJpbmFyeSBkYXRh
- name: docker-login
type: 'kubernetes.io/dockerconfigjson'
data:
Expand Down
7 changes: 1 addition & 6 deletions api/v1alpha2/sopssecret_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ type SopsSecretTemplate struct {

// Data map to use in Kubernetes secret (equivalent to Kubernetes Secret object stringData, please see for more
// information: https://kubernetes.io/docs/concepts/configuration/secret/#overview-of-secrets)
// +optional
Data map[string]string `json:"data,omitempty"`

// BinaryData is base64 data map to use in Kubernetes secret
// +optional
BinaryData map[string]string `json:"binaryData,omitempty"`
Data map[string]string `json:"data"`
}

// SopsSecretSpec defines the desired state of SopsSecret
Expand Down
7 changes: 0 additions & 7 deletions api/v1alpha2/zz_generated.deepcopy.go

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

4 changes: 2 additions & 2 deletions chart/helm3/sops-secrets-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
version: 0.7.5
appVersion: 0.1.16
version: 0.7.6
appVersion: 0.1.17
type: application
description: sops secrets operator
name: sops-secrets-operator
Expand Down
6 changes: 3 additions & 3 deletions chart/helm3/sops-secrets-operator/tests/operator_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ tests:
app.kubernetes.io/instance: sops
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: sops-secrets-operator
app.kubernetes.io/version: 0.1.16
helm.sh/chart: sops-secrets-operator-0.7.5
app.kubernetes.io/version: 0.1.17
helm.sh/chart: sops-secrets-operator-0.7.6

# template metadata and spec selector
- it: should correctly render template metadata and spec selector
Expand Down Expand Up @@ -140,7 +140,7 @@ tests:
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: isindir/sops-secrets-operator:0.1.16
value: isindir/sops-secrets-operator:0.1.17
- equal:
path: spec.template.spec.containers[0].imagePullPolicy
value: Always
Expand Down
2 changes: 1 addition & 1 deletion chart/helm3/sops-secrets-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ replicaCount: 1 # Deployment replica count - should not be modified

image:
repository: isindir/sops-secrets-operator # Operator image
tag: 0.1.16 # Operator image tag
tag: 0.1.17 # Operator image tag
pullPolicy: Always # Operator image pull policy

imagePullSecrets: [] # Secrets to pull image from private docker repository
Expand Down
7 changes: 1 addition & 6 deletions config/crd/bases/isindir.github.com_sopssecrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,6 @@ spec:
type: string
description: Annotations to apply to Kubernetes secret
type: object
binaryData:
additionalProperties:
type: string
description: BinaryData is base64 data map to use in Kubernetes
secret
type: object
data:
additionalProperties:
type: string
Expand All @@ -202,6 +196,7 @@ spec:
kubernetes.io/ssh-auth, kubernetes.io/tls, bootstrap.kubernetes.io/token'
type: string
required:
- data
- name
type: object
minItems: 1
Expand Down
9 changes: 0 additions & 9 deletions config/samples/isindir_v1alpha2_sopssecret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@ spec:
data:
data-name0: data-value0
data-nameL: data-valueL
- name: secret-with-base64-encoded-binary-data
binaryData:
datakey: c29tZSBiaW5hcnkgZGF0YQ==
example: YW5vdGhlciBleGFtcGxlIG9mIGJpbmFyeSBkYXRh
- name: secret-with-mixed-data
data:
textdata: example data
binaryData:
bindata: YW5vdGhlciBleGFtcGxlIG9mIGJpbmFyeSBkYXRh
- name: jenkins-secret
labels:
"jenkins.io/credentials-type": "usernamePassword"
Expand Down
19 changes: 6 additions & 13 deletions controllers/sopssecret_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package controllers

import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -175,7 +174,8 @@ func (r *SopsSecretReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error)
origSecret := foundSecret
foundSecret = foundSecret.DeepCopy()

foundSecret.Data = newSecret.Data
foundSecret.StringData = newSecret.StringData
foundSecret.Data = map[string][]byte{}
foundSecret.Type = newSecret.Type
foundSecret.ObjectMeta.Annotations = newSecret.ObjectMeta.Annotations
foundSecret.ObjectMeta.Labels = newSecret.ObjectMeta.Labels
Expand Down Expand Up @@ -257,16 +257,9 @@ func newSecretForCR(
}

// Construct Data for the secret
data := make(map[string][]byte)
for key, value := range secretTpl.BinaryData {
decoded, err := base64.StdEncoding.DecodeString(value)
if err != nil {
return nil, fmt.Errorf("newSecretForCR(): binaryData[%v] is not a valid base64 string", key)
}
data[key] = decoded
}
data := make(map[string]string)
for key, value := range secretTpl.Data {
data[key] = []byte(value)
data[key] = value
}

if secretTpl.Name == "" {
Expand Down Expand Up @@ -297,8 +290,8 @@ func newSecretForCR(
Labels: labels,
Annotations: annotations,
},
Type: kubeSecretType,
Data: data,
Type: kubeSecretType,
StringData: data,
}
return secret, nil
}
Expand Down
Loading

0 comments on commit 6f57f2e

Please sign in to comment.