@@ -291,19 +291,19 @@ func (s set) toSlice() []string {
291
291
292
292
// BuildConfig is a type for build
293
293
type BuildConfig struct {
294
- Context string `yaml:",omitempty" json:"context,omitempty"`
295
- Dockerfile string `yaml:",omitempty" json:"dockerfile,omitempty"`
296
- Args MappingWithEquals `yaml:",omitempty" json:"args,omitempty"`
297
- SSH SSHConfig `yaml:"ssh,omitempty" json:"ssh,omitempty"`
298
- Labels Labels `yaml:",omitempty" json:"labels,omitempty"`
299
- CacheFrom StringList `mapstructure:"cache_from" yaml:"cache_from,omitempty" json:"cache_from,omitempty"`
300
- CacheTo StringList `mapstructure:"cache_to" yaml:"cache_to,omitempty" json:"cache_to,omitempty"`
301
- NoCache bool `mapstructure:"no_cache" yaml:"no_cache,omitempty" json:"no_cache,omitempty"`
302
- Pull bool `mapstructure:"pull" yaml:"pull,omitempty" json:"pull,omitempty"`
303
- ExtraHosts HostsList `mapstructure:"extra_hosts" yaml:"extra_hosts,omitempty" json:"extra_hosts,omitempty"`
304
- Isolation string `yaml:",omitempty" json:"isolation,omitempty"`
305
- Network string `yaml:",omitempty" json:"network,omitempty"`
306
- Target string `yaml:",omitempty" json:"target,omitempty"`
294
+ Context string `yaml:",omitempty" json:"context,omitempty"`
295
+ Dockerfile string `yaml:",omitempty" json:"dockerfile,omitempty"`
296
+ Args MappingWithEquals `yaml:",omitempty" json:"args,omitempty"`
297
+ SSH SSHConfig `yaml:"ssh,omitempty" json:"ssh,omitempty"`
298
+ Labels Labels `yaml:",omitempty" json:"labels,omitempty"`
299
+ CacheFrom StringList `mapstructure:"cache_from" yaml:"cache_from,omitempty" json:"cache_from,omitempty"`
300
+ CacheTo StringList `mapstructure:"cache_to" yaml:"cache_to,omitempty" json:"cache_to,omitempty"`
301
+ NoCache bool `mapstructure:"no_cache" yaml:"no_cache,omitempty" json:"no_cache,omitempty"`
302
+ Pull bool `mapstructure:"pull" yaml:"pull,omitempty" json:"pull,omitempty"`
303
+ ExtraHosts HostsList `mapstructure:"extra_hosts" yaml:"extra_hosts,omitempty" json:"extra_hosts,omitempty"`
304
+ Isolation string `yaml:",omitempty" json:"isolation,omitempty"`
305
+ Network string `yaml:",omitempty" json:"network,omitempty"`
306
+ Target string `yaml:",omitempty" json:"target,omitempty"`
307
307
Secrets []ServiceSecretConfig `yaml:",omitempty" json:"secrets,omitempty"`
308
308
309
309
Extensions map [string ]interface {} `yaml:",inline" json:"-"`
@@ -679,6 +679,25 @@ type ServiceVolumeConfig struct {
679
679
Extensions map [string ]interface {} `yaml:",inline" json:"-"`
680
680
}
681
681
682
+ // String render ServiceVolumeConfig as a volume string, one can parse back using loader.ParseVolume
683
+ func (s ServiceVolumeConfig ) String () string {
684
+ access := "rw"
685
+ if s .ReadOnly {
686
+ access = "ro"
687
+ }
688
+ options := []string {access }
689
+ if s .Bind != nil && s .Bind .SELinux != "" {
690
+ options = append (options , s .Bind .SELinux )
691
+ }
692
+ if s .Bind != nil && s .Bind .Propagation != "" {
693
+ options = append (options , s .Bind .Propagation )
694
+ }
695
+ if s .Volume != nil && s .Volume .NoCopy {
696
+ options = append (options , "nocopy" )
697
+ }
698
+ return fmt .Sprintf ("%s:%s:%s" , s .Source , s .Target , strings .Join (options , "," ))
699
+ }
700
+
682
701
const (
683
702
// VolumeTypeBind is the type for mounting host dir
684
703
VolumeTypeBind = "bind"
0 commit comments