diff --git a/loader/full-example.yml b/loader/full-example.yml index 9614fd2f..08467227 100644 --- a/loader/full-example.yml +++ b/loader/full-example.yml @@ -15,6 +15,8 @@ services: - foo - bar labels: [FOO=BAR] + additional_contexts: + foo: /bar secrets: - secret1 - source: secret2 diff --git a/loader/full-struct_test.go b/loader/full-struct_test.go index add25008..8e4aa1e7 100644 --- a/loader/full-struct_test.go +++ b/loader/full-struct_test.go @@ -50,14 +50,15 @@ func services(workingDir, homeDir string) []types.ServiceConfig { Name: "foo", Build: &types.BuildConfig{ - Context: "./dir", - Dockerfile: "Dockerfile", - Args: map[string]*string{"foo": strPtr("bar")}, - SSH: []types.SSHKey{{ID: "default", Path: ""}}, - Target: "foo", - Network: "foo", - CacheFrom: []string{"foo", "bar"}, - Labels: map[string]string{"FOO": "BAR"}, + Context: "./dir", + Dockerfile: "Dockerfile", + Args: map[string]*string{"foo": strPtr("bar")}, + SSH: []types.SSHKey{{ID: "default", Path: ""}}, + Target: "foo", + Network: "foo", + CacheFrom: []string{"foo", "bar"}, + AdditionalContexts: map[string]*string{"foo": strPtr("/bar")}, + Labels: map[string]string{"FOO": "BAR"}, Secrets: []types.ServiceSecretConfig{ { Source: "secret1", @@ -597,6 +598,8 @@ services: cache_from: - foo - bar + additional_contexts: + foo: /bar network: foo target: foo secrets: @@ -1137,6 +1140,9 @@ func fullExampleJSON(workingDir, homeDir string) string { "foo", "bar" ], + "additional_contexts": { + "foo": "/bar" + }, "network": "foo", "target": "foo", "secrets": [ diff --git a/schema/compose-spec.json b/schema/compose-spec.json index d8cc36a6..78d6979f 100644 --- a/schema/compose-spec.json +++ b/schema/compose-spec.json @@ -97,6 +97,7 @@ "cache_from": {"type": "array", "items": {"type": "string"}}, "cache_to": {"type": "array", "items": {"type": "string"}}, "no_cache": {"type": "boolean"}, + "additional_contexts": {"$ref": "#/definitions/list_or_dict"}, "network": {"type": "string"}, "pull": {"type": "boolean"}, "target": {"type": "string"}, diff --git a/types/types.go b/types/types.go index fa1a1384..f3363c5c 100644 --- a/types/types.go +++ b/types/types.go @@ -294,23 +294,24 @@ 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"` - SSH SSHConfig `yaml:"ssh,omitempty" json:"ssh,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"` - NoCache bool `mapstructure:"no_cache" yaml:"no_cache,omitempty" json:"no_cache,omitempty"` - Pull bool `mapstructure:"pull" yaml:"pull,omitempty" json:"pull,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"` - Tags StringList `mapstructure:"tags" yaml:"tags,omitempty" json:"tags,omitempty"` - Platforms StringList `mapstructure:"platforms" yaml:"platforms,omitempty" json:"platforms,omitempty"` - Privileged bool `yaml:",omitempty" json:"privileged,omitempty"` + Context string `yaml:",omitempty" json:"context,omitempty"` + Dockerfile string `yaml:",omitempty" json:"dockerfile,omitempty"` + Args MappingWithEquals `yaml:",omitempty" json:"args,omitempty"` + SSH SSHConfig `yaml:"ssh,omitempty" json:"ssh,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"` + NoCache bool `mapstructure:"no_cache" yaml:"no_cache,omitempty" json:"no_cache,omitempty"` + AdditionalContexts MappingWithEquals `mapstructure:"additional_contexts" yaml:"additional_contexts,omitempty" json:"additional_contexts,omitempty"` + Pull bool `mapstructure:"pull" yaml:"pull,omitempty" json:"pull,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"` + Tags StringList `mapstructure:"tags" yaml:"tags,omitempty" json:"tags,omitempty"` + Platforms StringList `mapstructure:"platforms" yaml:"platforms,omitempty" json:"platforms,omitempty"` + Privileged bool `yaml:",omitempty" json:"privileged,omitempty"` Extensions map[string]interface{} `yaml:",inline" json:"-"` }