Skip to content

Commit

Permalink
Use PipelineWorkspaceDeclaration instead of WorkspacePipelineDeclarat…
Browse files Browse the repository at this point in the history
…ion 👷‍♀️

This is a super minor change to rename WorkspacePipelineDeclaration to
PipelineWorkspaceDeclaration. WorkspacePipelineDeclaration sounds like
it's a pipeline declaration inside of a workspace, but actually its
meant to be a workspace declaration inside of a pipeline!

I'm trying to pickup some of the work started in #1936
and this seemed like a reasonable improvement to carve off and merge on
its own :D

Co-authored-by: Scott <[email protected]>
  • Loading branch information
bobcatfish and Scott committed May 29, 2020
1 parent ea3e72e commit 3cac06f
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 29 deletions.
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
4 changes: 2 additions & 2 deletions pkg/apis/pipeline/v1beta1/workspace_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ type WorkspaceBinding struct {
Secret *corev1.SecretVolumeSource `json:"secret,omitempty"`
}

// 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 struct {
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
10 changes: 5 additions & 5 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

0 comments on commit 3cac06f

Please sign in to comment.