summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorjannfis <jann@mistrust.net>2020-08-10 18:10:12 +0200
committerGitHub <noreply@github.com>2020-08-10 18:10:12 +0200
commitff305793f88ec128990c7bed319a6a7ffb1aeddc (patch)
treea6f1ff4352b177853a0d818b65908c14a43171aa /pkg
parent522523f7d5cad2c811aebfe7050d08a9b095157d (diff)
refactor: Rename sort option to update-strategy (#28)
Diffstat (limited to 'pkg')
-rw-r--r--pkg/common/constants.go4
-rw-r--r--pkg/image/options.go6
-rw-r--r--pkg/image/options_test.go28
3 files changed, 19 insertions, 19 deletions
diff --git a/pkg/common/constants.go b/pkg/common/constants.go
index 368e32c..782617d 100644
--- a/pkg/common/constants.go
+++ b/pkg/common/constants.go
@@ -22,8 +22,8 @@ const (
// Upgrade strategy related annotations
const (
- MatchOptionAnnotation = ImageUpdaterAnnotationPrefix + "/%s.match"
- SortOptionAnnotation = ImageUpdaterAnnotationPrefix + "/%s.sort"
+ MatchOptionAnnotation = ImageUpdaterAnnotationPrefix + "/%s.tag-match"
+ UpdateStrategyAnnotation = ImageUpdaterAnnotationPrefix + "/%s.update-strategy"
)
// Image pull secret related annotations
diff --git a/pkg/image/options.go b/pkg/image/options.go
index 957fe6c..0ae7ac1 100644
--- a/pkg/image/options.go
+++ b/pkg/image/options.go
@@ -54,8 +54,8 @@ func (img *ContainerImage) GetParameterKustomizeImageName(annotations map[string
// GetParameterSort gets and validates the value for the sort option for the
// image from a set of annotations
-func (img *ContainerImage) GetParameterSort(annotations map[string]string) VersionSortMode {
- key := fmt.Sprintf(common.SortOptionAnnotation, img.normalizedSymbolicName())
+func (img *ContainerImage) GetParameterUpdateStrategy(annotations map[string]string) VersionSortMode {
+ key := fmt.Sprintf(common.UpdateStrategyAnnotation, img.normalizedSymbolicName())
val, ok := annotations[key]
if !ok {
// Default is sort by version
@@ -66,7 +66,7 @@ func (img *ContainerImage) GetParameterSort(annotations map[string]string) Versi
case "semver":
log.Tracef("Sort option semver in %s", key)
return VersionSortSemVer
- case "date":
+ case "latest":
log.Tracef("Sort option date in %s", key)
return VersionSortLatest
case "name":
diff --git a/pkg/image/options_test.go b/pkg/image/options_test.go
index 52135ce..d9ce899 100644
--- a/pkg/image/options_test.go
+++ b/pkg/image/options_test.go
@@ -73,46 +73,46 @@ func Test_GetKustomizeOptions(t *testing.T) {
func Test_GetSortOption(t *testing.T) {
- t.Run("Get sort option semver for configured application", func(t *testing.T) {
+ t.Run("Get update strategy semver for configured application", func(t *testing.T) {
annotations := map[string]string{
- fmt.Sprintf(common.SortOptionAnnotation, "dummy"): "semver",
+ fmt.Sprintf(common.UpdateStrategyAnnotation, "dummy"): "semver",
}
img := NewFromIdentifier("dummy=foo/bar:1.12")
- sortMode := img.GetParameterSort(annotations)
+ sortMode := img.GetParameterUpdateStrategy(annotations)
assert.Equal(t, VersionSortSemVer, sortMode)
})
- t.Run("Get sort option date for configured application", func(t *testing.T) {
+ t.Run("Get update strategy date for configured application", func(t *testing.T) {
annotations := map[string]string{
- fmt.Sprintf(common.SortOptionAnnotation, "dummy"): "date",
+ fmt.Sprintf(common.UpdateStrategyAnnotation, "dummy"): "latest",
}
img := NewFromIdentifier("dummy=foo/bar:1.12")
- sortMode := img.GetParameterSort(annotations)
+ sortMode := img.GetParameterUpdateStrategy(annotations)
assert.Equal(t, VersionSortLatest, sortMode)
})
- t.Run("Get sort option name for configured application", func(t *testing.T) {
+ t.Run("Get update strategy name for configured application", func(t *testing.T) {
annotations := map[string]string{
- fmt.Sprintf(common.SortOptionAnnotation, "dummy"): "name",
+ fmt.Sprintf(common.UpdateStrategyAnnotation, "dummy"): "name",
}
img := NewFromIdentifier("dummy=foo/bar:1.12")
- sortMode := img.GetParameterSort(annotations)
+ sortMode := img.GetParameterUpdateStrategy(annotations)
assert.Equal(t, VersionSortName, sortMode)
})
- t.Run("Get default sort option configured application because of invalid option", func(t *testing.T) {
+ t.Run("Get update strategy option configured application because of invalid option", func(t *testing.T) {
annotations := map[string]string{
- fmt.Sprintf(common.SortOptionAnnotation, "dummy"): "invalid",
+ fmt.Sprintf(common.UpdateStrategyAnnotation, "dummy"): "invalid",
}
img := NewFromIdentifier("dummy=foo/bar:1.12")
- sortMode := img.GetParameterSort(annotations)
+ sortMode := img.GetParameterUpdateStrategy(annotations)
assert.Equal(t, VersionSortSemVer, sortMode)
})
- t.Run("Get default sort option configured application because of option not set", func(t *testing.T) {
+ t.Run("Get update strategy option configured application because of option not set", func(t *testing.T) {
annotations := map[string]string{}
img := NewFromIdentifier("dummy=foo/bar:1.12")
- sortMode := img.GetParameterSort(annotations)
+ sortMode := img.GetParameterUpdateStrategy(annotations)
assert.Equal(t, VersionSortSemVer, sortMode)
})
}