Skip to content

Commit 8eadfe1

Browse files
authored
refactor: create root level HelmConfig struct which applies to all HelmReleases (#356)
## Issue First step into resolving - validator-labs/validatorctl#100 ## Description In an effort to simplify the TUI prompts in validatorctl to not require lots of re-prompts for the helm configuration, we first need to refactor our helm related structs. The proposed structure would be this: - `ValidatorConfigSpec.HelmConfig` defines the helm registry configuration that would be used to pull all plugin charts - `ValidatorConfigSpec.Plugins` has been simplifies to only specify the charts repository, name, version, and values. Along side this change, I updated the `reviewable-ext` make target to also update the CRDs in the validator helm chart
1 parent 4c85249 commit 8eadfe1

17 files changed

+212
-96
lines changed

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ CERTS_INIT_IMG ?= quay.io/validator-labs/validator-certs-init:latest
88
# Helm vars
99
CHART_NAME=validator
1010

11+
VALIDATION_RESULTS_CRD = chart/validator/crds/validation.spectrocloud.labs_validationresults.yaml
12+
VALIDATOR_CONFIGS_CRD = chart/validator/crds/validation.spectrocloud.labs_validatorconfigs.yaml
13+
1114
reviewable-ext:
1215
@$(INFO) Checking for plugin version updates...
1316
bash hack/update-versions.sh
17+
rm $(VALIDATION_RESULTS_CRD) $(VALIDATOR_CONFIGS_CRD)
18+
cp config/crd/bases/validation.spectrocloud.labs_validationresults.yaml $(VALIDATION_RESULTS_CRD)
19+
cp config/crd/bases/validation.spectrocloud.labs_validatorconfigs.yaml $(VALIDATOR_CONFIGS_CRD)
1420

1521
.PHONY: docker-build-certs-init
1622
docker-build-certs-init: ## Build validator-certs-init docker image.
@@ -31,4 +37,4 @@ HAULER_VERSION ?= 1.0.4
3137
.PHONY: hauler
3238
hauler: ## Install hauler
3339
curl -sfL https://get.hauler.dev | HAULER_VERSION=$(HAULER_VERSION) bash
34-
HAULER = /usr/local/bin/hauler
40+
HAULER = /usr/local/bin/hauler

api/v1alpha1/validatorconfig_types.go

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

2424
// ValidatorConfigSpec defines the desired state of ValidatorConfig.
2525
type ValidatorConfigSpec struct {
26+
// HelmConfig defines the configuration for the Helm registry.
27+
HelmConfig HelmConfig `json:"helmConfig" yaml:"helmConfig"`
28+
2629
// Plugins defines the configuration for the validator plugins.
2730
Plugins []HelmRelease `json:"plugins,omitempty" yaml:"plugins,omitempty"`
2831

@@ -54,11 +57,17 @@ type HelmChart struct {
5457
// Name of the Helm chart.
5558
Name string `json:"name" yaml:"name"`
5659

57-
// Repository URL of the Helm chart.
60+
// Repository of the Helm chart.
5861
Repository string `json:"repository" yaml:"repository"`
5962

6063
// Version of the Helm chart.
6164
Version string `json:"version" yaml:"version"`
65+
}
66+
67+
// HelmConfig defines the configuration for the Helm registry.
68+
type HelmConfig struct {
69+
// Registry is the URL of the Helm registry.
70+
Registry string `json:"registry" yaml:"registry"`
6271

6372
// CAFile is the path to the CA certificate for the Helm repository.
6473
CAFile string `json:"caFile,omitempty" yaml:"caFile,omitempty"`

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chart/validator/README.md

Lines changed: 2 additions & 1 deletion
Large diffs are not rendered by default.

chart/validator/crds/validation.spectrocloud.labs_validationresults.yaml

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.12.0
6+
controller-gen.kubebuilder.io/version: v0.15.0
77
name: validationresults.validation.spectrocloud.labs
88
spec:
99
group: validation.spectrocloud.labs
@@ -30,74 +30,83 @@ spec:
3030
name: v1alpha1
3131
schema:
3232
openAPIV3Schema:
33-
description: ValidationResult is the Schema for the validationresults API
33+
description: ValidationResult is the Schema for the validationresults API.
3434
properties:
3535
apiVersion:
36-
description: 'APIVersion defines the versioned schema of this representation
37-
of an object. Servers should convert recognized schemas to the latest
38-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
36+
description: |-
37+
APIVersion defines the versioned schema of this representation of an object.
38+
Servers should convert recognized schemas to the latest internal value, and
39+
may reject unrecognized values.
40+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
3941
type: string
4042
kind:
41-
description: 'Kind is a string value representing the REST resource this
42-
object represents. Servers may infer this from the endpoint the client
43-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
43+
description: |-
44+
Kind is a string value representing the REST resource this object represents.
45+
Servers may infer this from the endpoint the client submits requests to.
46+
Cannot be updated.
47+
In CamelCase.
48+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
4449
type: string
4550
metadata:
4651
type: object
4752
spec:
48-
description: ValidationResultSpec defines the desired state of ValidationResult
53+
description: ValidationResultSpec defines the desired state of ValidationResult.
4954
properties:
5055
expectedResults:
5156
description: The number of rules in the validator plugin spec, hence
5257
the number of expected ValidationResults.
5358
minimum: 1
5459
type: integer
5560
plugin:
61+
description: Plugin is the plugin code of the validator plugin that
62+
was executed.
5663
type: string
5764
required:
5865
- expectedResults
5966
- plugin
6067
type: object
6168
status:
62-
description: ValidationResultStatus defines the observed state of ValidationResult
69+
description: ValidationResultStatus defines the observed state of ValidationResult.
6370
properties:
6471
conditions:
72+
description: Conditions is a list of conditions that describe the
73+
current state of the ValidationResult.
6574
items:
6675
description: Condition defines an observation of a Cluster API resource
6776
operational state.
6877
properties:
6978
lastTransitionTime:
70-
description: Last time the condition transitioned from one status
71-
to another. This should be when the underlying condition changed.
72-
If that is not known, then using the time when the API field
73-
changed is acceptable.
79+
description: |-
80+
Last time the condition transitioned from one status to another.
81+
This should be when the underlying condition changed. If that is not known, then using the time when
82+
the API field changed is acceptable.
7483
format: date-time
7584
type: string
7685
message:
77-
description: A human readable message indicating details about
78-
the transition. This field may be empty.
86+
description: |-
87+
A human readable message indicating details about the transition.
88+
This field may be empty.
7989
type: string
8090
reason:
81-
description: The reason for the condition's last transition
82-
in CamelCase. The specific API may choose whether or not this
83-
field is considered a guaranteed API. This field may not be
84-
empty.
91+
description: |-
92+
The reason for the condition's last transition in CamelCase.
93+
The specific API may choose whether or not this field is considered a guaranteed API.
94+
This field may not be empty.
8595
type: string
8696
severity:
87-
description: Severity provides an explicit classification of
88-
Reason code, so the users or machines can immediately understand
89-
the current situation and act accordingly. The Severity field
90-
MUST be set only when Status=False.
97+
description: |-
98+
Severity provides an explicit classification of Reason code, so the users or machines can immediately
99+
understand the current situation and act accordingly.
100+
The Severity field MUST be set only when Status=False.
91101
type: string
92102
status:
93103
description: Status of the condition, one of True, False, Unknown.
94104
type: string
95105
type:
96-
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
97-
Many .condition.type values are consistent across resources
98-
like Available, but because arbitrary conditions can be useful
99-
(see .node.status.conditions), the ability to deconflict is
100-
important.
106+
description: |-
107+
Type of condition in CamelCase or in foo.example.com/CamelCase.
108+
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
109+
can be useful (see .node.status.conditions), the ability to deconflict is important.
101110
type: string
102111
required:
103112
- lastTransitionTime
@@ -106,9 +115,14 @@ spec:
106115
type: object
107116
type: array
108117
state:
118+
description: State is the overall state of the validation result.
109119
type: string
110120
validationConditions:
121+
description: ValidationConditions is a list of conditions that describe
122+
the validation rules associated with the ValidationResult.
111123
items:
124+
description: ValidationCondition describes the state of a validation
125+
rule.
112126
properties:
113127
details:
114128
description: Human-readable messages indicating additional details

chart/validator/crds/validation.spectrocloud.labs_validatorconfigs.yaml

Lines changed: 63 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.12.0
6+
controller-gen.kubebuilder.io/version: v0.15.0
77
name: validatorconfigs.validation.spectrocloud.labs
88
spec:
99
group: validation.spectrocloud.labs
@@ -17,59 +17,90 @@ spec:
1717
- name: v1alpha1
1818
schema:
1919
openAPIV3Schema:
20-
description: ValidatorConfig is the Schema for the validatorconfigs API
20+
description: ValidatorConfig is the Schema for the validatorconfigs API.
2121
properties:
2222
apiVersion:
23-
description: 'APIVersion defines the versioned schema of this representation
24-
of an object. Servers should convert recognized schemas to the latest
25-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
23+
description: |-
24+
APIVersion defines the versioned schema of this representation of an object.
25+
Servers should convert recognized schemas to the latest internal value, and
26+
may reject unrecognized values.
27+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
2628
type: string
2729
kind:
28-
description: 'Kind is a string value representing the REST resource this
29-
object represents. Servers may infer this from the endpoint the client
30-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
30+
description: |-
31+
Kind is a string value representing the REST resource this object represents.
32+
Servers may infer this from the endpoint the client submits requests to.
33+
Cannot be updated.
34+
In CamelCase.
35+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
3136
type: string
3237
metadata:
3338
type: object
3439
spec:
35-
description: ValidatorConfigSpec defines the desired state of ValidatorConfig
40+
description: ValidatorConfigSpec defines the desired state of ValidatorConfig.
3641
properties:
42+
helmConfig:
43+
description: HelmConfig defines the configuration for the Helm registry.
44+
properties:
45+
authSecretName:
46+
description: AuthSecretName is the name of the K8s secret containing
47+
the authentication details for the Helm repository.
48+
type: string
49+
caFile:
50+
description: CAFile is the path to the CA certificate for the
51+
Helm repository.
52+
type: string
53+
insecureSkipVerify:
54+
description: InsecureSkipTLSVerify skips the verification of the
55+
server's certificate chain and host name.
56+
type: boolean
57+
registry:
58+
description: Registry is the URL of the Helm registry.
59+
type: string
60+
required:
61+
- registry
62+
type: object
3763
plugins:
64+
description: Plugins defines the configuration for the validator plugins.
3865
items:
66+
description: HelmRelease defines the configuration for a Helm chart
67+
release.
3968
properties:
4069
chart:
70+
description: Chart defines the Helm chart to be installed.
4171
properties:
42-
authSecretName:
43-
type: string
44-
caFile:
45-
type: string
46-
insecureSkipVerify:
47-
type: boolean
4872
name:
73+
description: Name of the Helm chart.
4974
type: string
5075
repository:
76+
description: Repository of the Helm chart.
5177
type: string
5278
version:
79+
description: Version of the Helm chart.
5380
type: string
5481
required:
5582
- name
5683
- repository
5784
- version
5885
type: object
5986
values:
87+
description: Values defines the values to be passed to the Helm
88+
chart.
6089
type: string
6190
required:
6291
- chart
6392
- values
6493
type: object
6594
type: array
6695
sink:
96+
description: Sink defines the configuration for the notification sink.
6797
properties:
6898
secretName:
69-
description: Name of a K8s secret containing configuration details
70-
for the sink
99+
description: SecretName is the name of a K8s secret containing
100+
configuration details for the sink.
71101
type: string
72102
type:
103+
description: Type of the sink.
73104
enum:
74105
- alertmanager
75106
- slack
@@ -78,23 +109,28 @@ spec:
78109
- secretName
79110
- type
80111
type: object
112+
required:
113+
- helmConfig
81114
type: object
82115
status:
83116
description: ValidatorConfigStatus defines the observed state of ValidatorConfig
84117
properties:
85118
conditions:
86119
items:
120+
description: ValidatorPluginCondition describes the state of a Validator
121+
plugin.
87122
properties:
88123
lastUpdatedTime:
89-
description: Last time the condition transitioned from one status
90-
to another. This should be when the underlying condition changed.
91-
If that is not known, then using the time when the API field
92-
changed is acceptable.
124+
description: |-
125+
Last time the condition transitioned from one status to another.
126+
This should be when the underlying condition changed. If that is not known, then using the time when
127+
the API field changed is acceptable.
93128
format: date-time
94129
type: string
95130
message:
96-
description: A human readable message indicating details about
97-
the transition. This field may be empty.
131+
description: |-
132+
A human readable message indicating details about the transition.
133+
This field may be empty.
98134
type: string
99135
pluginName:
100136
description: Name of the Validator plugin.
@@ -103,11 +139,10 @@ spec:
103139
description: Status of the condition, one of True, False, Unknown.
104140
type: string
105141
type:
106-
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
107-
Many .condition.type values are consistent across resources
108-
like Available, but because arbitrary conditions can be useful
109-
(see .node.status.conditions), the ability to deconflict is
110-
important.
142+
description: |-
143+
Type of condition in CamelCase or in foo.example.com/CamelCase.
144+
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
145+
can be useful (see .node.status.conditions), the ability to deconflict is important.
111146
type: string
112147
required:
113148
- lastUpdatedTime

0 commit comments

Comments
 (0)