Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2.2k
use compose-go to load and parse compose files#4863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2,14 +2,16 @@ package stack | ||
| import ( | ||
| "fmt" | ||
| "path/filepath" | ||
| specLoader "github.com/compose-spec/compose-go/v2/loader" | ||
| compose "github.com/compose-spec/compose-go/v2/types" | ||
| "github.com/docker/cli/cli" | ||
| "github.com/docker/cli/cli/command" | ||
| "github.com/docker/cli/cli/command/completion" | ||
| "github.com/docker/cli/cli/command/stack/loader" | ||
| "github.com/docker/cli/cli/command/stack/options" | ||
| composeLoader "github.com/docker/cli/cli/compose/loader" | ||
| composetypes "github.com/docker/cli/cli/compose/types" | ||
| "github.com/spf13/cobra" | ||
| yaml "gopkg.in/yaml.v2" | ||
| ) | ||
| @@ -45,9 +47,17 @@ func newConfigCommand(dockerCli command.Cli) *cobra.Command { | ||
| } | ||
| // outputConfig returns the merged and interpolated config file | ||
| func outputConfig(configFiles composetypes.ConfigDetails, skipInterpolation bool) (string, error) { | ||
| optsFunc := func(opts *composeLoader.Options) { | ||
| func outputConfig(configFiles compose.ConfigDetails, skipInterpolation bool) (string, error) { | ||
| var dir string | ||
| for _, f := range configFiles.ConfigFiles { | ||
| if f.Filename != "" { | ||
| dir = filepath.Base(f.Filename) | ||
| break | ||
| } | ||
| } | ||
Comment on lines
+52
to
+57
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need to iterate over the config files here? I don't know much about this part of the code, but would like to know what problem it solves. For example, In which cases would the filename be empty? | ||
| optsFunc := func(opts *specLoader.Options) { | ||
| opts.SkipInterpolation = skipInterpolation | ||
| opts.SetProjectName(specLoader.NormalizeProjectName(dir), true) | ||
| } | ||
| config, err := composeLoader.Load(configFiles, optsFunc) | ||
| if err != nil { | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: keep it consistent with the other import names. Either stick with
composeorcomposetypes.