mirror of https://github.com/docker/compose.git
config --environment
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
cc09f39f29
commit
d633c33a19
|
@ -54,6 +54,7 @@ type configOptions struct {
|
|||
hash string
|
||||
noConsistency bool
|
||||
variables bool
|
||||
environment bool
|
||||
}
|
||||
|
||||
func (o *configOptions) ToProject(ctx context.Context, dockerCli command.Cli, services []string, po ...cli.ProjectOptionsFn) (*types.Project, error) {
|
||||
|
@ -118,6 +119,9 @@ func configCommand(p *ProjectOptions, dockerCli command.Cli) *cobra.Command {
|
|||
if opts.variables {
|
||||
return runVariables(ctx, dockerCli, opts, args)
|
||||
}
|
||||
if opts.environment {
|
||||
return runEnvironment(ctx, dockerCli, opts, args)
|
||||
}
|
||||
|
||||
return runConfig(ctx, dockerCli, opts, args)
|
||||
}),
|
||||
|
@ -138,6 +142,7 @@ func configCommand(p *ProjectOptions, dockerCli command.Cli) *cobra.Command {
|
|||
flags.BoolVar(&opts.images, "images", false, "Print the image names, one per line.")
|
||||
flags.StringVar(&opts.hash, "hash", "", "Print the service config hash, one per line.")
|
||||
flags.BoolVar(&opts.variables, "variables", false, "Print model variables and default values.")
|
||||
flags.BoolVar(&opts.environment, "environment", false, "Print environment used for interpolation.")
|
||||
flags.StringVarP(&opts.Output, "output", "o", "", "Save to file (default to stdout)")
|
||||
|
||||
return cmd
|
||||
|
@ -385,6 +390,18 @@ func runVariables(ctx context.Context, dockerCli command.Cli, opts configOptions
|
|||
}, "NAME", "REQUIRED", "DEFAULT VALUE", "ALTERNATE VALUE")
|
||||
}
|
||||
|
||||
func runEnvironment(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) error {
|
||||
project, err := opts.ToProject(ctx, dockerCli, services)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, v := range project.Environment.Values() {
|
||||
fmt.Println(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func escapeDollarSign(marshal []byte) []byte {
|
||||
dollar := []byte{'$'}
|
||||
escDollar := []byte{'$', '$'}
|
||||
|
|
|
@ -12,6 +12,7 @@ Parse, resolve and render compose file in canonical format
|
|||
| Name | Type | Default | Description |
|
||||
|:--------------------------|:---------|:--------|:----------------------------------------------------------------------------|
|
||||
| `--dry-run` | | | Execute command in dry run mode |
|
||||
| `--environment` | | | Print environment used for interpolation. |
|
||||
| `--format` | `string` | `yaml` | Format the output. Values: [yaml \| json] |
|
||||
| `--hash` | `string` | | Print the service config hash, one per line. |
|
||||
| `--images` | | | Print the image names, one per line. |
|
||||
|
|
|
@ -9,6 +9,16 @@ usage: docker compose config [OPTIONS] [SERVICE...]
|
|||
pname: docker compose
|
||||
plink: docker_compose.yaml
|
||||
options:
|
||||
- option: environment
|
||||
value_type: bool
|
||||
default_value: "false"
|
||||
description: Print environment used for interpolation.
|
||||
deprecated: false
|
||||
hidden: false
|
||||
experimental: false
|
||||
experimentalcli: false
|
||||
kubernetes: false
|
||||
swarm: false
|
||||
- option: format
|
||||
value_type: string
|
||||
default_value: yaml
|
||||
|
|
Loading…
Reference in New Issue