Skip to content

Commit

Permalink
feat!: create root level HelmConfig struct which applies to all HelmR…
Browse files Browse the repository at this point in the history
…eleases (#356)

First step into resolving
- validator-labs/validatorctl#100

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
  • Loading branch information
ahmad-ibra committed Aug 1, 2024
1 parent 4c85249 commit 6fe04ba
Show file tree
Hide file tree
Showing 17 changed files with 212 additions and 96 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ CERTS_INIT_IMG ?= quay.io/validator-labs/validator-certs-init:latest
# Helm vars
CHART_NAME=validator

VALIDATION_RESULTS_CRD = chart/validator/crds/validation.spectrocloud.labs_validationresults.yaml
VALIDATOR_CONFIGS_CRD = chart/validator/crds/validation.spectrocloud.labs_validatorconfigs.yaml

reviewable-ext:
@$(INFO) Checking for plugin version updates...
bash hack/update-versions.sh
rm $(VALIDATION_RESULTS_CRD) $(VALIDATOR_CONFIGS_CRD)
cp config/crd/bases/validation.spectrocloud.labs_validationresults.yaml $(VALIDATION_RESULTS_CRD)
cp config/crd/bases/validation.spectrocloud.labs_validatorconfigs.yaml $(VALIDATOR_CONFIGS_CRD)

.PHONY: docker-build-certs-init
docker-build-certs-init: ## Build validator-certs-init docker image.
Expand All @@ -31,4 +37,4 @@ HAULER_VERSION ?= 1.0.4
.PHONY: hauler
hauler: ## Install hauler
curl -sfL https://get.hauler.dev | HAULER_VERSION=$(HAULER_VERSION) bash
HAULER = /usr/local/bin/hauler
HAULER = /usr/local/bin/hauler
11 changes: 10 additions & 1 deletion api/v1alpha1/validatorconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import (

// ValidatorConfigSpec defines the desired state of ValidatorConfig.
type ValidatorConfigSpec struct {
// HelmConfig defines the configuration for the Helm registry.
HelmConfig HelmConfig `json:"helmConfig" yaml:"helmConfig"`

// Plugins defines the configuration for the validator plugins.
Plugins []HelmRelease `json:"plugins,omitempty" yaml:"plugins,omitempty"`

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

// Repository URL of the Helm chart.
// Repository of the Helm chart.
Repository string `json:"repository" yaml:"repository"`

// Version of the Helm chart.
Version string `json:"version" yaml:"version"`
}

// HelmConfig defines the configuration for the Helm registry.
type HelmConfig struct {
// Registry is the URL of the Helm registry.
Registry string `json:"registry" yaml:"registry"`

// CAFile is the path to the CA certificate for the Helm repository.
CAFile string `json:"caFile,omitempty" yaml:"caFile,omitempty"`
Expand Down
16 changes: 16 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion chart/validator/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.12.0
controller-gen.kubebuilder.io/version: v0.15.0
name: validationresults.validation.spectrocloud.labs
spec:
group: validation.spectrocloud.labs
Expand All @@ -30,74 +30,83 @@ spec:
name: v1alpha1
schema:
openAPIV3Schema:
description: ValidationResult is the Schema for the validationresults API
description: ValidationResult is the Schema for the validationresults API.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
spec:
description: ValidationResultSpec defines the desired state of ValidationResult
description: ValidationResultSpec defines the desired state of ValidationResult.
properties:
expectedResults:
description: The number of rules in the validator plugin spec, hence
the number of expected ValidationResults.
minimum: 1
type: integer
plugin:
description: Plugin is the plugin code of the validator plugin that
was executed.
type: string
required:
- expectedResults
- plugin
type: object
status:
description: ValidationResultStatus defines the observed state of ValidationResult
description: ValidationResultStatus defines the observed state of ValidationResult.
properties:
conditions:
description: Conditions is a list of conditions that describe the
current state of the ValidationResult.
items:
description: Condition defines an observation of a Cluster API resource
operational state.
properties:
lastTransitionTime:
description: Last time the condition transitioned from one status
to another. This should be when the underlying condition changed.
If that is not known, then using the time when the API field
changed is acceptable.
description: |-
Last time the condition transitioned from one status to another.
This should be when the underlying condition changed. If that is not known, then using the time when
the API field changed is acceptable.
format: date-time
type: string
message:
description: A human readable message indicating details about
the transition. This field may be empty.
description: |-
A human readable message indicating details about the transition.
This field may be empty.
type: string
reason:
description: The reason for the condition's last transition
in CamelCase. The specific API may choose whether or not this
field is considered a guaranteed API. This field may not be
empty.
description: |-
The reason for the condition's last transition in CamelCase.
The specific API may choose whether or not this field is considered a guaranteed API.
This field may not be empty.
type: string
severity:
description: Severity provides an explicit classification of
Reason code, so the users or machines can immediately understand
the current situation and act accordingly. The Severity field
MUST be set only when Status=False.
description: |-
Severity provides an explicit classification of Reason code, so the users or machines can immediately
understand the current situation and act accordingly.
The Severity field MUST be set only when Status=False.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important.
description: |-
Type of condition in CamelCase or in foo.example.com/CamelCase.
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
can be useful (see .node.status.conditions), the ability to deconflict is important.
type: string
required:
- lastTransitionTime
Expand All @@ -106,9 +115,14 @@ spec:
type: object
type: array
state:
description: State is the overall state of the validation result.
type: string
validationConditions:
description: ValidationConditions is a list of conditions that describe
the validation rules associated with the ValidationResult.
items:
description: ValidationCondition describes the state of a validation
rule.
properties:
details:
description: Human-readable messages indicating additional details
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.12.0
controller-gen.kubebuilder.io/version: v0.15.0
name: validatorconfigs.validation.spectrocloud.labs
spec:
group: validation.spectrocloud.labs
Expand All @@ -17,59 +17,90 @@ spec:
- name: v1alpha1
schema:
openAPIV3Schema:
description: ValidatorConfig is the Schema for the validatorconfigs API
description: ValidatorConfig is the Schema for the validatorconfigs API.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
spec:
description: ValidatorConfigSpec defines the desired state of ValidatorConfig
description: ValidatorConfigSpec defines the desired state of ValidatorConfig.
properties:
helmConfig:
description: HelmConfig defines the configuration for the Helm registry.
properties:
authSecretName:
description: AuthSecretName is the name of the K8s secret containing
the authentication details for the Helm repository.
type: string
caFile:
description: CAFile is the path to the CA certificate for the
Helm repository.
type: string
insecureSkipVerify:
description: InsecureSkipTLSVerify skips the verification of the
server's certificate chain and host name.
type: boolean
registry:
description: Registry is the URL of the Helm registry.
type: string
required:
- registry
type: object
plugins:
description: Plugins defines the configuration for the validator plugins.
items:
description: HelmRelease defines the configuration for a Helm chart
release.
properties:
chart:
description: Chart defines the Helm chart to be installed.
properties:
authSecretName:
type: string
caFile:
type: string
insecureSkipVerify:
type: boolean
name:
description: Name of the Helm chart.
type: string
repository:
description: Repository of the Helm chart.
type: string
version:
description: Version of the Helm chart.
type: string
required:
- name
- repository
- version
type: object
values:
description: Values defines the values to be passed to the Helm
chart.
type: string
required:
- chart
- values
type: object
type: array
sink:
description: Sink defines the configuration for the notification sink.
properties:
secretName:
description: Name of a K8s secret containing configuration details
for the sink
description: SecretName is the name of a K8s secret containing
configuration details for the sink.
type: string
type:
description: Type of the sink.
enum:
- alertmanager
- slack
Expand All @@ -78,23 +109,28 @@ spec:
- secretName
- type
type: object
required:
- helmConfig
type: object
status:
description: ValidatorConfigStatus defines the observed state of ValidatorConfig
properties:
conditions:
items:
description: ValidatorPluginCondition describes the state of a Validator
plugin.
properties:
lastUpdatedTime:
description: Last time the condition transitioned from one status
to another. This should be when the underlying condition changed.
If that is not known, then using the time when the API field
changed is acceptable.
description: |-
Last time the condition transitioned from one status to another.
This should be when the underlying condition changed. If that is not known, then using the time when
the API field changed is acceptable.
format: date-time
type: string
message:
description: A human readable message indicating details about
the transition. This field may be empty.
description: |-
A human readable message indicating details about the transition.
This field may be empty.
type: string
pluginName:
description: Name of the Validator plugin.
Expand All @@ -103,11 +139,10 @@ spec:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important.
description: |-
Type of condition in CamelCase or in foo.example.com/CamelCase.
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
can be useful (see .node.status.conditions), the ability to deconflict is important.
type: string
required:
- lastUpdatedTime
Expand Down
Loading

0 comments on commit 6fe04ba

Please sign in to comment.