-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(admintools): add default image tag if left empty
- Loading branch information
1 parent
4afb5fe
commit 4f19690
Showing
5 changed files
with
78 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package version | ||
|
||
import "fmt" | ||
|
||
// DefaultAdminToolTag returns the tag of the admin tools image for the given version. | ||
// It's required as 1.24.x had really bad image tagging. | ||
func DefaultAdminToolTag(version *Version) string { | ||
// Particular case for >= 1.24.0 but < 1.25.0 | ||
if version.GreaterOrEqual(V1_24_0) && version.LessThan(V1_25_0) { | ||
return "1.24.2-tctl-1.18.1-cli-0.13.2" | ||
} | ||
|
||
// Particular case for >= 1.25 because the admin tools image tag doesn't | ||
// contains patch version (or it has the same bad naming as for 1.24.x). | ||
if version.GreaterOrEqual(V1_25_0) { | ||
return fmt.Sprintf("%d.%d", version.Major(), version.Minor()) | ||
} | ||
|
||
return version.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package version_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/alexandrevilain/temporal-operator/pkg/version" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestDefaultAdminToolTag(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
version *version.Version | ||
expected string | ||
}{ | ||
{ | ||
name: "Version 1.24.1", | ||
version: version.MustNewVersionFromString("1.24.1"), | ||
expected: "1.24.2-tctl-1.18.1-cli-0.13.2", | ||
}, | ||
{ | ||
name: "Version 1.24.9", | ||
version: version.MustNewVersionFromString("1.24.9"), | ||
expected: "1.24.2-tctl-1.18.1-cli-0.13.2", | ||
}, | ||
{ | ||
name: "Version 1.25.0", | ||
version: version.MustNewVersionFromString("1.25.0"), | ||
expected: "1.25", | ||
}, | ||
{ | ||
name: "Version 1.25.5", | ||
version: version.MustNewVersionFromString("1.25.5"), | ||
expected: "1.25", | ||
}, | ||
{ | ||
name: "Version 1.26.0", | ||
version: version.MustNewVersionFromString("1.26.0"), | ||
expected: "1.26", | ||
}, | ||
{ | ||
name: "Version 1.10.0", | ||
version: version.MustNewVersionFromString("1.10.0"), | ||
expected: "1.10.0", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
assert.Equal(t, tt.expected, version.DefaultAdminToolTag(tt.version)) | ||
}) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.