Skip to content

Commit

Permalink
Add HCD version override test
Browse files Browse the repository at this point in the history
  • Loading branch information
burmanm committed Oct 11, 2024
1 parent 85e07a0 commit fb9eb8c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
2 changes: 2 additions & 0 deletions apis/config/v1beta1/imageconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ type Images struct {

DSEVersions map[string]string `json:"dse,omitempty"`

HCDVersions map[string]string `json:"hcd,omitempty"`

SystemLogger string `json:"system-logger,omitempty"`

Client string `json:"k8ssandra-client,omitempty"`
Expand Down
7 changes: 7 additions & 0 deletions apis/config/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/images/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ func getCassandraContainerImageOverride(serverType, version string) (bool, strin
return true, value
}
}
if serverType == "hcd" {
if value, found := images.HCDVersions[version]; found {
return true, value
}
}
}
return false, ""
}
Expand Down
20 changes: 17 additions & 3 deletions pkg/images/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,28 @@ func TestCassandraOverride(t *testing.T) {
assert.NoError(err, "getting Cassandra image with overrides should succeed")
assert.Equal(fmt.Sprintf("ghcr.io/%s", customImageName), cassImage)

customImageWithOrg := "k8ssandra/cass-management-api:4.0.0"
customImageNamespace := "modified"
imageConfig.Images.CassandraVersions = map[string]string{
"4.0.0": fmt.Sprintf("us-docker.pkg.dev/%s", customImageWithOrg),
"4.0.0": fmt.Sprintf("us-docker.pkg.dev/%s/cass-management-api:4.0.0", customImageNamespace),
}
imageConfig.Images.DSEVersions = map[string]string{
"6.8.0": fmt.Sprintf("us-docker.pkg.dev/%s/dse-mgmtapi-6_8:6.8.0", customImageNamespace),
}
imageConfig.Images.HCDVersions = map[string]string{
"1.0.0": fmt.Sprintf("us-docker.pkg.dev/%s/hcd:1.0.0", customImageNamespace),
}

cassImage, err = GetCassandraImage("cassandra", "4.0.0")
assert.NoError(err, "getting Cassandra image with overrides should succeed")
assert.Equal(fmt.Sprintf("ghcr.io/%s", customImageWithOrg), cassImage)
assert.Equal("ghcr.io/modified/cass-management-api:4.0.0", cassImage)

cassImage, err = GetCassandraImage("dse", "6.8.0")
assert.NoError(err, "getting Cassandra image with overrides should succeed")
assert.Equal("ghcr.io/modified/dse-mgmtapi-6_8:6.8.0", cassImage)

cassImage, err = GetCassandraImage("hcd", "1.0.0")
assert.NoError(err, "getting Cassandra image with overrides should succeed")
assert.Equal("ghcr.io/modified/hcd:1.0.0", cassImage)
}

func TestDefaultImageConfigParsing(t *testing.T) {
Expand Down

0 comments on commit fb9eb8c

Please sign in to comment.