@@ -48,6 +48,8 @@ const (
4848// Artifact for a Git repository.
4949type GitRepositorySpec struct {
5050 // URL specifies the Git repository URL, it can be an HTTP/S or SSH address.
51+ // +kubebuilder:validation:MinLength=1
52+ // +kubebuilder:validation:MaxLength=253
5153 // +kubebuilder:validation:Pattern="^(http|https|ssh)://.*$"
5254 // +required
5355 URL string `json:"url"`
@@ -83,6 +85,8 @@ type GitRepositorySpec struct {
8385 // Ignore overrides the set of excluded patterns in the .sourceignore format
8486 // (which is the same as .gitignore). If not provided, a default will be used,
8587 // consult the documentation for your version to find out what those are.
88+ // +kubebuilder:validation:MaxLength=253
89+ // +kubebuilder:validation:Pattern=`^([a-zA-Z0-9_\-.\\\/]|\[[0-9]{1,5}\])+$`
8690 // +optional
8791 Ignore * string `json:"ignore,omitempty"`
8892
@@ -124,11 +128,15 @@ type GitRepositoryInclude struct {
124128
125129 // FromPath specifies the path to copy contents from, defaults to the root
126130 // of the Artifact.
131+ // +kubebuilder:validation:MaxLength=253
132+ // +kubebuilder:validation:Pattern=`^([a-zA-Z0-9_\-.\\\/]|\[[0-9]{1,5}\])+$`
127133 // +optional
128134 FromPath string `json:"fromPath"`
129135
130136 // ToPath specifies the path to copy contents to, defaults to the name of
131137 // the GitRepositoryRef.
138+ // +kubebuilder:validation:MaxLength=253
139+ // +kubebuilder:validation:Pattern=`^([a-zA-Z0-9_\-.\\\/]|\[[0-9]{1,5}\])+$`
132140 // +optional
133141 ToPath string `json:"toPath"`
134142}
@@ -153,14 +161,20 @@ type GitRepositoryRef struct {
153161 //
154162 // When GitRepositorySpec.GitImplementation is set to 'go-git', a shallow
155163 // clone of the specified branch is performed.
164+ // +kubebuilder:validation:MaxLength=63
165+ // +kubebuilder:validation:Pattern=`^([a-zA-Z0-9_\-.\\\/]|\[[0-9]{1,5}\])+$`
156166 // +optional
157167 Branch string `json:"branch,omitempty"`
158168
159169 // Tag to check out, takes precedence over Branch.
170+ // +kubebuilder:validation:MaxLength=253
171+ // +kubebuilder:validation:Pattern=`^[\-._0-9]+$`
160172 // +optional
161173 Tag string `json:"tag,omitempty"`
162174
163175 // SemVer tag expression to check out, takes precedence over Tag.
176+ // +kubebuilder:validation:MaxLength=63
177+ // +kubebuilder:validation:Pattern=`^[\-._0-9]+$`
164178 // +optional
165179 SemVer string `json:"semver,omitempty"`
166180
@@ -169,6 +183,8 @@ type GitRepositoryRef struct {
169183 // When GitRepositorySpec.GitImplementation is set to 'go-git', this can be
170184 // combined with Branch to shallow clone the branch, in which the commit is
171185 // expected to exist.
186+ // +kubebuilder:validation:MaxLength=250
187+ // +kubebuilder:validation:Pattern=`^([a-zA-Z0-9_\-.\\\/]|\[[0-9]{1,5}\])+$`
172188 // +optional
173189 Commit string `json:"commit,omitempty"`
174190}
@@ -199,6 +215,8 @@ type GitRepositoryStatus struct {
199215 // URL is the dynamic fetch link for the latest Artifact.
200216 // It is provided on a "best effort" basis, and using the precise
201217 // GitRepositoryStatus.Artifact data is recommended.
218+ // +kubebuilder:validation:MaxLength=253
219+ // +kubebuilder:validation:Pattern="^(http|https|ssh)://.*$"
202220 // +optional
203221 URL string `json:"url,omitempty"`
204222
@@ -274,6 +292,7 @@ type GitRepository struct {
274292 metav1.TypeMeta `json:",inline"`
275293 metav1.ObjectMeta `json:"metadata,omitempty"`
276294
295+ // +kubebuilder:validation:required
277296 Spec GitRepositorySpec `json:"spec,omitempty"`
278297 // +kubebuilder:default={"observedGeneration":-1}
279298 Status GitRepositoryStatus `json:"status,omitempty"`
0 commit comments