Skip to content

Commit

Permalink
Add HMCDeployment API fields
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Pavlov <[email protected]>
  • Loading branch information
Kshatrix committed May 29, 2024
1 parent 614ef64 commit f480ca6
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 15 deletions.
23 changes: 13 additions & 10 deletions api/v1alpha1/hmcdeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,28 @@ limitations under the License.
package v1alpha1

import (
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// HMCDeploymentSpec defines the desired state of HMCDeployment
type HMCDeploymentSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of HMCDeployment. Edit hmcdeployment_types.go to remove/update
Foo string `json:"foo,omitempty"`
// DryRun specifies whether the template should be applied after validation or only validated.
// +kubebuilder:validation:Optional
DryRun bool `json:"dryRun"`
// Template is a reference to a HMCTemplate object located in the same namespace.
// +kubebuilder:validation:Required
Template string `json:"template"`
// Configuration allows to provide parameters for template customization.
// If no Configuration provided, the field will be populated with the default values for
// the template and DryRun will be enabled.
// +kubebuilder:validation:Optional
Configuration apiextensionsv1.JSON `json:"configuration"`
}

// HMCDeploymentStatus defines the observed state of HMCDeployment
type HMCDeploymentStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
TemplateValidationStatus `json:",inline"`
}

//+kubebuilder:object:root=true
Expand Down
4 changes: 4 additions & 0 deletions api/v1alpha1/hmctemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ type HMCTemplateSpec struct {

// HMCTemplateStatus defines the observed state of HMCTemplate
type HMCTemplateStatus struct {
TemplateValidationStatus `json:",inline"`
// Descriptions contains information about the template.
// +optional
Description string `json:"description"`
}

type TemplateValidationStatus struct {
// Valid indicates whether the template passed validation or not.
Valid bool `json:"valid"`
// ValidationError provides information regarding issues encountered during template validation.
Expand Down
20 changes: 19 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,36 @@ spec:
spec:
description: HMCDeploymentSpec defines the desired state of HMCDeployment
properties:
foo:
description: Foo is an example field of HMCDeployment. Edit hmcdeployment_types.go
to remove/update
configuration:
description: |-
Configuration allows to provide parameters for template customization.
If no Configuration provided, the field will be populated with the default values for
the template and DryRun will be enabled.
x-kubernetes-preserve-unknown-fields: true
dryRun:
description: DryRun specifies whether the template should be applied
after validation or only validated.
type: boolean
template:
description: Template is a reference to a HMCTemplate object located
in the same namespace.
type: string
required:
- template
type: object
status:
description: HMCDeploymentStatus defines the observed state of HMCDeployment
properties:
valid:
description: Valid indicates whether the template passed validation
or not.
type: boolean
validationError:
description: ValidationError provides information regarding issues
encountered during template validation.
type: string
required:
- valid
type: object
type: object
served: true
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.21
require (
github.com/onsi/ginkgo/v2 v2.19.0
github.com/onsi/gomega v1.33.1
k8s.io/apiextensions-apiserver v0.29.2
k8s.io/apimachinery v0.29.2
k8s.io/client-go v0.29.2
sigs.k8s.io/controller-runtime v0.17.3
Expand Down Expand Up @@ -62,7 +63,6 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.29.2 // indirect
k8s.io/apiextensions-apiserver v0.29.2 // indirect
k8s.io/component-base v0.29.2 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
Expand Down
4 changes: 4 additions & 0 deletions internal/controller/hmctemplate_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ var _ = Describe("HMCTemplate Controller", func() {
Name: resourceName,
Namespace: "default",
},
Spec: hmcmirantiscomv1alpha1.HMCTemplateSpec{
Provider: "aws",
HelmChartURL: "oci://ghcr.io/Mirantis/hmc/charts/aws-template-example",
},
// TODO(user): Specify other spec details if needed.
}
Expect(k8sClient.Create(ctx, resource)).To(Succeed())
Expand Down

0 comments on commit f480ca6

Please sign in to comment.