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

This commit fixes some style issues noticed after #1345 was merged. #1356

Merged
merged 1 commit into from
Sep 25, 2019
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 pkg/apis/pipeline/v1alpha1/build_gcs_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (s *BuildGCSResource) GetInputTaskModifier(ts *TaskSpec, sourcePath string)
Args: args,
}}}

volumes, err := getStorageVolumeSpec(s, ts)
volumes, err := getStorageVolumeSpec(s, *ts)
if err != nil {
return nil, err
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/pipeline/v1alpha1/cloud_event_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ func (s *CloudEventResource) Replacements() map[string]string {
}
}

// GetInputTaskModifier returns the TaskModifier to be used when this resource is an input.
func (s *CloudEventResource) GetInputTaskModifier(_ *TaskSpec, _ string) (TaskModifier, error) {
return &InternalTaskModifier{}, nil
}

// GetOutputTaskModifier returns a No-op TaskModifier.
func (s *CloudEventResource) GetOutputTaskModifier(_ *TaskSpec, _ string) (TaskModifier, error) {
return &InternalTaskModifier{}, nil
}
2 changes: 2 additions & 0 deletions pkg/apis/pipeline/v1alpha1/cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,12 @@ func (s ClusterResource) String() string {
return string(json)
}

// GetOutputTaskModifier returns a No-op TaskModifier.
func (s *ClusterResource) GetOutputTaskModifier(_ *TaskSpec, _ string) (TaskModifier, error) {
return &InternalTaskModifier{}, nil
}

// GetInputTaskModifier returns the TaskModifier to be used when this resource is an input.
func (s *ClusterResource) GetInputTaskModifier(ts *TaskSpec, path string) (TaskModifier, error) {
var envVars []corev1.EnvVar
for _, sec := range s.Secrets {
Expand Down
6 changes: 4 additions & 2 deletions pkg/apis/pipeline/v1alpha1/gcs_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func (s *GCSResource) Replacements() map[string]string {
}
}

// GetOutputTaskModifier returns the TaskModifier to be used when this resource is an output.
func (s *GCSResource) GetOutputTaskModifier(ts *TaskSpec, path string) (TaskModifier, error) {
var args []string
if s.TypeDir {
Expand All @@ -116,7 +117,7 @@ func (s *GCSResource) GetOutputTaskModifier(ts *TaskSpec, path string) (TaskModi
Env: envVars},
}

volumes, err := getStorageVolumeSpec(s, ts)
volumes, err := getStorageVolumeSpec(s, *ts)
if err != nil {
return nil, err
}
Expand All @@ -127,6 +128,7 @@ func (s *GCSResource) GetOutputTaskModifier(ts *TaskSpec, path string) (TaskModi
}, nil
}

// GetInputTaskModifier returns the TaskModifier to be used when this resource is an input.
func (s *GCSResource) GetInputTaskModifier(ts *TaskSpec, path string) (TaskModifier, error) {
if path == "" {
return nil, xerrors.Errorf("GCSResource: Expect Destination Directory param to be set %s", s.Name)
Expand All @@ -150,7 +152,7 @@ func (s *GCSResource) GetInputTaskModifier(ts *TaskSpec, path string) (TaskModif
VolumeMounts: secretVolumeMount,
}}}

volumes, err := getStorageVolumeSpec(s, ts)
volumes, err := getStorageVolumeSpec(s, *ts)
if err != nil {
return nil, err
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/pipeline/v1alpha1/git_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func (s *GitResource) Replacements() map[string]string {
}
}

// GetInputTaskModifier returns the TaskModifier to be used when this resource is an input.
func (s *GitResource) GetInputTaskModifier(_ *TaskSpec, path string) (TaskModifier, error) {
args := []string{"-url", s.URL,
"-revision", s.Revision,
Expand All @@ -116,6 +117,7 @@ func (s *GitResource) GetInputTaskModifier(_ *TaskSpec, path string) (TaskModifi
}, nil
}

// GetOutputTaskModifier returns a No-op TaskModifier.
func (s *GitResource) GetOutputTaskModifier(_ *TaskSpec, _ string) (TaskModifier, error) {
return &InternalTaskModifier{}, nil
}
2 changes: 2 additions & 0 deletions pkg/apis/pipeline/v1alpha1/image_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ func (s *ImageResource) Replacements() map[string]string {
}
}

// GetInputTaskModifier returns the TaskModifier to be used when this resource is an input.
func (s *ImageResource) GetInputTaskModifier(_ *TaskSpec, _ string) (TaskModifier, error) {
return &InternalTaskModifier{}, nil
}

// GetOutputTaskModifier returns a No-op TaskModifier.
func (s *ImageResource) GetOutputTaskModifier(_ *TaskSpec, _ string) (TaskModifier, error) {
return &InternalTaskModifier{}, nil
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/pipeline/v1alpha1/pull_request_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,14 @@ func (s *PullRequestResource) Replacements() map[string]string {
}
}

// GetInputTaskModifier returns the TaskModifier to be used when this resource is an input.
func (s *PullRequestResource) GetInputTaskModifier(ts *TaskSpec, sourcePath string) (TaskModifier, error) {
return &InternalTaskModifier{
StepsToPrepend: s.getSteps("download", sourcePath),
}, nil
}

// GetOutputTaskModifier returns a No-op TaskModifier.
func (s *PullRequestResource) GetOutputTaskModifier(ts *TaskSpec, sourcePath string) (TaskModifier, error) {
return &InternalTaskModifier{
StepsToAppend: s.getSteps("upload", sourcePath),
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/pipeline/v1alpha1/resource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,29 @@ type TaskModifier interface {
GetVolumes() []v1.Volume
}

// InternalTaskModifier implements TaskModifier for resources that are built-in to Tekton Pipelines.
type InternalTaskModifier struct {
StepsToPrepend []Step
StepsToAppend []Step
Volumes []v1.Volume
}

// GetStepsToPrepend returns a set of Steps to prepend to the Task.
func (tm *InternalTaskModifier) GetStepsToPrepend() []Step {
return tm.StepsToPrepend
}

// GetStepsToPrepend returns a set of Steps to append to the Task.
func (tm *InternalTaskModifier) GetStepsToAppend() []Step {
return tm.StepsToAppend
}

// GetVolumes returns a set of Volumes to prepend to the Task pod.
func (tm *InternalTaskModifier) GetVolumes() []v1.Volume {
return tm.Volumes
}

// ApplyTaskModifier applies a modifier to the task by appending and prepending steps and volumes.
func ApplyTaskModifier(ts *TaskSpec, tm TaskModifier) {
steps := tm.GetStepsToPrepend()
ts.Steps = append(steps, ts.Steps...)
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1alpha1/storage_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func NewStorageResource(r *PipelineResource) (PipelineStorageResourceInterface,
return nil, xerrors.Errorf("StoreResource: Cannot create a storage resource without type %s in spec", r.Name)
}

func getStorageVolumeSpec(s PipelineStorageResourceInterface, spec *TaskSpec) ([]corev1.Volume, error) {
func getStorageVolumeSpec(s PipelineStorageResourceInterface, spec TaskSpec) ([]corev1.Volume, error) {
var storageVol []corev1.Volume
mountedSecrets := map[string]string{}

Expand Down