Skip to content

Commit

Permalink
Add ClusterTask to v1alpha2 🎋
Browse files Browse the repository at this point in the history
This port ClusterTask spec to v1alpha2, using v1alpha2.TaskSpec too.

Signed-off-by: Vincent Demeester <[email protected]>
  • Loading branch information
vdemeester authored and tekton-robot committed Jan 27, 2020
1 parent 0e504eb commit 3d6f1d3
Show file tree
Hide file tree
Showing 17 changed files with 738 additions and 2 deletions.
29 changes: 29 additions & 0 deletions pkg/apis/pipeline/v1alpha2/cluster_task_defaults.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Copyright 2020 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha2

import (
"context"

"knative.dev/pkg/apis"
)

var _ apis.Defaultable = (*ClusterTask)(nil)

func (t *ClusterTask) SetDefaults(ctx context.Context) {
t.Spec.SetDefaults(ctx)
}
61 changes: 61 additions & 0 deletions pkg/apis/pipeline/v1alpha2/cluster_task_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
Copyright 2020 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha2

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

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

// ClusterTask is a Task with a cluster scope. ClusterTasks are used to
// represent Tasks that should be publicly addressable from any namespace in the
// cluster.
type ClusterTask struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

// Spec holds the desired state of the Task from the client
// +optional
Spec TaskSpec `json:"spec,omitempty"`
}

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

// ClusterTaskList contains a list of ClusterTask
type ClusterTaskList struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
Items []ClusterTask `json:"items"`
}

func (t *ClusterTask) TaskSpec() TaskSpec {
return t.Spec
}

func (t *ClusterTask) TaskMetadata() metav1.ObjectMeta {
return t.ObjectMeta
}

func (t *ClusterTask) Copy() TaskInterface {
return t.DeepCopy()
}
33 changes: 33 additions & 0 deletions pkg/apis/pipeline/v1alpha2/cluster_task_validation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright 2020 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha2

import (
"context"

"github.com/tektoncd/pipeline/pkg/apis/validate"
"knative.dev/pkg/apis"
)

var _ apis.Validatable = (*ClusterTask)(nil)

func (t *ClusterTask) Validate(ctx context.Context) *apis.FieldError {
if err := validate.ObjectMetadata(t.GetObjectMeta()); err != nil {
return err.ViaField("metadata")
}
return t.Spec.Validate(ctx)
}
4 changes: 2 additions & 2 deletions pkg/apis/pipeline/v1alpha2/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&TaskList{},
&Pipeline{},
&PipelineList{},
&ClusterTask{},
&ClusterTaskList{},
&TaskRun{},
&TaskRunList{},
)
// &Condition{},
// &ConditionList{},
// &ClusterTask{},
// &ClusterTaskList{},
// &PipelineRun{},
// &PipelineRunList{},

Expand Down
60 changes: 60 additions & 0 deletions pkg/apis/pipeline/v1alpha2/zz_generated.deepcopy.go

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

164 changes: 164 additions & 0 deletions pkg/client/clientset/versioned/typed/pipeline/v1alpha2/clustertask.go

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

Loading

0 comments on commit 3d6f1d3

Please sign in to comment.