Skip to content

Commit bcfc9ab

Browse files
committed
sourcev1: align CRD validation with v1beta2
1 parent 9e6fa65 commit bcfc9ab

File tree

6 files changed

+8
-0
lines changed

6 files changed

+8
-0
lines changed

api/v1/gitrepository_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ type GitRepositorySpec struct {
9696
// Provider used for authentication, can be 'azure', 'github', 'generic'.
9797
// When not specified, defaults to 'generic'.
9898
// +kubebuilder:validation:Enum=generic;azure;github
99+
// +kubebuilder:default:=generic
99100
// +optional
100101
Provider string `json:"provider,omitempty"`
101102

api/v1/helmchart_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
const HelmChartKind = "HelmChart"
2929

3030
// HelmChartSpec specifies the desired state of a Helm chart.
31+
// +kubebuilder:validation:XValidation:rule="!has(self.verify) || self.sourceRef.kind == 'HelmRepository'",message="spec.verify is only supported when spec.sourceRef.kind is 'HelmRepository'"
3132
type HelmChartSpec struct {
3233
// Chart is the name or path the Helm chart is available at in the
3334
// SourceRef.

api/v1/helmrepository_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ type HelmRepositorySpec struct {
100100
// and for remote OCI Repository operations like pulling for an OCI helm
101101
// chart by the associated HelmChart.
102102
// Its default value is 60s.
103+
// +kubebuilder:default="60s"
103104
// +kubebuilder:validation:Type=string
104105
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ms|s|m))+$"
105106
// +optional

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ spec:
104104
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$
105105
type: string
106106
provider:
107+
default: generic
107108
description: |-
108109
Provider used for authentication, can be 'azure', 'github', 'generic'.
109110
When not specified, defaults to 'generic'.

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ spec:
198198
- interval
199199
- sourceRef
200200
type: object
201+
x-kubernetes-validations:
202+
- message: spec.verify is only supported when spec.sourceRef.kind is 'HelmRepository'
203+
rule: '!has(self.verify) || self.sourceRef.kind == ''HelmRepository'''
201204
status:
202205
default:
203206
observedGeneration: -1

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ spec:
162162
HelmRepository.
163163
type: boolean
164164
timeout:
165+
default: 60s
165166
description: |-
166167
Timeout is used for the index fetch operation for an HTTPS helm repository,
167168
and for remote OCI Repository operations like pulling for an OCI helm

0 commit comments

Comments
 (0)