From 522194f7764b1a278cfa7ec6d047ff4c88bb286e Mon Sep 17 00:00:00 2001 From: Jordan Sussman Date: Mon, 27 Sep 2021 10:25:26 -0500 Subject: [PATCH] enhance(container): enable setting user (#199) --- pipeline/container.go | 4 +++- yaml/service.go | 2 ++ yaml/step.go | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pipeline/container.go b/pipeline/container.go index 6383f214..84c6fce8 100644 --- a/pipeline/container.go +++ b/pipeline/container.go @@ -50,6 +50,7 @@ type ( Secrets StepSecretSlice `json:"secrets,omitempty" yaml:"secrets,omitempty"` Ulimits UlimitSlice `json:"ulimits,omitempty" yaml:"ulimits,omitempty"` Volumes VolumeSlice `json:"volumes,omitempty" yaml:"volumes,omitempty"` + User string `json:"user,omitempty" yaml:"user,omitempty"` } ) @@ -126,7 +127,8 @@ func (c *Container) Empty() bool { reflect.DeepEqual(c.Ruleset, Ruleset{}) && len(c.Secrets) == 0 && len(c.Ulimits) == 0 && - len(c.Volumes) == 0 { + len(c.Volumes) == 0 && + len(c.User) == 0 { return true } diff --git a/yaml/service.go b/yaml/service.go index a4987b9f..d45eedf8 100644 --- a/yaml/service.go +++ b/yaml/service.go @@ -29,6 +29,7 @@ type ( Ports raw.StringSlice `yaml:"ports,omitempty" json:"ports,omitempty" jsonschema:"description=List of ports to map for the container in the pipeline.\nReference: https://go-vela.github.io/docs/reference/yaml/services/#the-ports-tag"` Pull string `yaml:"pull,omitempty" json:"pull,omitempty" jsonschema:"enum=always,enum=not_present,enum=on_start,enum=never,default=not_present,description=Declaration to configure if and when the Docker image is pulled.\nReference: https://go-vela.github.io/docs/reference/yaml/services/#the-pul-tag"` Ulimits UlimitSlice `yaml:"ulimits,omitempty" json:"ulimits,omitempty" jsonschema:"description=Set the user limits for the container.\nReference: https://go-vela.github.io/docs/reference/yaml/services/#the-ulimits-tag"` + User string `yaml:"user,omitempty" json:"user,omitempty" jsonschema:"description=Set the user for the container.\nReference: https://go-vela.github.io/docs/reference/yaml/steps/#the-user-tag"` } ) @@ -50,6 +51,7 @@ func (s *ServiceSlice) ToPipeline() *pipeline.ContainerSlice { Ports: service.Ports, Pull: service.Pull, Ulimits: *service.Ulimits.ToPipeline(), + User: service.User, }) } diff --git a/yaml/step.go b/yaml/step.go index 6a6278c2..fa65eb67 100644 --- a/yaml/step.go +++ b/yaml/step.go @@ -36,6 +36,7 @@ type ( Parameters map[string]interface{} `yaml:"parameters,omitempty" json:"parameters,omitempty" jsonschema:"description=Extra configuration variables for a plugin.\nReference: https://go-vela.github.io/docs/reference/yaml/steps/#the-parameters-tag"` Detach bool `yaml:"detach,omitempty" json:"detach,omitempty" jsonschema:"description=Run the container in a detached (headless) state.\nReference: https://go-vela.github.io/docs/reference/yaml/steps/#the-detach-tag"` Privileged bool `yaml:"privileged,omitempty" json:"privileged,omitempty" jsonschema:"description=Run the container with extra privileges.\nReference: https://go-vela.github.io/docs/reference/yaml/steps/#the-privileged-tag"` + User string `yaml:"user,omitempty" json:"user,omitempty" jsonschema:"description=Set the user for the container.\nReference: https://go-vela.github.io/docs/reference/yaml/steps/#the-user-tag"` } ) @@ -61,6 +62,7 @@ func (s *StepSlice) ToPipeline() *pipeline.ContainerSlice { Secrets: *step.Secrets.ToPipeline(), Ulimits: *step.Ulimits.ToPipeline(), Volumes: *step.Volumes.ToPipeline(), + User: step.User, }) }