SovereignCloudStack / cluster-stacks

Definition of Cluster Stacks based on the ClusterAPI ClusterClass feature
https://scs.community/
Apache License 2.0
7 stars 6 forks source link

[openstack-csp-helper] Support custom (non `openstack`) name for cloud in clouds.yaml #52

Closed matofeder closed 4 months ago

matofeder commented 4 months ago

/kind feature

As a cluster stack administrator (CSP) I want to use a non-default cloud name in clouds.yaml.

CSPO supports custom cloud name (see note in the docs) as well as cluster-stacks are mostly written with custom cloud name support (override is possible via Cluster resource variables)

paulphys commented 4 months ago

Templating the cloud name in the various resources should be pretty straightforward, but I couldn't find a way to adjust the flow control to allow a unknown cloud name to be checked for whether the auth method is app credentials or username/password.

hack/openstack-csp-helper/templates/_helpers.tpl

{{/*
Checks whether we have a regular clouds.yaml or one with application credentials.
*/}}
{{- define "isAppCredential" -}}
{{- if and .Values.clouds.openstack.auth.username (not .Values.clouds.openstack.auth.application_credential_id) -}}
{{- else if and (not .Values.clouds.openstack.auth.username) .Values.clouds.openstack.auth.application_credential_id -}}
true
{{- else }}
{{ fail "please provide either username or application_credential_id, not both, not none" }}
{{- end }}
{{- end }}

AFAIK you can't do conditional statements with dynamic values. Ideally it would just be something like if and .Values.clouds.$cloud_name.auth.username (not .Values.clouds.$cloud_name.auth.application_credential_id) but that's not a thing in helm.

If anyone knows a way to do this please let me know