@@ -29,165 +29,198 @@ const (
29
29
// GitRepositoryKind is the string representation of a GitRepository.
30
30
GitRepositoryKind = "GitRepository"
31
31
32
- // GoGitImplementation represents the go-git Git implementation kind .
32
+ // GoGitImplementation for performing Git operations using go-git .
33
33
GoGitImplementation = "go-git"
34
- // LibGit2Implementation represents the git2go Git implementation kind .
34
+ // LibGit2Implementation for performing Git operations using libgit2 .
35
35
LibGit2Implementation = "libgit2"
36
36
)
37
37
38
38
const (
39
- // IncludeUnavailableCondition indicates one of the includes is not available. For example, because it does not
40
- // exist, or does not have an Artifact.
41
- // This is a "negative polarity" or "abnormal-true" type, and is only present on the resource if it is True.
39
+ // IncludeUnavailableCondition indicates one of the includes is not
40
+ // available. For example, because it does not exist, or does not have an
41
+ // Artifact.
42
+ // This is a "negative polarity" or "abnormal-true" type, and is only
43
+ // present on the resource if it is True.
42
44
IncludeUnavailableCondition string = "IncludeUnavailable"
43
45
)
44
46
45
- // GitRepositorySpec defines the desired state of a Git repository.
47
+ // GitRepositorySpec specifies the required configuration to produce an
48
+ // Artifact for a Git repository.
46
49
type GitRepositorySpec struct {
47
- // The repository URL, can be a HTTP/S or SSH address.
50
+ // URL specifies the Git repository URL, it can be an HTTP/S or SSH address.
48
51
// +kubebuilder:validation:Pattern="^(http|https|ssh)://"
49
52
// +required
50
53
URL string `json:"url"`
51
54
52
- // The secret name containing the Git credentials.
53
- // For HTTPS repositories the secret must contain username and password fields.
54
- // For SSH repositories the secret must contain 'identity', 'identity.pub' and 'known_hosts' fields.
55
+ // SecretRef specifies the Secret containing authentication credentials for
56
+ // the GitRepository.
57
+ // For HTTPS repositories the Secret must contain 'username' and 'password'
58
+ // fields.
59
+ // For SSH repositories the Secret must contain 'identity', 'identity.pub'
60
+ // and 'known_hosts' fields.
55
61
// +optional
56
62
SecretRef * meta.LocalObjectReference `json:"secretRef,omitempty"`
57
63
58
- // The interval at which to check for repository updates.
64
+ // Interval at which to check the GitRepository for updates.
59
65
// +required
60
66
Interval metav1.Duration `json:"interval"`
61
67
62
- // The timeout for remote Git operations like cloning, defaults to 60s.
68
+ // Timeout for Git operations like cloning, defaults to 60s.
63
69
// +kubebuilder:default="60s"
64
70
// +optional
65
71
Timeout * metav1.Duration `json:"timeout,omitempty"`
66
72
67
- // The Git reference to checkout and monitor for changes, defaults to
68
- // master branch.
73
+ // Reference specifies the Git reference to resolve and monitor for
74
+ // changes, defaults to the ' master' branch.
69
75
// +optional
70
76
Reference * GitRepositoryRef `json:"ref,omitempty"`
71
77
72
- // Verification defines the configuration to verify the OpenPGP signature for the Git commit HEAD points to.
78
+ // Verification specifies the configuration to verify the Git commit
79
+ // signature(s).
73
80
// +optional
74
81
Verification * GitRepositoryVerification `json:"verify,omitempty"`
75
82
76
- // Ignore overrides the set of excluded patterns in the .sourceignore format (which is the same as .gitignore).
77
- // If not provided, a default will be used, consult the documentation for your version to find out what those are.
83
+ // Ignore overrides the set of excluded patterns in the .sourceignore format
84
+ // (which is the same as .gitignore). If not provided, a default will be used,
85
+ // consult the documentation for your version to find out what those are.
78
86
// +optional
79
87
Ignore * string `json:"ignore,omitempty"`
80
88
81
- // Suspend tells the controller to suspend the reconciliation of this source.
82
- // This flag tells the controller to suspend the reconciliation of this source .
89
+ // Suspend tells the controller to suspend the reconciliation of this
90
+ // GitRepository .
83
91
// +optional
84
92
Suspend bool `json:"suspend,omitempty"`
85
93
86
- // Determines which git client library to use.
87
- // Defaults to go-git, valid values are ('go-git', 'libgit2').
94
+ // GitImplementation specifies which Git client library implementation to
95
+ // use. Defaults to ' go-git' , valid values are ('go-git', 'libgit2').
88
96
// +kubebuilder:validation:Enum=go-git;libgit2
89
97
// +kubebuilder:default:=go-git
90
98
// +optional
91
99
GitImplementation string `json:"gitImplementation,omitempty"`
92
100
93
- // When enabled, after the clone is created, initializes all submodules within, using their default settings.
101
+ // RecurseSubmodules enables the initialization of all submodules within
102
+ // the GitRepository as cloned from the URL, using their default settings.
94
103
// This option is available only when using the 'go-git' GitImplementation.
95
104
// +optional
96
105
RecurseSubmodules bool `json:"recurseSubmodules,omitempty"`
97
106
98
- // Include defines a list of GitRepository resources which artifacts should be included in the artifact produced for
99
- // this resource .
107
+ // Include specifies a list of GitRepository resources which Artifacts
108
+ // should be included in the Artifact produced for this GitRepository .
100
109
Include []GitRepositoryInclude `json:"include,omitempty"`
101
110
102
- // AccessFrom defines an Access Control List for allowing cross-namespace references to this object.
111
+ // AccessFrom specifies an Access Control List for allowing cross-namespace
112
+ // references to this object.
113
+ // NOTE: Not implemented, provisional as of https://github.com/fluxcd/flux2/pull/2092
103
114
// +optional
104
115
AccessFrom * acl.AccessFrom `json:"accessFrom,omitempty"`
105
116
}
106
117
118
+ // GitRepositoryInclude specifies a local reference to a GitRepository which
119
+ // Artifact (sub-)contents must be included, and where they should be placed.
120
+ type GitRepositoryInclude struct {
121
+ // GitRepositoryRef specifies the GitRepository which Artifact contents
122
+ // must be included.
123
+ GitRepositoryRef meta.LocalObjectReference `json:"repository"`
124
+
125
+ // FromPath specifies the path to copy contents from, defaults to the root
126
+ // of the Artifact.
127
+ // +optional
128
+ FromPath string `json:"fromPath"`
129
+
130
+ // ToPath specifies the path to copy contents to, defaults to the name of
131
+ // the GitRepositoryRef.
132
+ // +optional
133
+ ToPath string `json:"toPath"`
134
+ }
135
+
136
+ // GetFromPath returns the specified FromPath.
107
137
func (in * GitRepositoryInclude ) GetFromPath () string {
108
138
return in .FromPath
109
139
}
110
140
141
+ // GetToPath returns the specified ToPath, falling back to the name of the
142
+ // GitRepositoryRef.
111
143
func (in * GitRepositoryInclude ) GetToPath () string {
112
144
if in .ToPath == "" {
113
145
return in .GitRepositoryRef .Name
114
146
}
115
147
return in .ToPath
116
148
}
117
149
118
- // GitRepositoryInclude defines a source with a from and to path.
119
- type GitRepositoryInclude struct {
120
- // Reference to a GitRepository to include.
121
- GitRepositoryRef meta.LocalObjectReference `json:"repository"`
122
-
123
- // The path to copy contents from, defaults to the root directory.
124
- // +optional
125
- FromPath string `json:"fromPath"`
126
-
127
- // The path to copy contents to, defaults to the name of the source ref.
128
- // +optional
129
- ToPath string `json:"toPath"`
130
- }
131
-
132
- // GitRepositoryRef defines the Git ref used for pull and checkout operations.
150
+ // GitRepositoryRef specifies the Git reference to resolve and checkout.
133
151
type GitRepositoryRef struct {
134
- // The Git branch to checkout, defaults to master.
152
+ // Branch to check out, defaults to 'master' if no other field is defined.
153
+ //
154
+ // When GitRepositorySpec.GitImplementation is set to 'go-git', a shallow
155
+ // clone of the specified branch is performed.
135
156
// +optional
136
157
Branch string `json:"branch,omitempty"`
137
158
138
- // The Git tag to checkout , takes precedence over Branch.
159
+ // Tag to check out , takes precedence over Branch.
139
160
// +optional
140
161
Tag string `json:"tag,omitempty"`
141
162
142
- // The Git tag semver expression, takes precedence over Tag.
163
+ // SemVer tag expression to check out , takes precedence over Tag.
143
164
// +optional
144
165
SemVer string `json:"semver,omitempty"`
145
166
146
- // The Git commit SHA to checkout, if specified Tag filters will be ignored.
167
+ // Commit SHA to check out, takes precedence over all reference fields.
168
+ //
169
+ // When GitRepositorySpec.GitImplementation is set to 'go-git', this can be
170
+ // combined with Branch to shallow clone the branch, in which the commit is
171
+ // expected to exist.
147
172
// +optional
148
173
Commit string `json:"commit,omitempty"`
149
174
}
150
175
151
- // GitRepositoryVerification defines the OpenPGP signature verification process.
176
+ // GitRepositoryVerification specifies the Git commit signature verification
177
+ // strategy.
152
178
type GitRepositoryVerification struct {
153
- // Mode describes what Git object should be verified, currently ('head').
179
+ // Mode specifies what Git object should be verified, currently ('head').
154
180
// +kubebuilder:validation:Enum=head
155
181
Mode string `json:"mode"`
156
182
157
- // SecretRef containing the public keys of all trusted Git authors.
183
+ // SecretRef specifies the Secret containing the public keys of trusted Git
184
+ // authors.
158
185
SecretRef meta.LocalObjectReference `json:"secretRef,omitempty"`
159
186
}
160
187
161
- // GitRepositoryStatus defines the observed state of a Git repository.
188
+ // GitRepositoryStatus records the observed state of a Git repository.
162
189
type GitRepositoryStatus struct {
163
- // ObservedGeneration is the last observed generation.
190
+ // ObservedGeneration is the last observed generation of the GitRepository
191
+ // object.
164
192
// +optional
165
193
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
166
194
167
195
// Conditions holds the conditions for the GitRepository.
168
196
// +optional
169
197
Conditions []metav1.Condition `json:"conditions,omitempty"`
170
198
171
- // URL is the fetch link for the artifact output of the last repository sync.
199
+ // URL is the dynamic fetch link for the latest Artifact.
200
+ // It is provided on a "best effort" basis, and using the precise
201
+ // GitRepositoryStatus.Artifact data is recommended.
172
202
// +optional
173
203
URL string `json:"url,omitempty"`
174
204
175
- // Artifact represents the output of the last successful repository sync .
205
+ // Artifact represents the last successful GitRepository reconciliation .
176
206
// +optional
177
207
Artifact * Artifact `json:"artifact,omitempty"`
178
208
179
- // IncludedArtifacts represents the included artifacts from the last successful repository sync.
209
+ // IncludedArtifacts contains a list of the last successfully included
210
+ // Artifacts as instructed by GitRepositorySpec.Include.
180
211
// +optional
181
212
IncludedArtifacts []* Artifact `json:"includedArtifacts,omitempty"`
182
213
183
214
meta.ReconcileRequestStatus `json:",inline"`
184
215
}
185
216
186
217
const (
187
- // GitOperationSucceedReason represents the fact that the git clone, pull and checkout operations succeeded.
188
- GitOperationSucceedReason string = "GitOperationSucceed"
218
+ // GitOperationSucceedReason signals that a Git operation (e.g. clone,
219
+ // checkout, etc.) succeeded.
220
+ GitOperationSucceedReason string = "GitOperationSucceeded"
189
221
190
- // GitOperationFailedReason represents the fact that the git clone, pull or checkout operations failed.
222
+ // GitOperationFailedReason signals that a Git operation (e.g. clone,
223
+ // checkout, etc.) failed.
191
224
GitOperationFailedReason string = "GitOperationFailed"
192
225
)
193
226
@@ -201,28 +234,18 @@ func (in *GitRepository) SetConditions(conditions []metav1.Condition) {
201
234
in .Status .Conditions = conditions
202
235
}
203
236
204
- // GetRequeueAfter returns the duration after which the source must be reconciled again.
237
+ // GetRequeueAfter returns the duration after which the GitRepository must be
238
+ // reconciled again.
205
239
func (in GitRepository ) GetRequeueAfter () time.Duration {
206
240
return in .Spec .Interval .Duration
207
241
}
208
242
209
- // GetInterval returns the interval at which the source is reconciled.
210
- // Deprecated: use GetRequeueAfter instead.
211
- func (in GitRepository ) GetInterval () metav1.Duration {
212
- return in .Spec .Interval
213
- }
214
-
215
- // GetArtifact returns the latest artifact from the source if present in the status sub-resource.
243
+ // GetArtifact returns the latest Artifact from the GitRepository if present in
244
+ // the status sub-resource.
216
245
func (in * GitRepository ) GetArtifact () * Artifact {
217
246
return in .Status .Artifact
218
247
}
219
248
220
- // GetStatusConditions returns a pointer to the Status.Conditions slice.
221
- // Deprecated: use GetConditions instead.
222
- func (in * GitRepository ) GetStatusConditions () * []metav1.Condition {
223
- return & in .Status .Conditions
224
- }
225
-
226
249
// +genclient
227
250
// +genclient:Namespaced
228
251
// +kubebuilder:storageversion
@@ -234,7 +257,7 @@ func (in *GitRepository) GetStatusConditions() *[]metav1.Condition {
234
257
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description=""
235
258
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description=""
236
259
237
- // GitRepository is the Schema for the gitrepositories API
260
+ // GitRepository is the Schema for the gitrepositories API.
238
261
type GitRepository struct {
239
262
metav1.TypeMeta `json:",inline"`
240
263
metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -244,7 +267,7 @@ type GitRepository struct {
244
267
Status GitRepositoryStatus `json:"status,omitempty"`
245
268
}
246
269
247
- // GitRepositoryList contains a list of GitRepository
270
+ // GitRepositoryList contains a list of GitRepository objects.
248
271
// +kubebuilder:object:root=true
249
272
type GitRepositoryList struct {
250
273
metav1.TypeMeta `json:",inline"`
0 commit comments