@@ -29,165 +29,198 @@ const (
2929 // GitRepositoryKind is the string representation of a GitRepository.
3030 GitRepositoryKind = "GitRepository"
3131
32- // GoGitImplementation represents the go-git Git implementation kind .
32+ // GoGitImplementation for performing Git operations using go-git .
3333 GoGitImplementation = "go-git"
34- // LibGit2Implementation represents the git2go Git implementation kind .
34+ // LibGit2Implementation for performing Git operations using libgit2 .
3535 LibGit2Implementation = "libgit2"
3636)
3737
3838const (
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.
4244 IncludeUnavailableCondition string = "IncludeUnavailable"
4345)
4446
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.
4649type 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.
4851 // +kubebuilder:validation:Pattern="^(http|https|ssh)://"
4952 // +required
5053 URL string `json:"url"`
5154
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.
5561 // +optional
5662 SecretRef * meta.LocalObjectReference `json:"secretRef,omitempty"`
5763
58- // The interval at which to check for repository updates.
64+ // Interval at which to check the GitRepository for updates.
5965 // +required
6066 Interval metav1.Duration `json:"interval"`
6167
62- // The timeout for remote Git operations like cloning, defaults to 60s.
68+ // Timeout for Git operations like cloning, defaults to 60s.
6369 // +kubebuilder:default="60s"
6470 // +optional
6571 Timeout * metav1.Duration `json:"timeout,omitempty"`
6672
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.
6975 // +optional
7076 Reference * GitRepositoryRef `json:"ref,omitempty"`
7177
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).
7380 // +optional
7481 Verification * GitRepositoryVerification `json:"verify,omitempty"`
7582
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.
7886 // +optional
7987 Ignore * string `json:"ignore,omitempty"`
8088
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 .
8391 // +optional
8492 Suspend bool `json:"suspend,omitempty"`
8593
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').
8896 // +kubebuilder:validation:Enum=go-git;libgit2
8997 // +kubebuilder:default:=go-git
9098 // +optional
9199 GitImplementation string `json:"gitImplementation,omitempty"`
92100
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.
94103 // This option is available only when using the 'go-git' GitImplementation.
95104 // +optional
96105 RecurseSubmodules bool `json:"recurseSubmodules,omitempty"`
97106
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 .
100109 Include []GitRepositoryInclude `json:"include,omitempty"`
101110
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
103114 // +optional
104115 AccessFrom * acl.AccessFrom `json:"accessFrom,omitempty"`
105116}
106117
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.
107137func (in * GitRepositoryInclude ) GetFromPath () string {
108138 return in .FromPath
109139}
110140
141+ // GetToPath returns the specified ToPath, falling back to the name of the
142+ // GitRepositoryRef.
111143func (in * GitRepositoryInclude ) GetToPath () string {
112144 if in .ToPath == "" {
113145 return in .GitRepositoryRef .Name
114146 }
115147 return in .ToPath
116148}
117149
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.
133151type 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.
135156 // +optional
136157 Branch string `json:"branch,omitempty"`
137158
138- // The Git tag to checkout , takes precedence over Branch.
159+ // Tag to check out , takes precedence over Branch.
139160 // +optional
140161 Tag string `json:"tag,omitempty"`
141162
142- // The Git tag semver expression, takes precedence over Tag.
163+ // SemVer tag expression to check out , takes precedence over Tag.
143164 // +optional
144165 SemVer string `json:"semver,omitempty"`
145166
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.
147172 // +optional
148173 Commit string `json:"commit,omitempty"`
149174}
150175
151- // GitRepositoryVerification defines the OpenPGP signature verification process.
176+ // GitRepositoryVerification specifies the Git commit signature verification
177+ // strategy.
152178type GitRepositoryVerification struct {
153- // Mode describes what Git object should be verified, currently ('head').
179+ // Mode specifies what Git object should be verified, currently ('head').
154180 // +kubebuilder:validation:Enum=head
155181 Mode string `json:"mode"`
156182
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.
158185 SecretRef meta.LocalObjectReference `json:"secretRef,omitempty"`
159186}
160187
161- // GitRepositoryStatus defines the observed state of a Git repository.
188+ // GitRepositoryStatus records the observed state of a Git repository.
162189type GitRepositoryStatus struct {
163- // ObservedGeneration is the last observed generation.
190+ // ObservedGeneration is the last observed generation of the GitRepository
191+ // object.
164192 // +optional
165193 ObservedGeneration int64 `json:"observedGeneration,omitempty"`
166194
167195 // Conditions holds the conditions for the GitRepository.
168196 // +optional
169197 Conditions []metav1.Condition `json:"conditions,omitempty"`
170198
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.
172202 // +optional
173203 URL string `json:"url,omitempty"`
174204
175- // Artifact represents the output of the last successful repository sync .
205+ // Artifact represents the last successful GitRepository reconciliation .
176206 // +optional
177207 Artifact * Artifact `json:"artifact,omitempty"`
178208
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.
180211 // +optional
181212 IncludedArtifacts []* Artifact `json:"includedArtifacts,omitempty"`
182213
183214 meta.ReconcileRequestStatus `json:",inline"`
184215}
185216
186217const (
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"
189221
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.
191224 GitOperationFailedReason string = "GitOperationFailed"
192225)
193226
@@ -201,28 +234,18 @@ func (in *GitRepository) SetConditions(conditions []metav1.Condition) {
201234 in .Status .Conditions = conditions
202235}
203236
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.
205239func (in GitRepository ) GetRequeueAfter () time.Duration {
206240 return in .Spec .Interval .Duration
207241}
208242
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.
216245func (in * GitRepository ) GetArtifact () * Artifact {
217246 return in .Status .Artifact
218247}
219248
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-
226249// +genclient
227250// +genclient:Namespaced
228251// +kubebuilder:storageversion
@@ -234,7 +257,7 @@ func (in *GitRepository) GetStatusConditions() *[]metav1.Condition {
234257// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description=""
235258// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description=""
236259
237- // GitRepository is the Schema for the gitrepositories API
260+ // GitRepository is the Schema for the gitrepositories API.
238261type GitRepository struct {
239262 metav1.TypeMeta `json:",inline"`
240263 metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -244,7 +267,7 @@ type GitRepository struct {
244267 Status GitRepositoryStatus `json:"status,omitempty"`
245268}
246269
247- // GitRepositoryList contains a list of GitRepository
270+ // GitRepositoryList contains a list of GitRepository objects.
248271// +kubebuilder:object:root=true
249272type GitRepositoryList struct {
250273 metav1.TypeMeta `json:",inline"`
0 commit comments