Skip to content

Commit 391a765

Browse files
committed
remove region env var and retrieve from config instead
1 parent 31e96fb commit 391a765

2 files changed

Lines changed: 3 additions & 12 deletions

File tree

cmd/stackit-csi-plugin/main.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,7 @@ func handle() {
103103
iaasOpts = append(iaasOpts, sdkconfig.WithEndpoint(cfg.Global.APIEndpoints.IaasAPI))
104104
}
105105

106-
region := os.Getenv("STACKIT_REGION")
107-
if region == "" {
108-
klog.Fatalf("The environment variable STACKIT_REGION must be set to the region of the cluster")
109-
}
110-
iaasClient, err := stackitclient.New(region, cfg.Global.ProjectID).IaaS(iaasOpts)
106+
iaasClient, err := stackitclient.New(cfg.Global.Region, cfg.Global.ProjectID).IaaS(iaasOpts)
111107
if err != nil {
112108
klog.Fatalf("Failed to create STACKIT stackitclient: %v", err)
113109
}

pkg/ccm/stackit.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,7 @@ func NewCloudControllerManager(cfg *stackitconfig.CCMConfig, obs *MetricsRemoteW
133133
lbOpts = append(lbOpts, sdkconfig.WithToken(lbEmergencyAPIToken))
134134
}
135135

136-
region := os.Getenv("STACKIT_REGION")
137-
if region == "" {
138-
return nil, fmt.Errorf("STACKIT_REGION environment variable must be set")
139-
}
140-
141-
loadbalancingClient, err := stackitclient.New(region, cfg.Global.ProjectID).LoadBalancing(lbOpts)
136+
loadbalancingClient, err := stackitclient.New(cfg.Global.Region, cfg.Global.ProjectID).LoadBalancing(lbOpts)
142137
if err != nil {
143138
return nil, fmt.Errorf("failed to create Load Balancing stackitclient: %v", err)
144139
}
@@ -151,7 +146,7 @@ func NewCloudControllerManager(cfg *stackitconfig.CCMConfig, obs *MetricsRemoteW
151146
iaasOpts = append(iaasOpts, sdkconfig.WithEndpoint(cfg.Global.APIEndpoints.IaasAPI))
152147
}
153148

154-
iaasClient, err := stackitclient.New(region, cfg.Global.ProjectID).IaaS(iaasOpts)
149+
iaasClient, err := stackitclient.New(cfg.Global.Region, cfg.Global.ProjectID).IaaS(iaasOpts)
155150
if err != nil {
156151
return nil, fmt.Errorf("failed to create IaaS stackitclient: %v", err)
157152
}

0 commit comments

Comments
 (0)