Skip to content

Commit

Permalink
Add APIs for conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
dibyom committed Jul 1, 2019
1 parent af090f0 commit 6c7accb
Show file tree
Hide file tree
Showing 20 changed files with 1,394 additions and 836 deletions.
31 changes: 31 additions & 0 deletions config/500-condition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2018 The Knative 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
#
# https://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.
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: conditions.tekton.dev
spec:
group: tekton.dev
names:
kind: Condition
plural: conditions
categories:
- all
- tekton-pipelines
scope: Namespaced
# Opt into the status subresource so metadata.generation
# starts to increment
subresources:
status: {}
version: v1alpha1
44 changes: 44 additions & 0 deletions config/500-conditionrun.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2018 The Knative 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
#
# https://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.
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: conditionruns.tekton.dev
spec:
group: tekton.dev
names:
kind: ConditionRun
plural: conditionruns
categories:
- all
- tekton-pipelines
scope: Namespaced
additionalPrinterColumns:
- name: Succeeded
type: string
JSONPath: ".status.conditions[?(@.type==\"Succeeded\")].status"
- name: Reason
type: string
JSONPath: ".status.conditions[?(@.type==\"Succeeded\")].reason"
- name: StartTime
type: date
JSONPath: .status.startTime
- name: CompletionTime
type: date
JSONPath: .status.completionTime
# Opt into the status subresource so metadata.generation
# starts to increment
subresources:
status: {}
version: v1alpha1
62 changes: 58 additions & 4 deletions pkg/apis/pipeline/v1alpha1/condition_types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package v1alpha1

import(
"github.com/knative/pkg/apis"
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand All @@ -11,13 +10,23 @@ type TaskCondition struct {
ConditionRef string `json:"conditionRef"`
// +optional
Params []Param `json:"params,omitempty"`
// +optional
// chain using AND and OR
ConditionCheckType string `json:"conditionChainType,omitempty"`
// +optional
RunDependentOnFailure bool `json:"runDependentOnFailure,omitempty"`
}

// Check that Task may be validated and defaulted.
var _ apis.Validatable = (*Task)(nil)
var _ apis.Defaultable = (*Task)(nil)
// TODO(dibyom): Validate and default conditions
// var _ apis.Validatable = (*Condition)(nil)
// var _ apis.Defaultable = (*Condition)(nil)


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

// Task represents a collection of sequential steps that are run as part of a
// Pipeline using a set of inputs and producing a set of outputs. Tasks execute
// when TaskRuns are created that provide the input parameters and resources and
Expand Down Expand Up @@ -48,3 +57,48 @@ type ConditionState struct {
Name string `json:"name,omitempty"`
}


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

// TaskRun represents a single execution of a Task. TaskRuns are how the steps
// specified in a Task are executed; they specify the parameters and resources
// used to run the steps in a Task.
//
// +k8s:openapi-gen=true
type ConditionRun struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata"`

// +optional
Spec ConditionRunSpec `json:"spec"`

Status TaskRunStatus `json:"status,omitempty"`
}

type ConditionRunSpec struct {
ConditionRef string `json:"conditionRef"`
// +optional
Params []Param `json:"params,omitempty"`
}

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

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

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

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

0 comments on commit 6c7accb

Please sign in to comment.