Skip to content

Commit

Permalink
Add PipelineRun types to v1alpha2 🎋
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Demeester <[email protected]>
  • Loading branch information
vdemeester committed Feb 3, 2020
1 parent aee09da commit 1491916
Show file tree
Hide file tree
Showing 24 changed files with 2,249 additions and 213 deletions.
29 changes: 4 additions & 25 deletions pkg/apis/pipeline/v1alpha1/condition_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019 The Tekton Authors
Copyright 2019-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.
Expand All @@ -17,10 +17,9 @@ limitations under the License.
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"knative.dev/pkg/apis"
duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1"
)

// +genclient
Expand All @@ -41,32 +40,12 @@ type Condition struct {
}

// ConditionCheckStatus defines the observed state of ConditionCheck
type ConditionCheckStatus struct {
duckv1beta1.Status `json:",inline"`

// ConditionCheckStatusFields inlines the status fields.
ConditionCheckStatusFields `json:",inline"`
}
type ConditionCheckStatus = v1alpha2.ConditionCheckStatus

// ConditionCheckStatusFields holds the fields of ConfigurationCheck's status.
// This is defined separately and inlined so that other types can readily
// consume these fields via duck typing.
type ConditionCheckStatusFields struct {
// PodName is the name of the pod responsible for executing this condition check.
PodName string `json:"podName"`

// StartTime is the time the check is actually started.
// +optional
StartTime *metav1.Time `json:"startTime,omitempty"`

// CompletionTime is the time the check pod completed.
// +optional
CompletionTime *metav1.Time `json:"completionTime,omitempty"`

// Check describes the state of the check container.
// +optional
Check corev1.ContainerState `json:"check,omitempty"`
}
type ConditionCheckStatusFields = v1alpha2.ConditionCheckStatusFields

// ConditionSpec defines the desired state of the Condition
type ConditionSpec struct {
Expand Down
122 changes: 53 additions & 69 deletions pkg/apis/pipeline/v1alpha1/pipelinerun_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019 The Tekton Authors
Copyright 2019-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.
Expand All @@ -22,6 +22,7 @@ import (

"github.com/tektoncd/pipeline/pkg/apis/config"
"github.com/tektoncd/pipeline/pkg/apis/pipeline"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha2"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand All @@ -37,6 +38,27 @@ var (
}
)

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

// PipelineRun represents a single execution of a Pipeline. PipelineRuns are how
// the graph of Tasks declared in a Pipeline are executed; they specify inputs
// to Pipelines such as parameter values and capture operational aspects of the
// Tasks execution such as service account and tolerations. Creating a
// PipelineRun creates TaskRuns for Tasks in the referenced Pipeline.
//
// +k8s:openapi-gen=true
type PipelineRun struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

// +optional
Spec PipelineRunSpec `json:"spec,omitempty"`
// +optional
Status PipelineRunStatus `json:"status,omitempty"`
}

// PipelineRunSpec defines the desired state of PipelineRun
type PipelineRunSpec struct {
// +optional
Expand Down Expand Up @@ -88,13 +110,7 @@ type PipelineResourceRef struct {

// PipelineRef can be used to refer to a specific instance of a Pipeline.
// Copied from CrossVersionObjectReference: https:/kubernetes/kubernetes/blob/169df7434155cbbc22f1532cba8e0a9588e29ad8/pkg/apis/autoscaling/types.go#L64
type PipelineRef struct {
// Name of the referent; More info: http://kubernetes.io/docs/user-guide/identifiers#names
Name string `json:"name,omitempty"`
// API version of the referent
// +optional
APIVersion string `json:"apiVersion,omitempty"`
}
type PipelineRef = v1alpha2.PipelineRef

// PipelineRunStatus defines the observed state of PipelineRun
type PipelineRunStatus struct {
Expand All @@ -104,43 +120,6 @@ type PipelineRunStatus struct {
PipelineRunStatusFields `json:",inline"`
}

// PipelineRunStatusFields holds the fields of PipelineRunStatus' status.
// This is defined separately and inlined so that other types can readily
// consume these fields via duck typing.
type PipelineRunStatusFields struct {
// StartTime is the time the PipelineRun is actually started.
// +optional
StartTime *metav1.Time `json:"startTime,omitempty"`

// CompletionTime is the time the PipelineRun completed.
// +optional
CompletionTime *metav1.Time `json:"completionTime,omitempty"`

// map of PipelineRunTaskRunStatus with the taskRun name as the key
// +optional
TaskRuns map[string]*PipelineRunTaskRunStatus `json:"taskRuns,omitempty"`
}

// PipelineRunTaskRunStatus contains the name of the PipelineTask for this TaskRun and the TaskRun's Status
type PipelineRunTaskRunStatus struct {
// PipelineTaskName is the name of the PipelineTask.
PipelineTaskName string `json:"pipelineTaskName,omitempty"`
// Status is the TaskRunStatus for the corresponding TaskRun
// +optional
Status *TaskRunStatus `json:"status,omitempty"`
// ConditionChecks maps the name of a condition check to its Status
// +optional
ConditionChecks map[string]*PipelineRunConditionCheckStatus `json:"conditionChecks,omitempty"`
}

type PipelineRunConditionCheckStatus struct {
// ConditionName is the name of the Condition
ConditionName string `json:"conditionName,omitempty"`
// Status is the ConditionCheckStatus for the corresponding ConditionCheck
// +optional
Status *ConditionCheckStatus `json:"status,omitempty"`
}

var pipelineRunCondSet = apis.NewBatchConditionSet()

// GetCondition returns the Condition matching the given type.
Expand All @@ -160,13 +139,6 @@ func (pr *PipelineRunStatus) InitializeConditions() {
pipelineRunCondSet.Manage(pr).InitializeConditions()
}

// PipelineRunSpecServiceAccountName can be used to configure specific
// ServiceAccountName for a concrete Task
type PipelineRunSpecServiceAccountName struct {
TaskName string `json:"taskName,omitempty"`
ServiceAccountName string `json:"serviceAccountName,omitempty"`
}

// SetCondition sets the condition, unsetting previous conditions with the same
// type as necessary.
func (pr *PipelineRunStatus) SetCondition(newCond *apis.Condition) {
Expand All @@ -175,27 +147,41 @@ func (pr *PipelineRunStatus) SetCondition(newCond *apis.Condition) {
}
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// PipelineRunStatusFields holds the fields of PipelineRunStatus' status.
// This is defined separately and inlined so that other types can readily
// consume these fields via duck typing.
type PipelineRunStatusFields struct {
// StartTime is the time the PipelineRun is actually started.
// +optional
StartTime *metav1.Time `json:"startTime,omitempty"`

// PipelineRun represents a single execution of a Pipeline. PipelineRuns are how
// the graph of Tasks declared in a Pipeline are executed; they specify inputs
// to Pipelines such as parameter values and capture operational aspects of the
// Tasks execution such as service account and tolerations. Creating a
// PipelineRun creates TaskRuns for Tasks in the referenced Pipeline.
//
// +k8s:openapi-gen=true
type PipelineRun struct {
metav1.TypeMeta `json:",inline"`
// CompletionTime is the time the PipelineRun completed.
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
CompletionTime *metav1.Time `json:"completionTime,omitempty"`

// map of PipelineRunTaskRunStatus with the taskRun name as the key
// +optional
Spec PipelineRunSpec `json:"spec,omitempty"`
TaskRuns map[string]*PipelineRunTaskRunStatus `json:"taskRuns,omitempty"`
}

// PipelineRunTaskRunStatus contains the name of the PipelineTask for this TaskRun and the TaskRun's Status
type PipelineRunTaskRunStatus struct {
// PipelineTaskName is the name of the PipelineTask.
PipelineTaskName string `json:"pipelineTaskName,omitempty"`
// Status is the TaskRunStatus for the corresponding TaskRun
// +optional
Status PipelineRunStatus `json:"status,omitempty"`
Status *TaskRunStatus `json:"status,omitempty"`
// ConditionChecks maps the name of a condition check to its Status
// +optional
ConditionChecks map[string]*PipelineRunConditionCheckStatus `json:"conditionChecks,omitempty"`
}

type PipelineRunConditionCheckStatus = v1alpha2.PipelineRunConditionCheckStatus

// PipelineRunSpecServiceAccountName can be used to configure specific
// ServiceAccountName for a concrete Task
type PipelineRunSpecServiceAccountName = v1alpha2.PipelineRunSpecServiceAccountName

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

// PipelineRunList contains a list of PipelineRun
Expand All @@ -209,9 +195,7 @@ type PipelineRunList struct {
// PipelineTaskRun reports the results of running a step in the Task. Each
// task has the potential to succeed or fail (based on the exit code)
// and produces logs.
type PipelineTaskRun struct {
Name string `json:"name,omitempty"`
}
type PipelineTaskRun = v1alpha2.PipelineTaskRun

// GetTaskRunRef for pipelinerun
func (pr *PipelineRun) GetTaskRunRef() corev1.ObjectReference {
Expand Down
Loading

0 comments on commit 1491916

Please sign in to comment.