/
types_workflow.go
97 lines (80 loc) · 3.79 KB
/
types_workflow.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package v1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +genclient
// +genclient:noStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:openapi-gen=true
// Workflow represents pipeline activity for a particular run of a pipeline
type Workflow struct {
metav1.TypeMeta `json:",inline"`
// Standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
// +optional
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
Spec WorkflowSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
Status WorkflowStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
}
// WorkflowSpec is the specification of the pipeline activity
type WorkflowSpec struct {
PipelineName string `json:"pipeline,omitempty" protobuf:"bytes,1,opt,name=pipeline"`
Steps []WorkflowStep `json:"steps,omitempty" protobuf:"bytes,7,opt,name=steps"`
}
// WorkflowStep represents a step in a pipeline activity
type WorkflowStep struct {
Kind WorkflowStepKindType `json:"kind,omitempty" protobuf:"bytes,1,opt,name=kind"`
Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"`
Description string `json:"description,omitempty" protobuf:"bytes,2,opt,name=description"`
Preconditions WorkflowPreconditions `json:"trigger,omitempty" protobuf:"bytes,3,opt,name=trigger"`
Promote *PromoteWorkflowStep `json:"promote,omitempty" protobuf:"bytes,4,opt,name=promote"`
}
// PromoteWorkflowStep is the step of promoting a version of an application to an environment
type PromoteWorkflowStep struct {
Environment string `json:"environment,omitempty" protobuf:"bytes,1,opt,name=environment"`
}
// WorkflowPreconditions is the trigger to start a step
type WorkflowPreconditions struct {
// the names of the environments which need to have promoted before this step can be triggered
Environments []string `json:"environments,omitempty" protobuf:"bytes,1,opt,name=environments"`
}
// WorkflowStatus is the status for an Environment resource
type WorkflowStatus struct {
Version string `json:"version,omitempty" protobuf:"bytes,1,opt,name=version"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// WorkflowList is a list of Workflow resources
type WorkflowList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []Workflow `json:"items"`
}
// WorkflowStepKindType is a kind of step
type WorkflowStepKindType string
const (
// WorkflowStepKindTypeNone no kind yet
WorkflowStepKindTypeNone WorkflowStepKindType = ""
// WorkflowStepKindTypePromote a promote activity
WorkflowStepKindTypePromote WorkflowStepKindType = "Promote"
)
// WorkflowStatusType is the status of an activity; usually succeeded or failed/error on completion
type WorkflowStatusType string
const (
// WorkflowStatusTypeNone an activity step has not started yet
WorkflowStatusTypeNone WorkflowStatusType = ""
// WorkflowStatusTypePending an activity step is waiting to start
WorkflowStatusTypePending WorkflowStatusType = "Pending"
// WorkflowStatusTypeRunning an activity is running
WorkflowStatusTypeRunning WorkflowStatusType = "Running"
// WorkflowStatusTypeSucceeded an activity completed successfully
WorkflowStatusTypeSucceeded WorkflowStatusType = "Succeeded"
// WorkflowStatusTypeFailed an activity failed
WorkflowStatusTypeFailed WorkflowStatusType = "Failed"
// WorkflowStatusTypeWaitingForApproval an activity is waiting for approval
WorkflowStatusTypeWaitingForApproval WorkflowStatusType = "WaitingForApproval"
// WorkflowStatusTypeError there is some error with an activity
WorkflowStatusTypeError WorkflowStatusType = "Error"
)
func (s WorkflowStatusType) String() string {
return string(s)
}