Skip to content

Commit

Permalink
enhance(container): enable setting user (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanSussman committed Sep 27, 2021
1 parent c8edeac commit 522194f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pipeline/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
)

Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 2 additions & 0 deletions yaml/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
)

Expand All @@ -50,6 +51,7 @@ func (s *ServiceSlice) ToPipeline() *pipeline.ContainerSlice {
Ports: service.Ports,
Pull: service.Pull,
Ulimits: *service.Ulimits.ToPipeline(),
User: service.User,
})
}

Expand Down
2 changes: 2 additions & 0 deletions yaml/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
)

Expand All @@ -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,
})
}

Expand Down

0 comments on commit 522194f

Please sign in to comment.