Skip to content

Commit dffa2cd

Browse files
preserve variable interpolation when validating generated compose files (#1379)
1 parent 1f73a90 commit dffa2cd

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/pkg/cli/compose/load_content.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@ import (
77
composeTypes "github.com/compose-spec/compose-go/v2/types"
88
)
99

10-
func LoadFromContent(ctx context.Context, content []byte, nameFallback string) (*Project, error) {
10+
func loadFromContent(ctx context.Context, content []byte, nameFallback string, skipInterpolation bool) (*Project, error) {
1111
return loader.LoadWithContext(ctx, composeTypes.ConfigDetails{ConfigFiles: []composeTypes.ConfigFile{{Content: content}}}, func(o *loader.Options) {
1212
o.SetProjectName(nameFallback, false)
13-
o.SkipConsistencyCheck = true // this matches the WithConsistency(false) option from the loader
14-
o.SkipInterpolation = true
13+
o.SkipConsistencyCheck = true
14+
o.SkipInterpolation = skipInterpolation
1515
o.SkipResolveEnvironment = true
1616
o.SkipInclude = true
1717
})
1818
}
19+
20+
func LoadFromContent(ctx context.Context, content []byte, nameFallback string) (*Project, error) {
21+
return loadFromContent(ctx, content, nameFallback, true)
22+
}
23+
24+
func LoadFromContentWithInterpolation(ctx context.Context, content []byte, nameFallback string) (*Project, error) {
25+
return loadFromContent(ctx, content, nameFallback, false)
26+
}

src/pkg/migrate/migrate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func generateComposeFile(ctx context.Context, fabric client.FabricClient, platfo
153153
}
154154

155155
// Attempt to load the compose content
156-
_, err = compose.LoadFromContent(ctx, []byte(composeContent), projectName)
156+
_, err = compose.LoadFromContentWithInterpolation(ctx, []byte(composeContent), projectName)
157157
if err != nil {
158158
previousError = err.Error()
159159
term.Debugf("Invalid compose file received: %v. Retrying...", err)

0 commit comments

Comments
 (0)