Skip to content

Commit

Permalink
Add Release object to hmc-templates chart
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Pavlov <[email protected]>
  • Loading branch information
Kshatrix committed Sep 23, 2024
1 parent 6738b17 commit f4d0092
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ set-hmc-version: yq
$(YQ) eval '.version = "$(VERSION)"' -i $(PROVIDER_TEMPLATES_DIR)/hmc/Chart.yaml
$(YQ) eval '.version = "$(VERSION)"' -i $(PROVIDER_TEMPLATES_DIR)/hmc-templates/Chart.yaml
$(YQ) eval '.image.tag = "$(VERSION)"' -i $(PROVIDER_TEMPLATES_DIR)/hmc/values.yaml
$(YQ) eval '.spec.version = "$(VERSION)"' -i $(PROVIDER_TEMPLATES_DIR)/hmc-templates/files/release.yaml
$(YQ) eval '.metadata.name = "hmc-$(patsubst v%,%,$(subst .,-, $(VERSION)))"' -i $(PROVIDER_TEMPLATES_DIR)/hmc-templates/files/release.yaml

.PHONY: hmc-chart-release
hmc-chart-release: set-hmc-version templates-generate ## Generate hmc helm chart
Expand Down Expand Up @@ -295,6 +297,10 @@ dev-push: docker-build helm-push
dev-templates: templates-generate
$(KUBECTL) -n $(NAMESPACE) apply -f $(PROVIDER_TEMPLATES_DIR)/hmc-templates/files/templates

.PHONY: dev-release
dev-release:
@$(YQ) e ".spec.version = \"${VERSION}\"" $(PROVIDER_TEMPLATES_DIR)/hmc-templates/files/release.yaml | $(KUBECTL) -n $(NAMESPACE) apply -f -

.PHONY: dev-aws-creds
dev-aws-creds: yq
@$(YQ) e ".stringData.AWS_B64ENCODED_CREDENTIALS = \"${AWS_CREDENTIALS}\"" config/dev/awscredentials.yaml | $(KUBECTL) -n $(NAMESPACE) apply -f -
Expand All @@ -308,7 +314,7 @@ dev-vsphere-creds: envsubst
@NAMESPACE=$(NAMESPACE) $(ENVSUBST) -no-unset -i config/dev/vsphere-credentials.yaml | $(KUBECTL) apply -f -

.PHONY: dev-apply ## Apply the development environment by deploying the kind cluster, local registry and the HMC helm chart.
dev-apply: kind-deploy registry-deploy dev-push dev-deploy dev-templates
dev-apply: kind-deploy registry-deploy dev-push dev-deploy dev-templates dev-release

.PHONY: dev-destroy
dev-destroy: kind-undeploy registry-undeploy ## Destroy the development environment by deleting the kind cluster and local registry.
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/release_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (p *Poller) ensureManagement(ctx context.Context) error {
return fmt.Errorf("failed to get %s Management object", hmc.ManagementName)
}

mgmtObj.Spec.Release, err = p.gerCurrentReleaseName(ctx)
mgmtObj.Spec.Release, err = p.getCurrentReleaseName(ctx)
if err != nil {
return err
}
Expand Down Expand Up @@ -227,7 +227,7 @@ func (p *Poller) reconcileHMCTemplates(ctx context.Context) error {
}
return nil
}
func (p *Poller) gerCurrentReleaseName(ctx context.Context) (string, error) {
func (p *Poller) getCurrentReleaseName(ctx context.Context) (string, error) {
releases := &hmc.ReleaseList{}
listOptions := client.ListOptions{
FieldSelector: fields.SelectorFromSet(fields.Set{hmc.VersionKey: build.Version}),
Expand Down
21 changes: 21 additions & 0 deletions templates/provider/hmc-templates/files/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: hmc.mirantis.com/v1alpha1
kind: Release
metadata:
name: hmc-0-0-2
spec:
version: v0.0.2
hmc:
template: hmc
capi:
template: cluster-api
providers:
- name: k0smotron
template: k0smotron
- name: cluster-api-provider-azure
template: cluster-api-provider-azure
- name: cluster-api-provider-vsphere
template: cluster-api-provider-vsphere
- name: cluster-api-provider-aws
template: cluster-api-provider-aws
- name: projectsveltos
template: projectsveltos
3 changes: 3 additions & 0 deletions templates/provider/hmc-templates/templates/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- if .Values.createRelease }}
{{ $.Files.Get "files/release.yaml" }}
{{- end }}

0 comments on commit f4d0092

Please sign in to comment.