adding helm match tag
parent
bb495fad56
commit
6211693ce7
|
@ -97,6 +97,7 @@ type Root struct {
|
|||
// KeelChartConfig - keel related configuration taken from values.yaml
|
||||
type KeelChartConfig struct {
|
||||
Policy types.PolicyType `json:"policy"`
|
||||
MatchTag bool `json:"matchTag"`
|
||||
Trigger types.TriggerType `json:"trigger"`
|
||||
PollSchedule string `json:"pollSchedule"`
|
||||
Approvals int `json:"approvals"` // Minimum required approvals
|
||||
|
|
|
@ -499,3 +499,71 @@ keel:
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetChartMatchTag(t *testing.T) {
|
||||
|
||||
chartVals := `
|
||||
name: al Rashid
|
||||
where:
|
||||
city: Basrah
|
||||
title: caliph
|
||||
image:
|
||||
repository: gcr.io/v2-namespace/hello-world
|
||||
tag: 1.1.0
|
||||
|
||||
keel:
|
||||
policy: all
|
||||
trigger: poll
|
||||
matchTag: true
|
||||
images:
|
||||
- repository: image.repository
|
||||
tag: image.tag
|
||||
|
||||
`
|
||||
|
||||
fakeImpl := &fakeImplementer{
|
||||
listReleasesResponse: &rls.ListReleasesResponse{
|
||||
Releases: []*hapi_release5.Release{
|
||||
&hapi_release5.Release{
|
||||
Name: "release-1",
|
||||
Chart: &chart.Chart{
|
||||
Values: &chart.Config{Raw: chartVals},
|
||||
Metadata: &chart.Metadata{Name: "app-x"},
|
||||
},
|
||||
Config: &chart.Config{Raw: ""},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
releases, err := fakeImpl.ListReleases()
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %s", err)
|
||||
}
|
||||
|
||||
policyFound := false
|
||||
|
||||
for _, release := range releases.Releases {
|
||||
|
||||
vals, err := values(release.Chart, release.Config)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get values: %s", err)
|
||||
}
|
||||
|
||||
cfg, err := getKeelConfig(vals)
|
||||
if err != nil {
|
||||
t.Errorf("failed to get image paths: %s", err)
|
||||
}
|
||||
|
||||
if cfg.Policy == types.PolicyTypeAll {
|
||||
policyFound = true
|
||||
}
|
||||
if !cfg.MatchTag {
|
||||
t.Errorf("expected to find 'matchTag' == true ")
|
||||
}
|
||||
}
|
||||
|
||||
if !policyFound {
|
||||
t.Errorf("policy not found")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,16 @@ func checkUnversionedRelease(repo *types.Repository, namespace, name string, cha
|
|||
log.WithFields(log.Fields{
|
||||
"parsed_image_name": imageRef.Remote(),
|
||||
"target_image_name": repo.Name,
|
||||
}).Info("provider.helm: images do not match, ignoring")
|
||||
}).Debug("provider.helm: images do not match, ignoring")
|
||||
continue
|
||||
}
|
||||
|
||||
if keelCfg.MatchTag && imageRef.Tag() != eventRepoRef.Tag() {
|
||||
log.WithFields(log.Fields{
|
||||
"parsed_image_name": imageRef.Remote(),
|
||||
"target_image_name": repo.Name,
|
||||
"policy": keelCfg.Policy.String(),
|
||||
}).Info("provider.helm: match tag set but tags do not match, ignoring")
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue