Skip to content

Commit

Permalink
Make internal imageConfig to be non-pointer to allow easier usage in …
Browse files Browse the repository at this point in the history
…tests
  • Loading branch information
burmanm committed Mar 24, 2023
1 parent 6e8cd3f commit d7cf1a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pkg/images/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

var (
imageConfig *configv1beta1.ImageConfig
imageConfig configv1beta1.ImageConfig
scheme = runtime.NewScheme()
)

Expand Down Expand Up @@ -56,7 +56,7 @@ func LoadImageConfig(content []byte) (*configv1beta1.ImageConfig, error) {
return nil, fmt.Errorf("could not decode file into runtime.Object: %v", err)
}

imageConfig = parsedImageConfig
imageConfig = *parsedImageConfig

return parsedImageConfig, nil
}
Expand Down Expand Up @@ -111,7 +111,7 @@ func applyRegistry(imageType, image string) string {

func GetImageConfig() *configv1beta1.ImageConfig {
// For now, this is static configuration (updated only on start of the pod), even if the actual ConfigMap underneath is updated.
return imageConfig
return &imageConfig
}

func getCassandraContainerImageOverride(serverType, version string) (bool, string) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/images/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

func TestDefaultRegistryOverride(t *testing.T) {
assert := assert.New(t)
imageConfig = &configv1beta1.ImageConfig{}
imageConfig = configv1beta1.ImageConfig{}
imageConfig.ImageRegistry = "localhost:5000"
imageConfig.Images = &configv1beta1.Images{}
imageConfig.DefaultImages = &configv1beta1.DefaultImages{}
Expand All @@ -39,7 +39,7 @@ func TestCassandraOverride(t *testing.T) {

customImageName := "my-custom-image:4.0.0"

imageConfig = &configv1beta1.ImageConfig{}
imageConfig = configv1beta1.ImageConfig{}
imageConfig.Images = &configv1beta1.Images{}
imageConfig.DefaultImages = &configv1beta1.DefaultImages{}

Expand Down Expand Up @@ -144,7 +144,7 @@ func TestExtendedImageConfigParsing(t *testing.T) {

func TestDefaultRepositories(t *testing.T) {
assert := assert.New(t)
imageConfig = &configv1beta1.ImageConfig{}
imageConfig = configv1beta1.ImageConfig{}
imageConfig.Images = &configv1beta1.Images{}
imageConfig.DefaultImages = &configv1beta1.DefaultImages{}

Expand Down

0 comments on commit d7cf1a5

Please sign in to comment.