Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: fluxcd/kustomize-controller
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.14.0
Choose a base ref
...
head repository: fluxcd/kustomize-controller
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.14.1
Choose a head ref
  • 7 commits
  • 10 files changed
  • 4 contributors

Commits on Aug 27, 2021

  1. feat: set default observedGeneration to -1 on Kustomizations

    This is a follow-up to
    fluxcd/helm-controller#294, porting the same
    code to the kustomize-controller so that all Flux 2 controllers work
    the same way in this regard.
    
    Signed-off-by: Max Jonas Werner <mail@makk.es>
    Max Jonas Werner committed Aug 27, 2021

    Unverified

    No user is associated with the committer email.
    Copy the full SHA
    d7690d8 View commit details
  2. Merge pull request #404 from makkes/default-observed-generation

    feat: set default observedGeneration to -1 on Kustomizations
    hiddeco authored Aug 27, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    52c61f8 View commit details

Commits on Sep 3, 2021

  1. Redact secret data.

    Signed-off-by: Michal Schott <michal.schott@onegini.com>
    Michal Schott committed Sep 3, 2021

    Unverified

    No user is associated with the committer email.
    Copy the full SHA
    cb93667 View commit details

Commits on Sep 8, 2021

  1. Filter dryrun errors for senstive data.

    Signed-off-by: Michal Schott <michal.schott@onegini.com>
    Michal Schott committed Sep 8, 2021

    Unverified

    No user is associated with the committer email.
    Copy the full SHA
    72bc544 View commit details

Commits on Sep 9, 2021

  1. Merge pull request #420 from michalschott/main

    Mask the Kubernetes Secrets data from dry-run and apply logs
    stefanprodan authored Sep 9, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9838b77 View commit details
  2. Release v0.14.1

    Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
    stefanprodan committed Sep 9, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    stefanprodan Stefan Prodan
    Copy the full SHA
    54efaca View commit details
  3. Merge pull request #424 from fluxcd/release-v0.14.1

    Release v0.14.1
    stefanprodan authored Sep 9, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8534a14 View commit details
11 changes: 11 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -55,6 +55,17 @@ jobs:
KUBEBUILDER_ASSETS: ${{ github.workspace }}/kubebuilder/bin
- name: Load test image
run: kind load docker-image test/kustomize-controller:latest
- name: Install CRDs
run: make install
- name: Run default status test
run: |
kubectl apply -f config/testdata/status-defaults
RESULT=$(kubectl get kustomization status-defaults -o go-template={{.status}})
EXPECTED='map[observedGeneration:-1]'
if [ "${RESULT}" != "${EXPECTED}" ] ; then
echo -e "${RESULT}\n\ndoes not equal\n\n${EXPECTED}"
exit 1
fi
- name: Deploy controllers
run: |
make dev-deploy IMG=test/kustomize-controller:latest
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,19 @@

All notable changes to this project are documented in this file.

## 0.14.1

**Release date:** 2021-09-09

This prerelease comes with improvements to logging.
When Kubernetes Secrets can't be reconciled due to validation errors,
the controller will mask the secret data from logs and events to prevent
disclosing sensitive information.

Improvements:
* Mask the Kubernetes Secrets data from dry-run and apply logs
[#420](https://github.com/fluxcd/kustomize-controller/pull/420)

## 0.14.0

**Release date:** 2021-08-26
3 changes: 2 additions & 1 deletion api/v1beta1/kustomization_types.go
Original file line number Diff line number Diff line change
@@ -340,7 +340,8 @@ type Kustomization struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec KustomizationSpec `json:"spec,omitempty"`
Spec KustomizationSpec `json:"spec,omitempty"`
// +kubebuilder:default:={"observedGeneration":-1}
Status KustomizationStatus `json:"status,omitempty"`
}

Original file line number Diff line number Diff line change
@@ -330,6 +330,8 @@ spec:
- sourceRef
type: object
status:
default:
observedGeneration: -1
description: KustomizationStatus defines the observed state of a kustomization.
properties:
conditions:
2 changes: 1 addition & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -5,4 +5,4 @@ resources:
images:
- name: fluxcd/kustomize-controller
newName: fluxcd/kustomize-controller
newTag: v0.14.0
newTag: v0.14.1
4 changes: 4 additions & 0 deletions config/testdata/status-defaults/empty-kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.toolkit.fluxcd.io/v1beta1
kind: Kustomization
metadata:
name: status-defaults
4 changes: 2 additions & 2 deletions controllers/kustomization_controller.go
Original file line number Diff line number Diff line change
@@ -356,7 +356,7 @@ func (r *KustomizationReconciler) reconcile(
source.GetArtifact().Revision,
kustomizev1.ValidationFailedReason,
err.Error(),
), err
), stripSensitiveData(err)
}

// apply
@@ -367,7 +367,7 @@ func (r *KustomizationReconciler) reconcile(
source.GetArtifact().Revision,
meta.ReconciliationFailedReason,
err.Error(),
), err
), stripSensitiveData(err)
}

// prune
13 changes: 13 additions & 0 deletions controllers/utils.go
Original file line number Diff line number Diff line change
@@ -17,6 +17,8 @@ limitations under the License.
package controllers

import (
"errors"
"regexp"
"strings"
)

@@ -77,3 +79,14 @@ func containsString(slice []string, s string) bool {
}
return false
}

func stripSensitiveData(err error) error {
r := regexp.MustCompile(`(v1.Secret.(StringData|Data):) (.*)`)
newErr := r.ReplaceAllString(err.Error(), "$1 [ ** REDACTED ** ]")

// strip data from bigger context
r = regexp.MustCompile(`((stringData|data)\":{)(.*)(})`)
newErr = r.ReplaceAllString(newErr, "$1 [ ** REDACTED ** ] $4")

return errors.New(newErr)
}
30 changes: 30 additions & 0 deletions controllers/utils_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package controllers

import (
"errors"
"strings"
"testing"
)
@@ -54,3 +55,32 @@ error: error validating data: unknown field "ima ge" in io.k8s.api.core.v1.Cont
})
}
}

func TestStripSensitiveData(t *testing.T) {
tests := []struct {
name string
in error
expected error
}{
{
"stringData",
errors.New("apply failed: Error from server (BadRequest): error when creating \"0f1563ce-8273-4879-99dd-f6f58629cc2d.yaml\": Secret in version \"v1\" cannot be handled as a Secret: v1.Secret.StringData: ReadString: expects \" or n, but found 0, error found in #10 byte of ...|\"secret\":0}}\n|..., bigger context ...|\"namespace\":\"sensitive-data-dkgvw\"},\"stringData\":{\"secret\":0}}\n|...\n"),
errors.New("apply failed: Error from server (BadRequest): error when creating \"0f1563ce-8273-4879-99dd-f6f58629cc2d.yaml\": Secret in version \"v1\" cannot be handled as a Secret: v1.Secret.StringData: [ ** REDACTED ** ]\n|..., bigger context ...|\"namespace\":\"sensitive-data-dkgvw\"},\"stringData\":{ [ ** REDACTED ** ] }\n|...\n"),
},
{
"data",
errors.New("apply failed: Error from server (BadRequest): error when creating \"0f1563ce-8273-4879-99dd-f6f58629cc2d.yaml\": Secret in version \"v1\" cannot be handled as a Secret: v1.Secret.Data: ReadString: expects \" or n, but found 0, error found in #10 byte of ...|\"secret\":0}}\n|..., bigger context ...|\"namespace\":\"sensitive-data-dkgvw\"},\"data\":{\"secret\":0}}\n|...\n"),
errors.New("apply failed: Error from server (BadRequest): error when creating \"0f1563ce-8273-4879-99dd-f6f58629cc2d.yaml\": Secret in version \"v1\" cannot be handled as a Secret: v1.Secret.Data: [ ** REDACTED ** ]\n|..., bigger context ...|\"namespace\":\"sensitive-data-dkgvw\"},\"data\":{ [ ** REDACTED ** ] }\n|...\n"),
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
expected := stripSensitiveData(tt.in)

if expected.Error() != tt.expected.Error() {
t.Errorf("\nexpected:\n%q\ngot:\n%q\n", tt.expected.Error(), expected.Error())
}
})
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ require (
filippo.io/age v1.0.0-beta7
github.com/cyphar/filepath-securejoin v0.2.2
github.com/drone/envsubst v1.0.3-0.20200804185402-58bc65f69603
github.com/fluxcd/kustomize-controller/api v0.14.0
github.com/fluxcd/kustomize-controller/api v0.14.1
github.com/fluxcd/pkg/apis/kustomize v0.2.0
github.com/fluxcd/pkg/apis/meta v0.10.0
github.com/fluxcd/pkg/runtime v0.12.0