Commit b4424cb2 authored by Vasilis Katopodis's avatar Vasilis Katopodis
Browse files

refactor: remove namespaceResourceQuota from helm deploy response

parent 4daf0c3c
Loading
Loading
Loading
Loading
Loading
+0 −1
Changes for README.md: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -173,7 +173,6 @@ Upon success, the handler publishes to `helm-engine-deploy-result`:
    "serviceEndpoints": [
      { "ip": "10.0.2.4", "port": 8080 }
    ],
    "namespaceResourceQuota": "",
    "defaultValuesYaml": "<base64-encoded default values.yaml>"
  }
}
+0 −1
Changes for datamodel/helmDeploy.go: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ type HelmDeployResponse struct {
	K8sIpAddress           string            `json:"k8sIpAddress"`
	ServiceNamespaces      []string          `json:"serviceNamespaces,omitempty"`
	ServiceEndpoints       []ServiceEndpoint `json:"serviceEndpoints,omitempty"`
	NamespaceResourceQuota string            `json:"namespaceResourceQuota,omitempty"`
	DefaultValuesYaml      string            `json:"defaultValuesYaml,omitempty"`
}

+0 −15
Changes for kubernetes/kubernetes.go: 0 added lines, 15 removed lines.
Original line number Diff line number Diff line
@@ -111,21 +111,6 @@ func (client *KubernetesClient) GetServiceEndpoints(namespace string) ([]datamod
	return endpoints, nil
}

func (client *KubernetesClient) GetResourceQuota(namespace string) (string, error) {
	resourceQuotas, err := client.CoreV1().ResourceQuotas(namespace).List(context.TODO(), metav1.ListOptions{})
	if err != nil {
		return "", fmt.Errorf("error listing resource quotas: %w", err)
	}
	if len(resourceQuotas.Items) == 0 {
		return "", nil
	}
	resourceQuotaJSON, err := json.MarshalIndent(resourceQuotas.Items[0], "", "  ")
	if err != nil {
		return "", fmt.Errorf("error converting resource quota to JSON: %w", err)
	}
	return string(resourceQuotaJSON), nil
}

func (client *KubernetesClient) ProcessImagePullSecrets(namespace string, secrets []*registryapi.ImagePullSecret) error {
	client.Log.Debug("%s msg=\"Processing image pull secrets for target namespace: %s\"", client.ContextTag, namespace)

+0 −19
Changes for ops/helm_ops.go: 0 added lines, 19 removed lines.
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ type BaseContext struct {

type DeploymentDetails struct {
	Namespace         []string
	NamespaceResourceQuota string
	ServiceEndpoints  []datamodel.ServiceEndpoint
	DefaultValuesYaml string
}
@@ -84,14 +83,7 @@ func getDeploymentDetails(log logging.Logger, serviceID string, kubeconfigBytes
		return nil, err
	}

	log.Debug("service_id=%s msg=\"Fetching Resource Quota for namespace: %s\"", serviceID, namespace)
	resourceQuota, err := getResourceQuota(kubernetesClient, namespace)
	if err != nil {
		return nil, err
	}

	deploymentDetails := &DeploymentDetails{
		NamespaceResourceQuota: resourceQuota,
		ServiceEndpoints: serviceEndpoints,
	}

@@ -107,14 +99,12 @@ func emitDeploymentResponse(log logging.Logger, traceCtx context.Context, ctx go

	log.Debug("service_id=%s msg=\"Preparing HelmDeployResponse. Target State: %s, Target Topic: %s\"", serviceID, state, deployCtx.OutputStreamTopic)

	var namespaceResourceQuota string
	var namespace []string
	var endpoints []datamodel.ServiceEndpoint
	var defaultValuesYaml string

	if deployCtx.Details != nil {
		namespace = deployCtx.Details.Namespace
		namespaceResourceQuota = deployCtx.Details.NamespaceResourceQuota
		endpoints = deployCtx.Details.ServiceEndpoints
		defaultValuesYaml = deployCtx.Details.DefaultValuesYaml
	}
@@ -129,7 +119,6 @@ func emitDeploymentResponse(log logging.Logger, traceCtx context.Context, ctx go
		K8sIpAddress:           deployCtx.K8sIpAddress,
		ServiceNamespaces:      namespace,
		ServiceEndpoints:       endpoints,
		NamespaceResourceQuota: namespaceResourceQuota,
		DefaultValuesYaml:      defaultValuesYaml,
	}

@@ -210,11 +199,3 @@ func getServiceEndpoints(kubernetesClient *kubernetes.KubernetesClient, namespac
	}
	return serviceEndpoints, nil
}

func getResourceQuota(kubernetesClient *kubernetes.KubernetesClient, namespace string) (string, error) {
	resourceQuota, err := kubernetesClient.GetResourceQuota(namespace)
	if err != nil {
		return "", fmt.Errorf("error getting the namespace's ResourseQuota %s: %w", namespace, err)
	}
	return resourceQuota, nil
}