Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PipelineWorkspaceDeclaration instead of WorkspacePipelineDeclaration 👷‍♀️ #2717

Merged
merged 1 commit into from
Jun 4, 2020
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
2 changes: 1 addition & 1 deletion internal/builder/v1alpha1/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ func PipelineResourceSpecSecretParam(fieldname, secretName, secretKey string) Pi
func PipelineWorkspaceDeclaration(names ...string) PipelineSpecOp {
return func(spec *v1alpha1.PipelineSpec) {
for _, name := range names {
spec.Workspaces = append(spec.Workspaces, v1alpha1.WorkspacePipelineDeclaration{Name: name})
spec.Workspaces = append(spec.Workspaces, v1alpha1.PipelineWorkspaceDeclaration{Name: name})
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/builder/v1alpha1/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func TestPipeline(t *testing.T) {
}}},
}},
}},
Workspaces: []v1alpha1.WorkspacePipelineDeclaration{{
Workspaces: []v1alpha1.PipelineWorkspaceDeclaration{{
Name: "workspace1",
}},
},
Expand Down
2 changes: 1 addition & 1 deletion internal/builder/v1beta1/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ func PipelineRunTaskRunsStatus(taskRunName string, status *v1beta1.PipelineRunTa
func PipelineWorkspaceDeclaration(names ...string) PipelineSpecOp {
return func(spec *v1beta1.PipelineSpec) {
for _, name := range names {
spec.Workspaces = append(spec.Workspaces, v1beta1.WorkspacePipelineDeclaration{Name: name})
spec.Workspaces = append(spec.Workspaces, v1beta1.PipelineWorkspaceDeclaration{Name: name})
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/builder/v1beta1/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func TestPipeline(t *testing.T) {
}}},
},
}},
Workspaces: []v1beta1.WorkspacePipelineDeclaration{{
Workspaces: []v1beta1.PipelineWorkspaceDeclaration{{
Name: "workspace1",
}},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1alpha1/pipeline_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestPipelineConversion(t *testing.T) {
Type: v1beta1.ParamTypeString,
Description: "My first param",
}},
Workspaces: []WorkspacePipelineDeclaration{{
Workspaces: []PipelineWorkspaceDeclaration{{
Name: "workspace1",
}},
Tasks: []PipelineTask{{
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1alpha1/pipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type PipelineSpec struct {
// Workspaces declares a set of named workspaces that are expected to be
// provided by a PipelineRun.
// +optional
Workspaces []WorkspacePipelineDeclaration `json:"workspaces,omitempty"`
Workspaces []PipelineWorkspaceDeclaration `json:"workspaces,omitempty"`
// Results are values that this pipeline can output once run
// +optional
Results []PipelineResult `json:"results,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1alpha1/pipeline_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func validatePipelineTaskName(ctx context.Context, prefix string, i int, t Pipel
return nil
}

func validatePipelineWorkspaces(wss []WorkspacePipelineDeclaration, pts []PipelineTask) *apis.FieldError {
func validatePipelineWorkspaces(wss []PipelineWorkspaceDeclaration, pts []PipelineTask) *apis.FieldError {
// Workspace names must be non-empty and unique.
wsTable := make(map[string]struct{})
for i, ws := range wss {
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/pipeline/v1alpha1/workspace_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ type WorkspaceDeclaration = v1beta1.WorkspaceDeclaration
// WorkspaceBinding maps a Task's declared workspace to a Volume.
type WorkspaceBinding = v1beta1.WorkspaceBinding

// WorkspacePipelineDeclaration creates a named slot in a Pipeline that a PipelineRun
// PipelineWorkspaceDeclaration creates a named slot in a Pipeline that a PipelineRun
// is expected to populate with a workspace binding.
type WorkspacePipelineDeclaration = v1beta1.WorkspacePipelineDeclaration
type PipelineWorkspaceDeclaration = v1beta1.PipelineWorkspaceDeclaration

// WorkspacePipelineTaskBinding describes how a workspace passed into the pipeline should be
// mapped to a task's declared workspace.
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1alpha1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1beta1/pipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type PipelineSpec struct {
// Workspaces declares a set of named workspaces that are expected to be
// provided by a PipelineRun.
// +optional
Workspaces []WorkspacePipelineDeclaration `json:"workspaces,omitempty"`
Workspaces []PipelineWorkspaceDeclaration `json:"workspaces,omitempty"`
// Results are values that this pipeline can output once run
// +optional
Results []PipelineResult `json:"results,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1beta1/pipeline_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func validatePipelineTaskName(ctx context.Context, prefix string, i int, t Pipel

// validatePipelineWorkspaces validates the specified workspaces, ensuring having unique name without any empty string,
// and validates that all the referenced workspaces (by pipeline tasks) are specified in the pipeline
func validatePipelineWorkspaces(wss []WorkspacePipelineDeclaration, pts []PipelineTask) *apis.FieldError {
func validatePipelineWorkspaces(wss []PipelineWorkspaceDeclaration, pts []PipelineTask) *apis.FieldError {
// Workspace names must be non-empty and unique.
wsTable := make(map[string]struct{})
for i, ws := range wss {
Expand Down
14 changes: 7 additions & 7 deletions pkg/apis/pipeline/v1beta1/pipeline_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestPipeline_Validate_Success(t *testing.T) {
StringVal: "pipeline-default",
},
}},
Workspaces: []WorkspacePipelineDeclaration{{
Workspaces: []PipelineWorkspaceDeclaration{{
Name: "shared-workspace",
Description: "this is my shared workspace",
}},
Expand Down Expand Up @@ -978,11 +978,11 @@ func TestValidatePipelineParameterVariables_Failure(t *testing.T) {
func TestValidatePipelineWorkspaces_Success(t *testing.T) {
tests := []struct {
name string
workspaces []WorkspacePipelineDeclaration
workspaces []PipelineWorkspaceDeclaration
tasks []PipelineTask
}{{
name: "unused pipeline spec workspaces do not cause an error",
workspaces: []WorkspacePipelineDeclaration{{
workspaces: []PipelineWorkspaceDeclaration{{
Name: "foo",
}, {
Name: "bar",
Expand All @@ -1004,11 +1004,11 @@ func TestValidatePipelineWorkspaces_Success(t *testing.T) {
func TestValidatePipelineWorkspaces_Failure(t *testing.T) {
tests := []struct {
name string
workspaces []WorkspacePipelineDeclaration
workspaces []PipelineWorkspaceDeclaration
tasks []PipelineTask
}{{
name: "workspace bindings relying on a non-existent pipeline workspace cause an error",
workspaces: []WorkspacePipelineDeclaration{{
workspaces: []PipelineWorkspaceDeclaration{{
Name: "foo",
}},
tasks: []PipelineTask{{
Expand All @@ -1020,7 +1020,7 @@ func TestValidatePipelineWorkspaces_Failure(t *testing.T) {
}},
}, {
name: "multiple workspaces sharing the same name are not allowed",
workspaces: []WorkspacePipelineDeclaration{{
workspaces: []PipelineWorkspaceDeclaration{{
Name: "foo",
}, {
Name: "foo",
Expand All @@ -1030,7 +1030,7 @@ func TestValidatePipelineWorkspaces_Failure(t *testing.T) {
}},
}, {
name: "workspace name must not be empty",
workspaces: []WorkspacePipelineDeclaration{{
workspaces: []PipelineWorkspaceDeclaration{{
Name: "",
}},
tasks: []PipelineTask{{
Expand Down
7 changes: 6 additions & 1 deletion pkg/apis/pipeline/v1beta1/workspace_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ type WorkspaceBinding struct {

// WorkspacePipelineDeclaration creates a named slot in a Pipeline that a PipelineRun
// is expected to populate with a workspace binding.
type WorkspacePipelineDeclaration struct {
// Deprecated: use PipelineWorkspaceDeclaration type instead
type WorkspacePipelineDeclaration = PipelineWorkspaceDeclaration

// PipelineWorkspaceDeclaration creates a named slot in a Pipeline that a PipelineRun
// is expected to populate with a workspace binding.
type PipelineWorkspaceDeclaration struct {
// Name is the name of a workspace to be provided by a PipelineRun.
Name string `json:"name"`
// Description is a human readable string describing how the workspace will be
Expand Down
34 changes: 17 additions & 17 deletions pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion test/builder/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func TestPipeline(t *testing.T) {
}}},
}},
}},
Workspaces: []v1alpha1.WorkspacePipelineDeclaration{{
Workspaces: []v1alpha1.PipelineWorkspaceDeclaration{{
Name: "workspace1",
}},
},
Expand Down
4 changes: 2 additions & 2 deletions test/workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func TestWorkspacePipelineRunDuplicateWorkspaceEntriesInvalid(t *testing.T) {
pipeline := &v1beta1.Pipeline{
ObjectMeta: metav1.ObjectMeta{Name: pipelineName, Namespace: namespace},
Spec: v1beta1.PipelineSpec{
Workspaces: []v1beta1.WorkspacePipelineDeclaration{{
Workspaces: []v1beta1.PipelineWorkspaceDeclaration{{
Name: "foo",
}},
Tasks: []v1beta1.PipelineTask{{
Expand Down Expand Up @@ -204,7 +204,7 @@ func TestWorkspacePipelineRunMissingWorkspaceInvalid(t *testing.T) {
pipeline := &v1beta1.Pipeline{
ObjectMeta: metav1.ObjectMeta{Name: pipelineName, Namespace: namespace},
Spec: v1beta1.PipelineSpec{
Workspaces: []v1beta1.WorkspacePipelineDeclaration{{
Workspaces: []v1beta1.PipelineWorkspaceDeclaration{{
Name: "foo",
}},
Tasks: []v1beta1.PipelineTask{{
Expand Down