Skip to content

Commit

Permalink
Merge pull request #404 from makkes/default-observed-generation
Browse files Browse the repository at this point in the history
feat: set default observedGeneration to -1 on Kustomizations
  • Loading branch information
hiddeco authored Aug 27, 2021
2 parents ea052f8 + d7690d8 commit 52c61f8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion api/v1beta1/kustomization_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ spec:
- sourceRef
type: object
status:
default:
observedGeneration: -1
description: KustomizationStatus defines the observed state of a kustomization.
properties:
conditions:
Expand Down
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

0 comments on commit 52c61f8

Please sign in to comment.