Skip to content

Commit

Permalink
Merge pull request #2597 from lizardruss/revert-2540
Browse files Browse the repository at this point in the history
fix: revert #2540 and add tests to prevent future regressions
  • Loading branch information
lizardruss authored Mar 9, 2023
2 parents 1a5d68b + fef06b1 commit 339c230
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/devspace/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func Ensure(config Config) Config {
retConfig = NewConfig(map[string]interface{}{}, retConfig.RawBeforeConversion(), retConfig.Config(), retConfig.LocalCache(), retConfig.RemoteCache(), retConfig.Variables(), retConfig.Path())
}
if retConfig.RawBeforeConversion() == nil {
retConfig = NewConfig(retConfig.Raw(), map[string]interface{}{}, latest.NewRaw(), retConfig.LocalCache(), retConfig.RemoteCache(), retConfig.Variables(), retConfig.Path())
retConfig = NewConfig(retConfig.Raw(), map[string]interface{}{}, retConfig.Config(), retConfig.LocalCache(), retConfig.RemoteCache(), retConfig.Variables(), retConfig.Path())
}
if retConfig.Config() == nil {
retConfig = NewConfig(retConfig.Raw(), retConfig.RawBeforeConversion(), latest.NewRaw(), retConfig.LocalCache(), retConfig.RemoteCache(), retConfig.Variables(), retConfig.Path())
Expand Down
2 changes: 1 addition & 1 deletion pkg/devspace/config/loader/variable/legacy/replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func resolveImage(value string, config config2.Config, dependencies []types.Depe

// try to find the tag for the image
tag := originalTag
if tag == "" && imageCache.Tag != "" {
if imageCache.Tag != "" {
tag = imageCache.Tag
}

Expand Down
29 changes: 29 additions & 0 deletions pkg/devspace/config/loader/variable/legacy/replace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,35 @@ func TestReplaceContainerNames(t *testing.T) {
"": "myimage:someTag",
},
},
{
name: "Image in cache replaces explicit tag",
overwriteValues: map[string]interface{}{
"": "myimage:master",
},
imagesConf: map[string]*latest.Image{
"test": {
Image: "myimage",
},
},
cache: &localcache.LocalCache{
Images: map[string]localcache.ImageCache{
"test": {
ImageName: "myimage",
Tag: "someTag",
},
},
},
builtImages: map[string]buildtypes.ImageNameTag{
"test": {
ImageName: "myimage",
ImageTag: "someTag",
},
},
expectedShouldRedeploy: true,
expectedOverwriteValues: map[string]interface{}{
"": "myimage:someTag",
},
},
{
name: "Replace image & tag helpers",
overwriteValues: map[string]interface{}{
Expand Down

0 comments on commit 339c230

Please sign in to comment.