Skip to content

Commit

Permalink
Use short field options for Driver, and add driver_opts
Browse files Browse the repository at this point in the history
Signed-off-by: Sune Keller <absukl@almbrand.dk>
  • Loading branch information
sirlatrom committed Mar 28, 2019
1 parent def397a commit e59e264
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cli/command/secret/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func newSecretCreateCommand(dockerCli command.Cli) *cobra.Command {
flags.StringVarP(&options.driver, "driver", "d", "", "Secret driver")
flags.SetAnnotation("driver", "version", []string{"1.31"})
flags.StringVar(&options.templateDriver, "template-driver", "", "Template driver")
flags.SetAnnotation("driver", "version", []string{"1.37"})
flags.SetAnnotation("template-driver", "version", []string{"1.37"})

return cmd
}
Expand Down
3 changes: 2 additions & 1 deletion cli/compose/convert/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ func Secrets(namespace Namespace, secrets map[string]composetypes.SecretConfig)
spec := swarm.SecretSpec{Annotations: obj.Annotations, Data: obj.Data}
if secret.Driver != "" {
spec.Driver = &swarm.Driver{
Name: secret.Driver,
Name: secret.Driver,
Options: secret.DriverOpts,
}
}
if secret.TemplateDriver != "" {
Expand Down
4 changes: 4 additions & 0 deletions cli/compose/loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,10 @@ func loadFileObjectConfig(name string, objType string, obj types.FileObjectConfi
}
}
// if not "external: true"
} else if obj.Driver != "" {
if obj.File != "" {
return obj, errors.Errorf("%[1]s %[2]s: %[1]s.driver and %[1]s.file conflict; only use %[1]s.driver", objType, name)
}
} else {
obj.File = absPath(details.WorkingDir, obj.File)
}
Expand Down
6 changes: 6 additions & 0 deletions cli/compose/schema/data/config_schema_v3.8.json
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,12 @@
},
"labels": {"$ref": "#/definitions/list_or_dict"},
"driver": {"type": "string"},
"driver_opts": {
"type": "object",
"patternProperties": {
"^.+$": {"type": ["string", "number"]}
}
},
"template_driver": {"type": "string"}
},
"patternProperties": {"^x-": {}},
Expand Down
3 changes: 2 additions & 1 deletion cli/compose/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,8 @@ type FileObjectConfig struct {
External External `yaml:",omitempty" json:"external,omitempty"`
Labels Labels `yaml:",omitempty" json:"labels,omitempty"`
Extras map[string]interface{} `yaml:",inline" json:"-"`
Driver string `mapstructure:"driver" yaml:"driver,omitempty" json:"driver,omitempty"`
Driver string `yaml:",omitempty" json:"driver,omitempty"`
DriverOpts map[string]string `mapstructure:"driver_opts" yaml:"driver_opts,omitempty" json:"driver_opts,omitempty"`
TemplateDriver string `mapstructure:"template_driver" yaml:"template_driver,omitempty" json:"template_driver,omitempty"`
}

Expand Down

0 comments on commit e59e264

Please sign in to comment.