@@ -16,7 +16,6 @@ package chart
16
16
17
17
import (
18
18
"fmt"
19
- "path"
20
19
"path/filepath"
21
20
"strings"
22
21
@@ -175,10 +174,21 @@ func (c *Chart) ValuesFilePathsForCI() []string {
175
174
return c .ciValuesPaths
176
175
}
177
176
177
+ // HasCIValuesFile checks whether a given CI values file is present.
178
+ func (c * Chart ) HasCIValuesFile (path string ) bool {
179
+ fileName := filepath .Base (path )
180
+ for _ , file := range c .ValuesFilePathsForCI () {
181
+ if fileName == filepath .Base (file ) {
182
+ return true
183
+ }
184
+ }
185
+ return false
186
+ }
187
+
178
188
// CreateInstallParams generates a randomized release name and namespace based on the chart path
179
189
// and optional buildID. If a buildID is specified, it will be part of the generated namespace.
180
190
func (c * Chart ) CreateInstallParams (buildID string ) (release string , namespace string ) {
181
- release = path .Base (c .Path ())
191
+ release = filepath .Base (c .Path ())
182
192
if release == "." || release == "/" {
183
193
yaml := c .Yaml ()
184
194
release = yaml .Name
@@ -200,7 +210,7 @@ func NewChart(chartPath string) (*Chart, error) {
200
210
if err != nil {
201
211
return nil , err
202
212
}
203
- matches , _ := filepath .Glob (path .Join (chartPath , "ci/ *-values.yaml" ))
213
+ matches , _ := filepath .Glob (filepath .Join (chartPath , "ci" , " *-values.yaml" ))
204
214
return & Chart {chartPath , yaml , matches }, nil
205
215
}
206
216
@@ -248,7 +258,7 @@ const ctPreviousRevisionTree = "ct_previous_revision"
248
258
// computePreviousRevisionPath converts any file or directory path to the same path in the
249
259
// previous revision's working tree.
250
260
func computePreviousRevisionPath (fileOrDirPath string ) string {
251
- return path .Join (ctPreviousRevisionTree , fileOrDirPath )
261
+ return filepath .Join (ctPreviousRevisionTree , fileOrDirPath )
252
262
}
253
263
254
264
func (t * Testing ) processCharts (action func (chart * Chart ) TestResult ) ([]TestResult , error ) {
@@ -389,8 +399,8 @@ func (t *Testing) LintChart(chart *Chart) TestResult {
389
399
}
390
400
}
391
401
392
- chartYaml := path .Join (chart .Path (), "Chart.yaml" )
393
- valuesYaml := path .Join (chart .Path (), "values.yaml" )
402
+ chartYaml := filepath .Join (chart .Path (), "Chart.yaml" )
403
+ valuesYaml := filepath .Join (chart .Path (), "values.yaml" )
394
404
valuesFiles := chart .ValuesFilePathsForCI ()
395
405
396
406
if t .config .ValidateChartSchema {
@@ -530,7 +540,11 @@ func (t *Testing) doUpgrade(oldChart, newChart *Chart, oldChartMustPass bool) er
530
540
}
531
541
for _ , valuesFile := range valuesFiles {
532
542
if valuesFile != "" {
533
- fmt .Printf ("\n Installing chart '%s' with values file '%s'...\n \n " , oldChart .Path (), valuesFile )
543
+ if t .config .SkipMissingValues && ! newChart .HasCIValuesFile (valuesFile ) {
544
+ fmt .Printf ("Upgrade testing for values file '%s' skipped because a corresponding values file was not found in %s/ci" , valuesFile , newChart .Path ())
545
+ continue
546
+ }
547
+ fmt .Printf ("\n Installing chart '%s' with values file '%s'...\n \n " , oldChart , valuesFile )
534
548
}
535
549
536
550
// Use anonymous function. Otherwise deferred calls would pile up
@@ -677,7 +691,7 @@ func (t *Testing) ReadAllChartDirectories() ([]string, error) {
677
691
dirs , err := t .directoryLister .ListChildDirs (chartParentDir ,
678
692
func (dir string ) bool {
679
693
_ , err := t .chartUtils .LookupChartDir (cfg .ChartDirs , dir )
680
- return err == nil && ! util .StringSliceContains (cfg .ExcludedCharts , path .Base (dir ))
694
+ return err == nil && ! util .StringSliceContains (cfg .ExcludedCharts , filepath .Base (dir ))
681
695
})
682
696
if err != nil {
683
697
return nil , errors .Wrap (err , "Error reading chart directories" )
@@ -739,7 +753,7 @@ func (t *Testing) checkBreakingChangeAllowed(chart *Chart) (allowed bool, err er
739
753
func (t * Testing ) GetOldChartVersion (chartPath string ) (string , error ) {
740
754
cfg := t .config
741
755
742
- chartYamlFile := path .Join (chartPath , "Chart.yaml" )
756
+ chartYamlFile := filepath .Join (chartPath , "Chart.yaml" )
743
757
if ! t .git .FileExistsOnBranch (chartYamlFile , cfg .Remote , cfg .TargetBranch ) {
744
758
fmt .Printf ("Unable to find chart on %s. New chart detected.\n " , cfg .TargetBranch )
745
759
return "" , nil
0 commit comments