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

Have [Cluster]Task and Pipeline implement kmeta.OwnerRefable. #4295

Merged
merged 1 commit into from
Oct 11, 2021
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
10 changes: 10 additions & 0 deletions pkg/apis/pipeline/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,19 @@ const (
// nolint: revive
PipelineRunControllerName = "PipelineRun"

// PipelineControllerName holds the name of the Pipeline controller
// nolint: revive
PipelineControllerName = "Pipeline"

// TaskRunControllerName holds the name of the TaskRun controller
TaskRunControllerName = "TaskRun"

// TaskControllerName holds the name of the Task controller
TaskControllerName = "Task"

// ClusterTaskControllerName holds the name of the Task controller
ClusterTaskControllerName = "ClusterTask"

// RuncControllerName holds the name of the Custom Task controller
RunControllerName = "Run"
)
10 changes: 10 additions & 0 deletions pkg/apis/pipeline/v1beta1/cluster_task_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ limitations under the License.
package v1beta1

import (
"github.com/tektoncd/pipeline/pkg/apis/pipeline"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"knative.dev/pkg/kmeta"
)

// +genclient
Expand All @@ -38,6 +41,8 @@ type ClusterTask struct {
Spec TaskSpec `json:"spec,omitempty"`
}

var _ kmeta.OwnerRefable = (*ClusterTask)(nil)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ClusterTaskList contains a list of ClusterTask
Expand All @@ -59,3 +64,8 @@ func (t *ClusterTask) TaskMetadata() metav1.ObjectMeta {
func (t *ClusterTask) Copy() TaskObject {
return t.DeepCopy()
}

// GetGroupVersionKind implements kmeta.OwnerRefable.
func (*ClusterTask) GetGroupVersionKind() schema.GroupVersionKind {
return SchemeGroupVersion.WithKind(pipeline.ClusterTaskControllerName)
}
10 changes: 10 additions & 0 deletions pkg/apis/pipeline/v1beta1/pipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ import (

"github.com/google/go-containerregistry/pkg/name"
"github.com/tektoncd/pipeline/pkg/apis/config"
"github.com/tektoncd/pipeline/pkg/apis/pipeline"

"github.com/tektoncd/pipeline/pkg/reconciler/pipeline/dag"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/validation"
"knative.dev/pkg/apis"
"knative.dev/pkg/kmeta"
)

const (
Expand Down Expand Up @@ -58,6 +61,8 @@ type Pipeline struct {
Spec PipelineSpec `json:"spec"`
}

var _ kmeta.OwnerRefable = (*Pipeline)(nil)

func (p *Pipeline) PipelineMetadata() metav1.ObjectMeta {
return p.ObjectMeta
}
Expand All @@ -70,6 +75,11 @@ func (p *Pipeline) Copy() PipelineObject {
return p.DeepCopy()
}

// GetGroupVersionKind implements kmeta.OwnerRefable.
func (*Pipeline) GetGroupVersionKind() schema.GroupVersionKind {
return SchemeGroupVersion.WithKind(pipeline.PipelineControllerName)
}

// PipelineSpec defines the desired state of Pipeline.
type PipelineSpec struct {
// Description is a user-facing description of the pipeline that may be
Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/pipeline/v1beta1/task_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ limitations under the License.
package v1beta1

import (
"github.com/tektoncd/pipeline/pkg/apis/pipeline"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"knative.dev/pkg/kmeta"
)

const (
Expand Down Expand Up @@ -52,6 +55,8 @@ type Task struct {
Spec TaskSpec `json:"spec"`
}

var _ kmeta.OwnerRefable = (*Task)(nil)

func (t *Task) TaskSpec() TaskSpec {
return t.Spec
}
Expand All @@ -64,6 +69,11 @@ func (t *Task) Copy() TaskObject {
return t.DeepCopy()
}

// GetGroupVersionKind implements kmeta.OwnerRefable.
func (*Task) GetGroupVersionKind() schema.GroupVersionKind {
return SchemeGroupVersion.WithKind(pipeline.TaskControllerName)
}

// TaskSpec defines the desired state of Task.
type TaskSpec struct {
// Resources is a list input and output resource to run the task
Expand Down