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 Condition type to webhook and SchemeBuilder #1130

Merged
merged 1 commit into from
Jul 26, 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
1 change: 1 addition & 0 deletions cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func main() {
v1alpha1.SchemeGroupVersion.WithKind("ClusterTask"): &v1alpha1.ClusterTask{},
v1alpha1.SchemeGroupVersion.WithKind("TaskRun"): &v1alpha1.TaskRun{},
v1alpha1.SchemeGroupVersion.WithKind("PipelineRun"): &v1alpha1.PipelineRun{},
v1alpha1.SchemeGroupVersion.WithKind("Condition"): &v1alpha1.Condition{},
},
Logger: logger,
DisallowUnknownFields: true,
Expand Down
26 changes: 26 additions & 0 deletions pkg/apis/pipeline/v1alpha1/condition_defaults.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Copyright 2019 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 v1alpha1

import "context"

func (c *Condition) SetDefaults(ctx context.Context) {
c.Spec.SetDefaults(ctx)
}

func (cs *ConditionSpec) SetDefaults(ctx context.Context) {
}
1 change: 1 addition & 0 deletions pkg/apis/pipeline/v1alpha1/condition_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

// Check that Task may be validated and defaulted.
var _ apis.Validatable = (*Condition)(nil)
var _ apis.Defaultable = (*Condition)(nil)

// +genclient
// +genclient:noStatus
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/pipeline/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&Task{},
&TaskList{},
&Condition{},
&ConditionList{},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoa i never would have known to do this!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found out the hard way while writing an e2e test 😅

&ClusterTask{},
&ClusterTaskList{},
&TaskRun{},
Expand Down
4 changes: 2 additions & 2 deletions test/builder/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import (
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
)

// ConditionOp is an operation which modifies a StatusCondition struct.
// ConditionOp is an operation which modifies a Condition struct.
type ConditionOp func(*v1alpha1.Condition)

// ConditionSpecOp is an operation which modifies a ConditionSpec struct.
type ConditionSpecOp func(spec *v1alpha1.ConditionSpec)

// TaskParamOp is an operation which modify a ParamSpec struct.
// ConditionParamOp is an operation which modify a ParamSpec struct.
type ConditionParamOp func(*v1alpha1.ParamSpec)

// Condition creates a Condition with default values.
Expand Down