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

Add a PipelineResourceBase struct that implements some stub versions … #1188

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 1 addition & 9 deletions pkg/apis/pipeline/v1alpha1/cloud_event_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ package v1alpha1
import (
"fmt"
"strings"

corev1 "k8s.io/api/core/v1"
)

// CloudEventResource is an event sink to which events are delivered when a TaskRun has finished
Expand All @@ -31,6 +29,7 @@ type CloudEventResource struct {
Type PipelineResourceType `json:"type"`
// TargetURI is the URI of the sink which the cloud event is develired to
TargetURI string `json:"targetURI"`
PipelineResourceBase
}

// NewCloudEventResource creates a new CloudEvent resource to pass to a Task
Expand Down Expand Up @@ -79,10 +78,3 @@ func (s *CloudEventResource) Replacements() map[string]string {
"target-uri": s.TargetURI,
}
}

func (s *CloudEventResource) GetUploadSteps(string) ([]Step, error) { return nil, nil }
func (s *CloudEventResource) GetDownloadSteps(string) ([]Step, error) { return nil, nil }
func (s *CloudEventResource) GetUploadVolumeSpec(*TaskSpec) ([]corev1.Volume, error) { return nil, nil }
func (s *CloudEventResource) GetDownloadVolumeSpec(*TaskSpec) ([]corev1.Volume, error) {
return nil, nil
}
4 changes: 1 addition & 3 deletions pkg/apis/pipeline/v1alpha1/cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type ClusterResource struct {
CAData []byte `json:"cadata"`
//Secrets holds a struct to indicate a field name and corresponding secret name to populate it
Secrets []SecretParam `json:"secrets"`
PipelineResourceBase
}

// NewClusterResource create a new k8s cluster resource to pass to a pipeline task
Expand Down Expand Up @@ -166,6 +167,3 @@ func (s *ClusterResource) GetDownloadSteps(sourcePath string) ([]Step, error) {
Env: envVars,
}}}, nil
}

func (s *ClusterResource) GetUploadVolumeSpec(*TaskSpec) ([]corev1.Volume, error) { return nil, nil }
func (s *ClusterResource) GetDownloadVolumeSpec(*TaskSpec) ([]corev1.Volume, error) { return nil, nil }
5 changes: 1 addition & 4 deletions pkg/apis/pipeline/v1alpha1/git_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type GitResource struct {
// https://git-scm.com/docs/gitrevisions#_specifying_revisions for more
// information.
Revision string `json:"revision"`
PipelineResourceBase
}

// NewGitResource creates a new git resource to pass to a Task
Expand Down Expand Up @@ -110,7 +111,3 @@ func (s *GitResource) GetDownloadSteps(sourcePath string) ([]Step, error) {
WorkingDir: WorkspaceDir,
}}}, nil
}

func (s *GitResource) GetUploadSteps(sourcePath string) ([]Step, error) { return nil, nil }
func (s *GitResource) GetUploadVolumeSpec(spec *TaskSpec) ([]corev1.Volume, error) { return nil, nil }
func (s *GitResource) GetDownloadVolumeSpec(spec *TaskSpec) ([]corev1.Volume, error) { return nil, nil }
7 changes: 1 addition & 6 deletions pkg/apis/pipeline/v1alpha1/image_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"strings"

"golang.org/x/xerrors"
corev1 "k8s.io/api/core/v1"
)

// NewImageResource creates a new ImageResource from a PipelineResource.
Expand Down Expand Up @@ -53,6 +52,7 @@ type ImageResource struct {
URL string `json:"url"`
Digest string `json:"digest"`
OutputImageDir string
PipelineResourceBase
}

// GetName returns the name of the resource
Expand All @@ -75,11 +75,6 @@ func (s *ImageResource) Replacements() map[string]string {
}
}

func (s *ImageResource) GetUploadSteps(string) ([]Step, error) { return nil, nil }
func (s *ImageResource) GetDownloadSteps(string) ([]Step, error) { return nil, nil }
func (s *ImageResource) GetUploadVolumeSpec(*TaskSpec) ([]corev1.Volume, error) { return nil, nil }
func (s *ImageResource) GetDownloadVolumeSpec(*TaskSpec) ([]corev1.Volume, error) { return nil, nil }

// GetOutputImageDir return the path to get the index.json file
func (s *ImageResource) GetOutputImageDir() string {
return s.OutputImageDir
Expand Down
9 changes: 1 addition & 8 deletions pkg/apis/pipeline/v1alpha1/pull_request_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type PullRequestResource struct {
URL string `json:"url"`
// Secrets holds a struct to indicate a field name and corresponding secret name to populate it.
Secrets []SecretParam `json:"secrets"`
PipelineResourceBase
}

// NewPullRequestResource create a new git resource to pass to a Task
Expand Down Expand Up @@ -131,11 +132,3 @@ func (s *PullRequestResource) getSteps(mode string, sourcePath string) ([]Step,
Env: evs,
}}}, nil
}

func (s *PullRequestResource) GetUploadVolumeSpec(spec *TaskSpec) ([]corev1.Volume, error) {
return nil, nil
}

func (s *PullRequestResource) GetDownloadVolumeSpec(spec *TaskSpec) ([]corev1.Volume, error) {
return nil, nil
}
20 changes: 20 additions & 0 deletions pkg/apis/pipeline/v1alpha1/resource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,26 @@ type PipelineResourceInterface interface {
GetDownloadVolumeSpec(spec *TaskSpec) ([]corev1.Volume, error)
}

// PipelineResourceBase is a struct that can be used to simplify implementations.
type PipelineResourceBase struct {
}

func (p *PipelineResourceBase) GetDownloadSteps(sourcePath string) ([]Step, error) {
return nil, nil
}

func (p *PipelineResourceBase) GetUploadSteps(sourcePath string) ([]Step, error) {
return nil, nil
}

func (p *PipelineResourceBase) GetUploadVolumeSpec(spec *TaskSpec) ([]corev1.Volume, error) {
return nil, nil
}

func (p *PipelineResourceBase) GetDownloadVolumeSpec(spec *TaskSpec) ([]corev1.Volume, error) {
return nil, nil
}

// SecretParam indicates which secret can be used to populate a field of the resource
type SecretParam struct {
FieldName string `json:"fieldName"`
Expand Down