diff --git a/compiler/types/pipeline/container.go b/compiler/types/pipeline/container.go index 5cfb2acf9..83e6ca34d 100644 --- a/compiler/types/pipeline/container.go +++ b/compiler/types/pipeline/container.go @@ -53,6 +53,7 @@ type ( User string `json:"user,omitempty" yaml:"user,omitempty"` ReportAs string `json:"report_as,omitempty" yaml:"report_as,omitempty"` IDRequest string `json:"id_request,omitempty" yaml:"id_request,omitempty"` + LogTrunc string `json:"log_trunc,omitempty" yaml:"log_trunc,omitempty"` } ) @@ -137,7 +138,8 @@ func (c *Container) Empty() bool { len(c.Volumes) == 0 && len(c.User) == 0 && len(c.ReportAs) == 0 && - len(c.IDRequest) == 0 { + len(c.IDRequest) == 0 && + len(c.LogTrunc) == 0 { return true } diff --git a/compiler/types/yaml/buildkite/step.go b/compiler/types/yaml/buildkite/step.go index 4b36b93fd..45ad0e483 100644 --- a/compiler/types/yaml/buildkite/step.go +++ b/compiler/types/yaml/buildkite/step.go @@ -37,6 +37,7 @@ type ( 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-key"` ReportAs string `yaml:"report_as,omitempty" json:"report_as,omitempty" jsonschema:"description=Set the name of the step to report as.\nReference: https://go-vela.github.io/docs/reference/yaml/steps/#the-report_as-key"` IDRequest string `yaml:"id_request,omitempty" json:"id_request,omitempty" jsonschema:"description=Request ID Request Token for the step.\nReference: https://go-vela.github.io/docs/reference/yaml/steps/#the-id_request-key"` + LogTrunc string `yaml:"log_trunc,omitempty" json:"log_trunc,omitempty" jsonschema:"enum=head,enum=tail,description=When log reaches max size, set head or tail preference.\nReference: https://go-vela.github.io/docs/reference/yaml/steps/#the-log_trunc-key"` } ) @@ -65,6 +66,7 @@ func (s *StepSlice) ToPipeline() *pipeline.ContainerSlice { User: step.User, ReportAs: step.ReportAs, IDRequest: step.IDRequest, + LogTrunc: step.LogTrunc, }) } @@ -171,6 +173,7 @@ func (s *Step) ToYAML() *yaml.Step { User: s.User, ReportAs: s.ReportAs, IDRequest: s.IDRequest, + LogTrunc: s.LogTrunc, } } diff --git a/compiler/types/yaml/yaml/step.go b/compiler/types/yaml/yaml/step.go index 405e6d598..2c200a7b1 100644 --- a/compiler/types/yaml/yaml/step.go +++ b/compiler/types/yaml/yaml/step.go @@ -36,6 +36,7 @@ type ( 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-key"` ReportAs string `yaml:"report_as,omitempty" json:"report_as,omitempty" jsonschema:"description=Set the name of the step to report as.\nReference: https://go-vela.github.io/docs/reference/yaml/steps/#the-report_as-key"` IDRequest string `yaml:"id_request,omitempty" json:"id_request,omitempty" jsonschema:"description=Request ID Request Token for the step.\nReference: https://go-vela.github.io/docs/reference/yaml/steps/#the-id_request-key"` + LogTrunc string `yaml:"log_trunc,omitempty" json:"log_trunc,omitempty" jsonschema:"enum=head,enum=tail,description=When log reaches max size, set head or tail preference.\nReference: https://go-vela.github.io/docs/reference/yaml/steps/#the-log_trunc-key"` } ) @@ -64,6 +65,7 @@ func (s *StepSlice) ToPipeline() *pipeline.ContainerSlice { User: step.User, ReportAs: step.ReportAs, IDRequest: step.IDRequest, + LogTrunc: step.LogTrunc, }) } diff --git a/constants/log.go b/constants/log.go new file mode 100644 index 000000000..1c892f714 --- /dev/null +++ b/constants/log.go @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: Apache-2.0 + +package constants + +// Log options constants. +const ( + // LogHead defines the option for preserving beginning of logs + // when the step has produces over the limit of log bytes. + LogHead = "head" + + // LogTail defines the option for preserving end of logs + // when the step has produces over the limit of log bytes. + LogTail = "tail" +)