-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcommitrequest_types.go
More file actions
130 lines (112 loc) · 5.82 KB
/
Copy pathcommitrequest_types.go
File metadata and controls
130 lines (112 loc) · 5.82 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// SPDX-License-Identifier: Apache-2.0
package v1alpha3
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// CommitRequestSpec defines the desired state of CommitRequest. The spec is
// immutable after creation: a CEL validation rule rejects any update that
// changes it, so a delayed audit event always acts on the spec the object was
// created with.
//
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="CommitRequest spec is immutable after creation"
type CommitRequestSpec struct {
// TargetRef names the GitTarget whose open commit window to finalize.
// The GitTarget must be in the same namespace as this CommitRequest.
// +required
TargetRef LocalTargetReference `json:"targetRef"`
// Message is an optional commit message for the finalized commit. When
// omitted, the generated grouped-commit message is used.
//
// When present it is limited to 1-1024 Unicode characters and used
// verbatim as the commit message. Newlines are allowed so a subject and
// body can be supplied; all other ASCII control characters (including tab
// and carriage return) are rejected.
// +optional
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=1024
// +kubebuilder:validation:Pattern=`^[^\x00-\x09\x0B-\x1F\x7F]*$`
Message string `json:"message,omitempty"`
// CloseDelaySeconds optionally delays closing the open commit window for this
// many seconds after the CommitRequest attaches to a matching open window, acting as
// an extra collect window: matching changes that arrive in the meantime still join
// that window and are included in the resulting commit. Omitted or 0 closes the
// window as soon as the CommitRequest attaches. The window can still be closed
// earlier by another author's change or by the provider's commit window timer,
// exactly as without a CommitRequest.
// +optional
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Maximum=300
CloseDelaySeconds int32 `json:"closeDelaySeconds,omitempty"`
}
// CommitRequestStatus defines the observed state of CommitRequest. Progress and
// outcome are reported entirely through conditions (kstatus-compatible), so the
// object carries no lifecycle phase string:
//
// - Ready (summary): True once the request reached a terminal outcome that is not
// an error — a pushed commit, or a benign no-commit (nothing to save, already
// present, or a foreign open window). False while in progress or when it failed.
// - Reconciling / Stalled: the kstatus progress / blocked pair. Reconciling=True
// while finalizing; Stalled=True when the finalize failed and needs attention.
// - AuthorAttributed (domain): binary and settled immediately. True
// (AttributedFromAdmission) when the submitter captured at admission named the
// commit author; False (CommitterFallback) when capture ran but no admission record
// exists, or False (AuthorCaptureDisabled) when capture is disabled. In either False
// case the request claims no actor. False is not a failure and does not affect Ready;
// the final Git author remains the matching watch window's author.
// - Pushed (domain): True once the commit is in the remote repository.
type CommitRequestStatus struct {
// ObservedGeneration is the most recent generation observed by the controller.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
// Conditions report the request's progress and terminal outcome: the Ready
// summary, the kstatus Reconciling/Stalled pair, and the domain conditions
// AuthorAttributed and Pushed.
// +optional
// +listType=map
// +listMapKey=type
// +patchStrategy=merge
// +patchMergeKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
// Branch is the Git branch the GitTarget commits to. Populated once the
// finalize resolves.
// +optional
Branch string `json:"branch,omitempty"`
// SHA is the resulting commit SHA. Set when the commit was pushed (Pushed=True).
// +optional
SHA string `json:"sha,omitempty"`
}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="GitTarget",type=string,JSONPath=`.spec.targetRef.name`
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
// +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].reason`
// +kubebuilder:printcolumn:name="SHA",type=string,JSONPath=`.status.sha`
// +kubebuilder:printcolumn:name="AuthorAttributed",type=string,JSONPath=`.status.conditions[?(@.type=="AuthorAttributed")].status`,priority=1
// +kubebuilder:printcolumn:name="Pushed",type=string,JSONPath=`.status.conditions[?(@.type=="Pushed")].status`,priority=1
// +kubebuilder:printcolumn:name="Branch",type=string,JSONPath=`.status.branch`,priority=1
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
// CommitRequest is a one-shot "save" signal: creating one finalizes the open
// commit window for the referenced GitTarget instead of waiting for the
// silence timer. The resulting commit SHA is reported back in status.
type CommitRequest struct {
metav1.TypeMeta `json:",inline"`
// metadata is a standard object metadata
// +optional
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
// spec defines the desired state of CommitRequest
// +required
Spec CommitRequestSpec `json:"spec"`
// status defines the observed state of CommitRequest
// +optional
Status CommitRequestStatus `json:"status,omitempty,omitzero"`
}
// +kubebuilder:object:root=true
// CommitRequestList contains a list of CommitRequest.
type CommitRequestList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []CommitRequest `json:"items"`
}
func init() {
SchemeBuilder.Register(&CommitRequest{}, &CommitRequestList{})
}