Skip to content

Commit

Permalink
feat: detect 16char long hex strings
Browse files Browse the repository at this point in the history
matches kubernetes event names
  • Loading branch information
adityathebe authored and moshloop committed Oct 9, 2024
1 parent 4edcdb9 commit 516ecf9
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes/fingerprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func init() {
"DURATION", `\s+\d+(.\d+){0,1}(ms|s|h|d|m)`,
"SHA256", `[a-z0-9]{64}`,
"NUMBER", `^\d+$`,
"HEX16", `[0-9a-f]{16}`, // matches a 16 character long hex string
)
}

Expand Down
9 changes: 8 additions & 1 deletion changes/fingerprint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,17 @@ var _ = Describe("Change Fingerprints", func() {
Expect(err2).ToNot(HaveOccurred())
Expect(fp1).To(Equal(fp2))
})

It("16 character long hex should be ignored", func() {
fp1, err1 := changes.Fingerprint(readChange("helm_upgrade_failed.json"))
fp2, err2 := changes.Fingerprint(readChange("helm_upgrade_failed_2.json"))
Expect(err1).ToNot(HaveOccurred())
Expect(err2).ToNot(HaveOccurred())
Expect(fp1).To(Equal(fp2))
})
})

func TestChangeFingerprints(t *testing.T) {

RegisterFailHandler(Fail)
RunSpecs(t, "Change Fingerprints Suite")
}
29 changes: 29 additions & 0 deletions changes/testdata/helm_upgrade_failed.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"details": {
"reason": "UpgradeFailed",
"source": {
"component": "helm-controller"
},
"message": "Helm upgrade failed for release mission-control-agent/mission-control-kubernetes-bundle with chart [email protected]: values don't meet the specifications of the schema(s) in the following chart(s):\nmission-control-kubernetes:\n- (root): Additional property interval is not allowed\n\nLast Helm logs:\n\n2024-10-09T04:46:13.116068801Z: preparing upgrade for mission-control-kubernetes-bundle\n2024-10-09T04:46:13.156697628Z: resetting values to the chart's original version",
"metadata": {
"uid": "852af766-4928-49d5-a2a6-a5668e3715e3",
"name": "mission-control-kubernetes-bundle.17fcaf5d944b5886",
"namespace": "mission-control-agent",
"annotations": {
"helm.toolkit.fluxcd.io/token": "sha256:eb7505628756567105a575c2dcaf473756212793a2b43537b976db9e18c7b233",
"helm.toolkit.fluxcd.io/revision": "0.1.69",
"helm.toolkit.fluxcd.io/app-version": "1.0.0"
},
"resourceVersion": "43136301",
"creationTimestamp": "2024-10-09T04:46:13Z"
},
"involvedObject": {
"uid": "e280b462-01b2-41a4-a53a-50541240a3e2",
"kind": "HelmRelease",
"name": "mission-control-kubernetes-bundle",
"namespace": "mission-control-agent",
"apiVersion": "helm.toolkit.fluxcd.io/v2",
"resourceVersion": "43130040"
}
}
}
29 changes: 29 additions & 0 deletions changes/testdata/helm_upgrade_failed_2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"details": {
"reason": "UpgradeFailed",
"source": {
"component": "helm-controller"
},
"message": "Helm upgrade failed for release mission-control-agent/mission-control-kubernetes-bundle with chart [email protected]: values don't meet the specifications of the schema(s) in the following chart(s):\nmission-control-kubernetes:\n- (root): Additional property interval is not allowed\n\nLast Helm logs:\n\n2024-10-09T03:31:10.99090145Z: preparing upgrade for mission-control-kubernetes-bundle\n2024-10-09T03:31:11.022444234Z: resetting values to the chart's original version",
"metadata": {
"uid": "552e28a9-54a4-4ba7-8dc2-a68924cbba60",
"name": "mission-control-kubernetes-bundle.17fcab45546704af",
"namespace": "mission-control-agent",
"annotations": {
"helm.toolkit.fluxcd.io/token": "sha256:eb7505628756567105a575c2dcaf473756212793a2b43537b976db9e18c7b233",
"helm.toolkit.fluxcd.io/revision": "0.1.69",
"helm.toolkit.fluxcd.io/app-version": "1.0.0"
},
"resourceVersion": "43130433",
"creationTimestamp": "2024-10-09T03:31:11Z"
},
"involvedObject": {
"uid": "e280b462-01b2-41a4-a53a-50541240a3e2",
"kind": "HelmRelease",
"name": "mission-control-kubernetes-bundle",
"namespace": "mission-control-agent",
"apiVersion": "helm.toolkit.fluxcd.io/v2",
"resourceVersion": "43098665"
}
}
}

0 comments on commit 516ecf9

Please sign in to comment.