From 388b7d57da907c9894f40faf9f48088ec0ba15cd Mon Sep 17 00:00:00 2001 From: i325261 Date: Thu, 17 Oct 2024 10:53:55 +0200 Subject: [PATCH] renamed method names to be more specific --- .../reconcile-capapplicationversion.go | 16 ++++++++-------- .../controller/reconcile-captenantoperation.go | 6 +++--- internal/controller/reconcile.go | 10 +++++----- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/controller/reconcile-capapplicationversion.go b/internal/controller/reconcile-capapplicationversion.go index 191765e..c6e9154 100644 --- a/internal/controller/reconcile-capapplicationversion.go +++ b/internal/controller/reconcile-capapplicationversion.go @@ -266,7 +266,7 @@ func (c *Controller) handleContentDeployJob(ca *v1alpha1.CAPApplication, cav *v1 // Get VCAP secret name err = nil - if !useVolumeMounts(cav) { + if !useVolumeMountsForServiceCredentials(cav) { vcapSecretName, err = createVCAPSecret(jobName, cav.Namespace, ownerRef, consumedServiceInfos, c.kubeClient) } @@ -301,13 +301,13 @@ func newContentDeploymentJob(ca *v1alpha1.CAPApplication, cav *v1alpha1.CAPAppli env := workload.JobDefinition.Env - if useVolumeMounts(cav) { + if useVolumeMountsForServiceCredentials(cav) { // Get ServiceInfos for consumed BTP services consumedServiceInfos := getConsumedServiceInfos(getConsumedServiceMap(workload.ConsumedBTPServices), ca.Spec.BTP.Services) env = updateServiceBindingRootEnv(env) - serviceSecretVolumeMounts = getVolumeMounts(consumedServiceInfos) - serviceSecretVolumes = getVolumes(consumedServiceInfos) + serviceSecretVolumeMounts = getServiceCredentialVolumeMounts(consumedServiceInfos) + serviceSecretVolumes = getServiceCredentialVolumes(consumedServiceInfos) } else { envFrom = getEnvFrom(vcapSecretName) } @@ -699,7 +699,7 @@ func (c *Controller) updateDeployment(ca *v1alpha1.CAPApplication, cav *v1alpha1 // Get VCAP secret name err = nil - if !useVolumeMounts(cav) { + if !useVolumeMountsForServiceCredentials(cav) { vcapSecretName, err = createVCAPSecret(deploymentName, cav.Namespace, ownerRef, consumedServiceInfos, c.kubeClient) } @@ -724,13 +724,13 @@ func newDeployment(ca *v1alpha1.CAPApplication, cav *v1alpha1.CAPApplicationVers Env: workload.DeploymentDefinition.Env, } - if useVolumeMounts(cav) { + if useVolumeMountsForServiceCredentials(cav) { // Get ServiceInfos for consumed BTP services consumedServiceInfos := getConsumedServiceInfos(getConsumedServiceMap(workload.ConsumedBTPServices), ca.Spec.BTP.Services) params.Env = updateServiceBindingRootEnv(params.Env) - params.VolumeMounts = getVolumeMounts(consumedServiceInfos) - params.Volumes = getVolumes(consumedServiceInfos) + params.VolumeMounts = getServiceCredentialVolumeMounts(consumedServiceInfos) + params.Volumes = getServiceCredentialVolumes(consumedServiceInfos) } else { params.EnvFrom = getEnvFrom(vcapSecretName) } diff --git a/internal/controller/reconcile-captenantoperation.go b/internal/controller/reconcile-captenantoperation.go index fcf539c..52745ff 100644 --- a/internal/controller/reconcile-captenantoperation.go +++ b/internal/controller/reconcile-captenantoperation.go @@ -391,7 +391,7 @@ func (c *Controller) initiateJobForCAPTenantOperationStep(ctx context.Context, c consumedServiceInfos := getConsumedServiceInfos(getConsumedServiceMap(workload.ConsumedBTPServices), relatedResources.CAPApplication.Spec.BTP.Services) // check volume mount annotation - useVolumeMount := useVolumeMounts(relatedResources.CAPApplicationVersion) + useVolumeMount := useVolumeMountsForServiceCredentials(relatedResources.CAPApplicationVersion) // create VCAP secret from consumed BTP services var vcapSecretName string @@ -442,8 +442,8 @@ func (c *Controller) initiateJobForCAPTenantOperationStep(ctx context.Context, c if useVolumeMount { params.Env = updateServiceBindingRootEnv(params.Env) - params.volumeMounts = getVolumeMounts(consumedServiceInfos) - params.volumes = getVolumes(consumedServiceInfos) + params.volumeMounts = getServiceCredentialVolumeMounts(consumedServiceInfos) + params.volumes = getServiceCredentialVolumes(consumedServiceInfos) } else { params.EnvFrom = getEnvFrom(vcapSecretName) } diff --git a/internal/controller/reconcile.go b/internal/controller/reconcile.go index bf1a724..8d0c390 100644 --- a/internal/controller/reconcile.go +++ b/internal/controller/reconcile.go @@ -50,7 +50,7 @@ const ( AnnotationSubscriptionContextSecret = "sme.sap.com/subscription-context-secret" AnnotationProviderSubAccountId = "sme.sap.com/provider-sub-account-id" AnnotationEnableCleanupMonitoring = "sme.sap.com/enable-cleanup-monitoring" - AnnotationUseVolumeMount = "sme.sap.com/use-credential-volume-mount" + AnnotationUseCredentialVolumeMount = "sme.sap.com/use-credential-volume-mount" FinalizerCAPApplication = "sme.sap.com/capapplication" FinalizerCAPApplicationVersion = "sme.sap.com/capapplicationversion" FinalizerCAPTenant = "sme.sap.com/captenant" @@ -621,7 +621,7 @@ func getWorkloadName(cavName, workloadName string) string { return fmt.Sprintf("%s-%s", cavName, strings.ToLower(workloadName)) } -func getVolumeMounts(serviceInfos []v1alpha1.ServiceInfo) []corev1.VolumeMount { +func getServiceCredentialVolumeMounts(serviceInfos []v1alpha1.ServiceInfo) []corev1.VolumeMount { volumeMounts := []corev1.VolumeMount{} for _, serviceInfo := range serviceInfos { volumeMounts = append(volumeMounts, corev1.VolumeMount{Name: serviceInfo.Name, MountPath: path.Join(defaultServiceBindingRootEnv.Value, serviceInfo.Class), ReadOnly: true}) @@ -629,7 +629,7 @@ func getVolumeMounts(serviceInfos []v1alpha1.ServiceInfo) []corev1.VolumeMount { return volumeMounts } -func getVolumes(serviceInfos []v1alpha1.ServiceInfo) []corev1.Volume { +func getServiceCredentialVolumes(serviceInfos []v1alpha1.ServiceInfo) []corev1.Volume { volumes := []corev1.Volume{} for _, serviceInfo := range serviceInfos { volumes = append(volumes, corev1.Volume{Name: serviceInfo.Name, VolumeSource: corev1.VolumeSource{Secret: &corev1.SecretVolumeSource{SecretName: serviceInfo.Secret}}}) @@ -637,8 +637,8 @@ func getVolumes(serviceInfos []v1alpha1.ServiceInfo) []corev1.Volume { return volumes } -func useVolumeMounts(cav *v1alpha1.CAPApplicationVersion) bool { - value, exists := cav.Annotations[AnnotationUseVolumeMount] +func useVolumeMountsForServiceCredentials(cav *v1alpha1.CAPApplicationVersion) bool { + value, exists := cav.Annotations[AnnotationUseCredentialVolumeMount] return exists && value == "true" }