Skip to content

Commit f65e261

Browse files
committed
api: improve validation rules and omitempty nits
Signed-off-by: Hidde Beydals <[email protected]>
1 parent 8fcfde9 commit f65e261

13 files changed

+34
-11
lines changed

api/v1/artifact_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type Artifact struct {
3939

4040
// Revision is a human-readable identifier traceable in the origin source
4141
// system. It can be a Git commit SHA, Git tag, a Helm chart version, etc.
42-
// +optional
42+
// +required
4343
Revision string `json:"revision"`
4444

4545
// Digest is the digest of the file in the form of '<algorithm>:<checksum>'.
@@ -50,7 +50,7 @@ type Artifact struct {
5050
// LastUpdateTime is the timestamp corresponding to the last update of the
5151
// Artifact.
5252
// +required
53-
LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"`
53+
LastUpdateTime metav1.Time `json:"lastUpdateTime"`
5454

5555
// Size is the number of bytes in the file.
5656
// +optional

api/v1/gitrepository_types.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ type GitRepositorySpec struct {
9696

9797
// Include specifies a list of GitRepository resources which Artifacts
9898
// should be included in the Artifact produced for this GitRepository.
99+
// +optional
99100
Include []GitRepositoryInclude `json:"include,omitempty"`
100101
}
101102

@@ -104,17 +105,18 @@ type GitRepositorySpec struct {
104105
type GitRepositoryInclude struct {
105106
// GitRepositoryRef specifies the GitRepository which Artifact contents
106107
// must be included.
108+
// +required
107109
GitRepositoryRef meta.LocalObjectReference `json:"repository"`
108110

109111
// FromPath specifies the path to copy contents from, defaults to the root
110112
// of the Artifact.
111113
// +optional
112-
FromPath string `json:"fromPath"`
114+
FromPath string `json:"fromPath,omitempty"`
113115

114116
// ToPath specifies the path to copy contents to, defaults to the name of
115117
// the GitRepositoryRef.
116118
// +optional
117-
ToPath string `json:"toPath"`
119+
ToPath string `json:"toPath,omitempty"`
118120
}
119121

120122
// GetFromPath returns the specified FromPath.
@@ -169,7 +171,8 @@ type GitRepositoryVerification struct {
169171

170172
// SecretRef specifies the Secret containing the public keys of trusted Git
171173
// authors.
172-
SecretRef meta.LocalObjectReference `json:"secretRef,omitempty"`
174+
// +required
175+
SecretRef meta.LocalObjectReference `json:"secretRef"`
173176
}
174177

175178
// GitRepositoryStatus records the observed state of a Git repository.

api/v1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta2/gitrepository_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"github.com/fluxcd/pkg/apis/acl"
2525
"github.com/fluxcd/pkg/apis/meta"
26+
2627
apiv1 "github.com/fluxcd/source-controller/api/v1"
2728
)
2829

@@ -191,7 +192,7 @@ type GitRepositoryVerification struct {
191192

192193
// SecretRef specifies the Secret containing the public keys of trusted Git
193194
// authors.
194-
SecretRef meta.LocalObjectReference `json:"secretRef,omitempty"`
195+
SecretRef meta.LocalObjectReference `json:"secretRef"`
195196
}
196197

197198
// GitRepositoryStatus records the observed state of a Git repository.

api/v1beta2/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/source.toolkit.fluxcd.io_buckets.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,9 @@ spec:
411411
the Artifact contents.
412412
type: string
413413
required:
414+
- lastUpdateTime
414415
- path
416+
- revision
415417
- url
416418
type: object
417419
conditions:

config/crd/bases/source.toolkit.fluxcd.io_gitrepositories.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ spec:
174174
type: object
175175
required:
176176
- mode
177+
- secretRef
177178
type: object
178179
required:
179180
- interval
@@ -223,7 +224,9 @@ spec:
223224
the Artifact contents.
224225
type: string
225226
required:
227+
- lastUpdateTime
226228
- path
229+
- revision
227230
- url
228231
type: object
229232
conditions:
@@ -339,7 +342,9 @@ spec:
339342
the Artifact contents.
340343
type: string
341344
required:
345+
- lastUpdateTime
342346
- path
347+
- revision
343348
- url
344349
type: object
345350
type: array
@@ -926,6 +931,7 @@ spec:
926931
type: object
927932
required:
928933
- mode
934+
- secretRef
929935
type: object
930936
required:
931937
- interval
@@ -975,7 +981,9 @@ spec:
975981
the Artifact contents.
976982
type: string
977983
required:
984+
- lastUpdateTime
978985
- path
986+
- revision
979987
- url
980988
type: object
981989
conditions:
@@ -1101,7 +1109,9 @@ spec:
11011109
the Artifact contents.
11021110
type: string
11031111
required:
1112+
- lastUpdateTime
11041113
- path
1114+
- revision
11051115
- url
11061116
type: object
11071117
type: array

config/crd/bases/source.toolkit.fluxcd.io_helmcharts.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,9 @@ spec:
486486
the Artifact contents.
487487
type: string
488488
required:
489+
- lastUpdateTime
489490
- path
491+
- revision
490492
- url
491493
type: object
492494
conditions:

config/crd/bases/source.toolkit.fluxcd.io_helmrepositories.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,9 @@ spec:
403403
the Artifact contents.
404404
type: string
405405
required:
406+
- lastUpdateTime
406407
- path
408+
- revision
407409
- url
408410
type: object
409411
conditions:

0 commit comments

Comments
 (0)