@@ -133,6 +133,10 @@ var _ = Describe("HelmChartReconciler", func() {
133133 _ = k8sClient .Get (context .Background (), key , got )
134134 return got .Status .Artifact != nil && storage .ArtifactExist (* got .Status .Artifact )
135135 }, timeout , interval ).Should (BeTrue ())
136+ helmChart , err := loader .Load (storage .LocalPath (* got .Status .Artifact ))
137+ Expect (err ).NotTo (HaveOccurred ())
138+ Expect (helmChart .Values ["testDefault" ]).To (BeTrue ())
139+ Expect (helmChart .Values ["testOverride" ]).To (BeFalse ())
136140
137141 By ("Packaging a new chart version and regenerating the index" )
138142 Expect (helmServer .PackageChartWithVersion (path .Join ("testdata/charts/helmchart" ), "0.2.0" )).Should (Succeed ())
@@ -585,13 +589,55 @@ var _ = Describe("HelmChartReconciler", func() {
585589 Expect (err ).NotTo (HaveOccurred ())
586590
587591 By ("Expecting new artifact revision and GC" )
592+ now := & sourcev1.HelmChart {}
588593 Eventually (func () bool {
589- now := & sourcev1.HelmChart {}
590594 _ = k8sClient .Get (context .Background (), key , now )
591595 // Test revision change and garbage collection
592596 return now .Status .Artifact .Revision != got .Status .Artifact .Revision &&
593597 ! storage .ArtifactExist (* got .Status .Artifact )
594598 }, timeout , interval ).Should (BeTrue ())
599+ helmChart , err := loader .Load (storage .LocalPath (* now .Status .Artifact ))
600+ Expect (err ).NotTo (HaveOccurred ())
601+ Expect (helmChart .Values ["testDefault" ]).To (BeTrue ())
602+ Expect (helmChart .Values ["testOverride" ]).To (BeFalse ())
603+
604+ When ("Setting valid valuesFile attribute" , func () {
605+ updated := & sourcev1.HelmChart {}
606+ Expect (k8sClient .Get (context .Background (), key , updated )).To (Succeed ())
607+ updated .Spec .ValuesFile = "./testdata/charts/helmchart/override.yaml"
608+ Expect (k8sClient .Update (context .Background (), updated )).To (Succeed ())
609+ got := & sourcev1.HelmChart {}
610+ Eventually (func () bool {
611+ _ = k8sClient .Get (context .Background (), key , got )
612+ return got .Status .Artifact .Checksum != updated .Status .Artifact .Checksum &&
613+ storage .ArtifactExist (* got .Status .Artifact )
614+ }, timeout , interval ).Should (BeTrue ())
615+ f , err := os .Stat (storage .LocalPath (* got .Status .Artifact ))
616+ Expect (err ).NotTo (HaveOccurred ())
617+ Expect (f .Size ()).To (BeNumerically (">" , 0 ))
618+ helmChart , err := loader .Load (storage .LocalPath (* got .Status .Artifact ))
619+ Expect (err ).NotTo (HaveOccurred ())
620+ Expect (helmChart .Values ["testOverride" ]).To (BeTrue ())
621+ })
622+
623+ When ("Setting invalid valuesFile attribute" , func () {
624+ updated := & sourcev1.HelmChart {}
625+ Expect (k8sClient .Get (context .Background (), key , updated )).To (Succeed ())
626+ updated .Spec .ValuesFile = "./testdata/charts/helmchart/invalid.yaml"
627+ Expect (k8sClient .Update (context .Background (), updated )).To (Succeed ())
628+ got := & sourcev1.HelmChart {}
629+ Eventually (func () bool {
630+ _ = k8sClient .Get (context .Background (), key , got )
631+ return got .Status .ObservedGeneration > updated .Status .ObservedGeneration &&
632+ storage .ArtifactExist (* got .Status .Artifact )
633+ }, timeout , interval ).Should (BeTrue ())
634+ f , err := os .Stat (storage .LocalPath (* got .Status .Artifact ))
635+ Expect (err ).NotTo (HaveOccurred ())
636+ Expect (f .Size ()).To (BeNumerically (">" , 0 ))
637+ helmChart , err := loader .Load (storage .LocalPath (* got .Status .Artifact ))
638+ Expect (err ).NotTo (HaveOccurred ())
639+ Expect (helmChart .Values ["testOverride" ]).To (BeTrue ())
640+ })
595641 })
596642
597643 It ("Creates artifacts with .tgz file" , func () {
@@ -693,31 +739,6 @@ var _ = Describe("HelmChartReconciler", func() {
693739 return got .Status .Artifact != nil &&
694740 storage .ArtifactExist (* got .Status .Artifact )
695741 }, timeout , interval ).Should (BeTrue ())
696-
697- When ("Setting valid valuesFile attribute" , func () {
698- updated := & sourcev1.HelmChart {}
699- Expect (k8sClient .Get (context .Background (), key , updated )).To (Succeed ())
700- chart .Spec .ValuesFile = "./charts/helmchart/override.yaml"
701- Expect (k8sClient .Update (context .Background (), updated )).To (Succeed ())
702- got := & sourcev1.HelmChart {}
703- Eventually (func () bool {
704- _ = k8sClient .Get (context .Background (), key , got )
705- return got .Status .Artifact != nil &&
706- storage .ArtifactExist (* got .Status .Artifact )
707- }, timeout , interval ).Should (BeTrue ())
708- })
709-
710- When ("Setting invalid valuesFile attribute" , func () {
711- updated := & sourcev1.HelmChart {}
712- Expect (k8sClient .Get (context .Background (), key , updated )).To (Succeed ())
713- chart .Spec .ValuesFile = "invalid.yaml"
714- Expect (k8sClient .Update (context .Background (), updated )).To (Succeed ())
715- got := & sourcev1.HelmChart {}
716- Eventually (func () bool {
717- _ = k8sClient .Get (context .Background (), key , got )
718- return got .Status .Artifact != nil && got .Status .Artifact .Revision == updated .Status .Artifact .Revision
719- }, timeout , interval ).Should (BeTrue ())
720- })
721742 })
722743 })
723744
@@ -961,30 +982,47 @@ var _ = Describe("HelmChartReconciler", func() {
961982 return got .Status .Artifact != nil &&
962983 storage .ArtifactExist (* got .Status .Artifact )
963984 }, timeout , interval ).Should (BeTrue ())
985+ helmChart , err := loader .Load (storage .LocalPath (* got .Status .Artifact ))
986+ Expect (err ).NotTo (HaveOccurred ())
987+ Expect (helmChart .Values ["testDefault" ]).To (BeTrue ())
988+ Expect (helmChart .Values ["testOverride" ]).To (BeFalse ())
964989
965990 When ("Setting valid valuesFile attribute" , func () {
966991 updated := & sourcev1.HelmChart {}
967992 Expect (k8sClient .Get (context .Background (), key , updated )).To (Succeed ())
968- chart .Spec .ValuesFile = "override.yaml"
993+ updated .Spec .ValuesFile = "./testdata/charts/helmchartwithdeps/ override.yaml"
969994 Expect (k8sClient .Update (context .Background (), updated )).To (Succeed ())
970995 got := & sourcev1.HelmChart {}
971996 Eventually (func () bool {
972997 _ = k8sClient .Get (context .Background (), key , got )
973- return got .Status .Artifact != nil &&
998+ return got .Status .Artifact . Checksum != updated . Status . Artifact . Checksum &&
974999 storage .ArtifactExist (* got .Status .Artifact )
9751000 }, timeout , interval ).Should (BeTrue ())
1001+ f , err := os .Stat (storage .LocalPath (* got .Status .Artifact ))
1002+ Expect (err ).NotTo (HaveOccurred ())
1003+ Expect (f .Size ()).To (BeNumerically (">" , 0 ))
1004+ helmChart , err := loader .Load (storage .LocalPath (* got .Status .Artifact ))
1005+ Expect (err ).NotTo (HaveOccurred ())
1006+ Expect (helmChart .Values ["testOverride" ]).To (BeTrue ())
9761007 })
9771008
9781009 When ("Setting invalid valuesFile attribute" , func () {
9791010 updated := & sourcev1.HelmChart {}
9801011 Expect (k8sClient .Get (context .Background (), key , updated )).To (Succeed ())
981- chart .Spec .ValuesFile = "./charts/helmchart/override .yaml"
1012+ updated .Spec .ValuesFile = "./testdata/ charts/helmchartwithdeps/invalid .yaml"
9821013 Expect (k8sClient .Update (context .Background (), updated )).To (Succeed ())
9831014 got := & sourcev1.HelmChart {}
9841015 Eventually (func () bool {
9851016 _ = k8sClient .Get (context .Background (), key , got )
986- return got .Status .Artifact != nil && got .Status .Artifact .Revision == updated .Status .Artifact .Revision
1017+ return got .Status .ObservedGeneration > updated .Status .ObservedGeneration &&
1018+ storage .ArtifactExist (* got .Status .Artifact )
9871019 }, timeout , interval ).Should (BeTrue ())
1020+ f , err := os .Stat (storage .LocalPath (* got .Status .Artifact ))
1021+ Expect (err ).NotTo (HaveOccurred ())
1022+ Expect (f .Size ()).To (BeNumerically (">" , 0 ))
1023+ helmChart , err := loader .Load (storage .LocalPath (* got .Status .Artifact ))
1024+ Expect (err ).NotTo (HaveOccurred ())
1025+ Expect (helmChart .Values ["testOverride" ]).To (BeTrue ())
9881026 })
9891027 })
9901028 })
0 commit comments