Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ require (
github.com/jteeuwen/go-bindata v3.0.8-0.20151023091102-a0ff2567cfb7+incompatible
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.0.2-0.20190823105129-775207bd45b6
github.com/openshift/api v0.0.0-20211209135129-c58d9f695577
github.com/openshift/api v0.0.0-20211222145011-3bf13cf5081a
github.com/openshift/apiserver-library-go v0.0.0-20211209162547-8c11dbc46b6e
github.com/openshift/build-machinery-go v0.0.0-20210806203541-4ea9b6da3a37
github.com/openshift/build-machinery-go v0.0.0-20211213093930-7e33a7eb4ce3
github.com/openshift/client-go v0.0.0-20211209144617-7385dd6338e3
github.com/openshift/library-go v0.0.0-20211216141749-1816407208cf
github.com/spf13/cobra v1.2.1
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -552,13 +552,15 @@ github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/
github.com/opencontainers/runtime-spec v1.0.3-0.20200929063507-e6143ca7d51d/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xAPP8dBsCoU0KuF8=
github.com/openshift/api v0.0.0-20211209135129-c58d9f695577 h1:NUe82M8wMYXbd5s+WBAJ2QAZZivs+nhZ3zYgZFwKfqw=
github.com/openshift/api v0.0.0-20211209135129-c58d9f695577/go.mod h1:DoslCwtqUpr3d/gsbq4ZlkaMEdYqKxuypsDjorcHhME=
github.com/openshift/api v0.0.0-20211222145011-3bf13cf5081a h1:lJQ6mKlpoUn19dmaLY/ldRm2Mwi+WtTJ2MD6bteLa4o=
github.com/openshift/api v0.0.0-20211222145011-3bf13cf5081a/go.mod h1:F/eU6jgr6Q2VhMu1mSpMmygxAELd7+BUxs3NHZ25jV4=
github.com/openshift/apiserver-library-go v0.0.0-20211209162547-8c11dbc46b6e h1:1SSdcGjCsh95bGyIDgczAvAYigvMb4rh2rbWKOpfoew=
github.com/openshift/apiserver-library-go v0.0.0-20211209162547-8c11dbc46b6e/go.mod h1:xmXp4ppleImFhXXeHI7/jPoZiu0xvkPbrciB+U8K+64=
github.com/openshift/build-machinery-go v0.0.0-20210712174854-1bb7fd1518d3/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE=
github.com/openshift/build-machinery-go v0.0.0-20210806203541-4ea9b6da3a37 h1:40Nw4fwP1tXx0g1UgIGoLA9eoSdLm7jBUXFH5uVYjBA=
github.com/openshift/build-machinery-go v0.0.0-20210806203541-4ea9b6da3a37/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE=
github.com/openshift/build-machinery-go v0.0.0-20211213093930-7e33a7eb4ce3 h1:65oBhJYHzYK5VL0gF1eiYY37lLzyLZ47b9y5Kib1nf8=
github.com/openshift/build-machinery-go v0.0.0-20211213093930-7e33a7eb4ce3/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE=
github.com/openshift/client-go v0.0.0-20211209144617-7385dd6338e3 h1:SG1aqwleU6bGD0X4mhkTNupjVnByMYYuW4XbnCPavQU=
github.com/openshift/client-go v0.0.0-20211209144617-7385dd6338e3/go.mod h1:cwhyki5lqBmrT0m8Im+9I7PGFaraOzcYPtEz93RcsGY=
github.com/openshift/docker-distribution v0.0.0-20180925154709-d4c35485a70d h1:tupVADlF1SZrGy0Y0kg1FKUi2mVPzRwxVb+8LLMu8ws=
Expand Down
7 changes: 7 additions & 0 deletions pkg/build/apis/build/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,9 @@ const (

// BuildVolumeSourceTypeConfigmap is the ConfigMap build source volume type
BuildVolumeSourceTypeConfigMap BuildVolumeSourceType = "ConfigMap"

// BuildVolumeSourceTypeCSI is the CSI build source volume type
BuildVolumeSourceTypeCSI BuildVolumeSourceType = "CSI"
)

// BuildVolumeSource represents the source of a volume to mount
Expand All @@ -1439,6 +1442,10 @@ type BuildVolumeSource struct {
// configMap represents a ConfigMap that should populate this volume
// +optional
ConfigMap *kapi.ConfigMapVolumeSource

// csi represents ephemeral storage provided by external CSI drivers which support this capability
// +optional
CSI *kapi.CSIVolumeSource
}

// BuildVolumeMount describes the mounting of a Volume within buildah's runtime environment.
Expand Down
18 changes: 18 additions & 0 deletions pkg/build/apis/build/v1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions pkg/build/apis/build/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,16 @@ func validateBuildVolume(volume buildapi.BuildVolume, fldPath *field.Path) field
}
foundVolumeSources = append(foundVolumeSources, string(buildapi.BuildVolumeSourceTypeConfigMap))
}

if volume.Source.CSI != nil {
if len(volume.Source.CSI.Driver) == 0 {
allErrs = append(allErrs, field.Required(fldPath.Child("source").Child("csi").Child("driver"), ""))
} else if reasons := validation.ValidateCSIDriverName(volume.Source.CSI.Driver, fldPath.Child("source").Child("csi").Child("driver")); len(reasons) != 0 {
allErrs = append(allErrs, reasons...)
}
foundVolumeSources = append(foundVolumeSources, string(buildapi.BuildVolumeSourceTypeCSI))
}

if len(foundVolumeSources) == 0 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("source"), volume.Source, "must specify one volume source"))
}
Expand Down
91 changes: 91 additions & 0 deletions pkg/build/apis/build/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3831,6 +3831,97 @@ func TestValidateBuildVolumes(t *testing.T) {
},
errors: []string{},
},
{
name: "csi source and type should match",
volume: buildapi.BuildVolume{
Name: "csi-source-type-mismatch-fail",
Source: buildapi.BuildVolumeSource{
Type: buildapi.BuildVolumeSourceTypeConfigMap,
CSI: &kapi.CSIVolumeSource{
Driver: "csi.driver.ephemeral.io",
VolumeAttributes: map[string]string{
"attribute": "value",
},
},
},
Mounts: []buildapi.BuildVolumeMount{
{
DestinationPath: "/some/path",
},
},
},
errors: []string{"source type and specified type must match"},
},
{
name: "empty CSI driver name should fail",
volume: buildapi.BuildVolume{
Name: "csi-empty-driver-name-fail",
Source: buildapi.BuildVolumeSource{
Type: buildapi.BuildVolumeSourceTypeCSI,
CSI: &kapi.CSIVolumeSource{},
},
Mounts: []buildapi.BuildVolumeMount{
{
DestinationPath: "/some/path",
},
},
},
errors: []string{"Required value"},
},
{
name: "csi driver name longer than 63 characters should fail",
volume: buildapi.BuildVolume{
Name: "csi-driver-name-too-long-fail",
Source: buildapi.BuildVolumeSource{
Type: buildapi.BuildVolumeSourceTypeCSI,
CSI: &kapi.CSIVolumeSource{
Driver: "abcdefghijklmnopqrstuvwxyz1234567890.abcdefghijklmnopqrstuvwxyz1234567890-abcdefghijklmnopqrstuvwxyz1234567890",
},
},
Mounts: []buildapi.BuildVolumeMount{
{
DestinationPath: "/some/path",
},
},
},
errors: []string{"must have at most 63 bytes"},
},
{
name: "csi driver name that is not a DNS 1123 subdomain should fail",
volume: buildapi.BuildVolume{
Name: "csi-driver-invalid-dns-1123-fail",
Source: buildapi.BuildVolumeSource{
Type: buildapi.BuildVolumeSourceTypeCSI,
CSI: &kapi.CSIVolumeSource{
Driver: "subdoman.Invalid-Upper-Case+@SpecialChars.io",
},
},
Mounts: []buildapi.BuildVolumeMount{
{
DestinationPath: "/some/path",
},
},
},
errors: []string{"a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters"},
},
{
name: "valid csi driver name should succeed",
volume: buildapi.BuildVolume{
Name: "csi-driver-name-valid",
Source: buildapi.BuildVolumeSource{
Type: buildapi.BuildVolumeSourceTypeCSI,
CSI: &kapi.CSIVolumeSource{
Driver: "valid.csi-driver.io",
},
},
Mounts: []buildapi.BuildVolumeMount{
{
DestinationPath: "/some/path",
},
},
},
errors: []string{},
},
}

for _, tt := range tests {
Expand Down
5 changes: 5 additions & 0 deletions pkg/build/apis/build/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions pkg/openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading