Skip to content

Commit 1b14679

Browse files
committed
Externalize consts
Signed-off-by: Matheus Cruz <[email protected]>
1 parent b2d1c5d commit 1b14679

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

workspaces/controller/internal/controller/workspace_controller.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ const (
7878
stateMsgRunning = "Workspace is running"
7979
stateMsgTerminating = "Workspace is terminating"
8080
stateMsgUnknown = "Workspace is in an unknown state"
81+
82+
IstioHost = "ISTIO_HOST"
83+
IstioGateway = "ISTIO_GATEWAY"
84+
ClusterDomain = "CLUSTER_DOMAIN"
8185
)
8286

8387
// WorkspaceReconciler reconciles a Workspace object
@@ -1037,13 +1041,13 @@ func GenerateIstioVirtualService(workspace *kubefloworgv1beta1.Workspace, worksp
10371041
virtualService.SetNamespace(workspace.Namespace)
10381042

10391043
// .spec.gateways
1040-
istioGateway := getEnvOrDefault("ISTIO_GATEWAY", "kubeflow/kubeflow-gateway")
1044+
istioGateway := getEnvOrDefault(IstioGateway, "kubeflow/kubeflow-gateway")
10411045
if err := unstructured.SetNestedStringSlice(virtualService.Object, []string{istioGateway},
10421046
"spec", "gateways"); err != nil {
10431047
return nil, fmt.Errorf("set .spec.gateways error: %v", err)
10441048
}
10451049

1046-
istioHost := getEnvOrDefault("ISTIO_HOST", "*")
1050+
istioHost := getEnvOrDefault(IstioHost, "*")
10471051
if err := unstructured.SetNestedStringSlice(virtualService.Object, []string{istioHost},
10481052
"spec", "gateways"); err != nil {
10491053
return nil, fmt.Errorf("set .spec.hosts error: %v", err)
@@ -1057,7 +1061,7 @@ func GenerateIstioVirtualService(workspace *kubefloworgv1beta1.Workspace, worksp
10571061

10581062
var httpRoutes []interface{}
10591063

1060-
host := fmt.Sprintf("%s.%s.svc.%s", serviceName, workspace.Namespace, getEnvOrDefault("CLUSTER_DOMAIN", "cluster.local"))
1064+
host := fmt.Sprintf("%s.%s.svc.%s", serviceName, workspace.Namespace, getEnvOrDefault(ClusterDomain, "cluster.local"))
10611065

10621066
// generate container ports
10631067
// TODO: It can be better

workspaces/controller/internal/helper/conts.go

-1
This file was deleted.

0 commit comments

Comments
 (0)