Skip to content

Commit

Permalink
add secrets property to build section
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
  • Loading branch information
glours committed Mar 10, 2022
1 parent 98c14dd commit af73eeb
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 12 deletions.
7 changes: 7 additions & 0 deletions loader/full-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ services:
- foo
- bar
labels: [FOO=BAR]
secrets:
- secret1
- source: secret2
target: my_secret
uid: '103'
gid: '103'
mode: 0440


cap_add:
Expand Down
33 changes: 32 additions & 1 deletion loader/full-struct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ func services(workingDir, homeDir string) []types.ServiceConfig {
Network: "foo",
CacheFrom: []string{"foo", "bar"},
Labels: map[string]string{"FOO": "BAR"},
Secrets: []types.ServiceSecretConfig{
{
Source: "secret1",
},
{
Source: "secret2",
Target: "my_secret",
UID: "103",
GID: "103",
Mode: uint32Ptr(0440),
},
},
},
CapAdd: []string{"ALL"},
CapDrop: []string{"NET_ADMIN", "SYS_ADMIN"},
Expand Down Expand Up @@ -576,6 +588,13 @@ services:
- bar
network: foo
target: foo
secrets:
- source: secret1
- source: secret2
target: my_secret
uid: "103"
gid: "103"
mode: 288
cap_add:
- ALL
cap_drop:
Expand Down Expand Up @@ -1090,7 +1109,19 @@ func fullExampleJSON(workingDir, homeDir string) string {
"bar"
],
"network": "foo",
"target": "foo"
"target": "foo",
"secrets": [
{
"source": "secret1"
},
{
"source": "secret2",
"target": "my_secret",
"uid": "103",
"gid": "103",
"mode": 288
}
]
},
"cap_add": [
"ALL"
Expand Down
22 changes: 21 additions & 1 deletion schema/compose-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,27 @@
"target": {"type": "string"},
"shm_size": {"type": ["integer", "string"]},
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
"isolation": {"type": "string"}
"isolation": {"type": "string"},
"secrets": {
"type": "array",
"items": {
"oneOf": [
{"type": "string"},
{
"type": "object",
"properties": {
"source": {"type": "string"},
"target": {"type": "string"},
"uid": {"type": "string"},
"gid": {"type": "string"},
"mode": {"type": "number"}
},
"additionalProperties": false,
"patternProperties": {"^x-": {}}
}
]
}
}
},
"additionalProperties": false,
"patternProperties": {"^x-": {}}
Expand Down
21 changes: 11 additions & 10 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,17 @@ func (s set) toSlice() []string {

// BuildConfig is a type for build
type BuildConfig struct {
Context string `yaml:",omitempty" json:"context,omitempty"`
Dockerfile string `yaml:",omitempty" json:"dockerfile,omitempty"`
Args MappingWithEquals `yaml:",omitempty" json:"args,omitempty"`
Labels Labels `yaml:",omitempty" json:"labels,omitempty"`
CacheFrom StringList `mapstructure:"cache_from" yaml:"cache_from,omitempty" json:"cache_from,omitempty"`
CacheTo StringList `mapstructure:"cache_to" yaml:"cache_to,omitempty" json:"cache_to,omitempty"`
ExtraHosts HostsList `mapstructure:"extra_hosts" yaml:"extra_hosts,omitempty" json:"extra_hosts,omitempty"`
Isolation string `yaml:",omitempty" json:"isolation,omitempty"`
Network string `yaml:",omitempty" json:"network,omitempty"`
Target string `yaml:",omitempty" json:"target,omitempty"`
Context string `yaml:",omitempty" json:"context,omitempty"`
Dockerfile string `yaml:",omitempty" json:"dockerfile,omitempty"`
Args MappingWithEquals `yaml:",omitempty" json:"args,omitempty"`
Labels Labels `yaml:",omitempty" json:"labels,omitempty"`
CacheFrom StringList `mapstructure:"cache_from" yaml:"cache_from,omitempty" json:"cache_from,omitempty"`
CacheTo StringList `mapstructure:"cache_to" yaml:"cache_to,omitempty" json:"cache_to,omitempty"`
ExtraHosts HostsList `mapstructure:"extra_hosts" yaml:"extra_hosts,omitempty" json:"extra_hosts,omitempty"`
Isolation string `yaml:",omitempty" json:"isolation,omitempty"`
Network string `yaml:",omitempty" json:"network,omitempty"`
Target string `yaml:",omitempty" json:"target,omitempty"`
Secrets []ServiceSecretConfig `yaml:",omitempty" json:"secrets,omitempty"`

Extensions map[string]interface{} `yaml:",inline" json:"-"`
}
Expand Down

0 comments on commit af73eeb

Please sign in to comment.