Skip to content

Commit

Permalink
Add Beta feature gate for projected workspace
Browse files Browse the repository at this point in the history
This commit adds the Beta feature gate for projected workspace in v1.
  • Loading branch information
JeromeJu committed Oct 25, 2022
1 parent d50cfda commit ec1be89
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/apis/pipeline/v1/workspace_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@ func (b *WorkspaceBinding) Validate(ctx context.Context) (errs *apis.FieldError)
return apis.ErrMissingField("secret.secretName")
}

// The projected workspace is only supported when the beta feature gate is enabled.
// For a Projected volume to work, you must provide at least one source.
if b.Projected != nil && len(b.Projected.Sources) == 0 {
return apis.ErrMissingField("projected.sources")
errs := version.ValidateEnabledAPIFields(ctx, "projected workspace type", config.BetaAPIFields).ViaField("workspaces")
if errs != nil {
return errs
}
if len(b.Projected.Sources) == 0 {
return apis.ErrMissingField("projected.sources")
}
}

// The csi workspace is only supported when the alpha feature gate is enabled.
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/pipeline/v1/workspace_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func TestWorkspaceBindingValidateValid(t *testing.T) {
}},
},
},
wc: config.EnableBetaAPIFields,
}, {
name: "Valid csi",
binding: &v1.WorkspaceBinding{
Expand Down Expand Up @@ -165,12 +166,19 @@ func TestWorkspaceBindingValidateInvalid(t *testing.T) {
Name: "beth",
Secret: &corev1.SecretVolumeSource{},
},
}, {
name: "projected workspace should be disallowed without beta feature gate",
binding: &v1.WorkspaceBinding{
Name: "beth",
Projected: &corev1.ProjectedVolumeSource{},
},
}, {
name: "Provide projected without sources",
binding: &v1.WorkspaceBinding{
Name: "beth",
Projected: &corev1.ProjectedVolumeSource{},
},
wc: config.EnableBetaAPIFields,
}, {
name: "csi workspace should be disallowed without alpha feature gate",
binding: &v1.WorkspaceBinding{
Expand Down

0 comments on commit ec1be89

Please sign in to comment.