Skip to content

Commit

Permalink
Add support for template_driver in composefiles
Browse files Browse the repository at this point in the history
This maps the `--template-driver` flag on secret and config creation.

Signed-off-by: Vincent Demeester <[email protected]>
  • Loading branch information
vdemeester committed May 31, 2018
1 parent a8ee42a commit 505668f
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 44 deletions.
16 changes: 14 additions & 2 deletions cli/compose/convert/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@ func Secrets(namespace Namespace, secrets map[string]composetypes.SecretConfig)
if err != nil {
return nil, err
}
result = append(result, swarm.SecretSpec{Annotations: obj.Annotations, Data: obj.Data})
spec := swarm.SecretSpec{Annotations: obj.Annotations, Data: obj.Data}
if secret.TemplateDriver != "" {
spec.Templating = &swarm.Driver{
Name: secret.TemplateDriver,
}
}
result = append(result, spec)
}
return result, nil
}
Expand All @@ -127,7 +133,13 @@ func Configs(namespace Namespace, configs map[string]composetypes.ConfigObjConfi
if err != nil {
return nil, err
}
result = append(result, swarm.ConfigSpec{Annotations: obj.Annotations, Data: obj.Data})
spec := swarm.ConfigSpec{Annotations: obj.Annotations, Data: obj.Data}
if config.TemplateDriver != "" {
spec.Templating = &swarm.Driver{
Name: config.TemplateDriver,
}
}
result = append(result, spec)
}
return result, nil
}
Expand Down
72 changes: 36 additions & 36 deletions cli/compose/schema/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions cli/compose/schema/data/config_schema_v3.7.json
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,8 @@
"name": {"type": "string"}
}
},
"labels": {"$ref": "#/definitions/list_or_dict"}
"labels": {"$ref": "#/definitions/list_or_dict"},
"template_driver": {"type": "string"}
},
"additionalProperties": false
},
Expand All @@ -545,7 +546,8 @@
"name": {"type": "string"}
}
},
"labels": {"$ref": "#/definitions/list_or_dict"}
"labels": {"$ref": "#/definitions/list_or_dict"},
"template_driver": {"type": "string"}
},
"additionalProperties": false
},
Expand Down
9 changes: 5 additions & 4 deletions cli/compose/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,11 @@ type CredentialSpecConfig struct {

// FileObjectConfig is a config type for a file used by a service
type FileObjectConfig struct {
Name string `yaml:",omitempty"`
File string `yaml:",omitempty"`
External External `yaml:",omitempty"`
Labels Labels `yaml:",omitempty"`
Name string `yaml:",omitempty"`
File string `yaml:",omitempty"`
External External `yaml:",omitempty"`
Labels Labels `yaml:",omitempty"`
TemplateDriver string `mapstructure:"template_driver" yaml:"template_driver,omitempty"`
}

// SecretConfig for a secret
Expand Down

0 comments on commit 505668f

Please sign in to comment.