Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ func Read() (HCCMConfiguration, error) {
if err != nil {
errs = append(errs, err)
}
cfg.LoadBalancer.Location = os.Getenv(hcloudLoadBalancersLocation)
cfg.LoadBalancer.NetworkZone = os.Getenv(hcloudLoadBalancersNetworkZone)
cfg.LoadBalancer.Location = os.Getenv(HcloudLoadBalancersLocation)
cfg.LoadBalancer.NetworkZone = os.Getenv(HcloudLoadBalancersNetworkZone)

disablePrivateIngress, err := getEnvBool(hcloudLoadBalancersDisablePrivateIngress, false)
if err != nil {
Expand Down Expand Up @@ -317,7 +317,7 @@ func (c HCCMConfiguration) Validate() (err error) {
}

if c.LoadBalancer.Location != "" && c.LoadBalancer.NetworkZone != "" {
errs = append(errs, fmt.Errorf("invalid value for %q/%q, only one of them can be set", hcloudLoadBalancersLocation, hcloudLoadBalancersNetworkZone))
errs = append(errs, fmt.Errorf("invalid value for %q/%q, only one of them can be set", HcloudLoadBalancersLocation, HcloudLoadBalancersNetworkZone))
}

if c.LoadBalancer.PrivateSubnetIPRange != "" {
Expand Down
12 changes: 6 additions & 6 deletions internal/config/load_balancer_envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ const (
// Default: true
hcloudLoadBalancersEnabled = "HCLOUD_LOAD_BALANCERS_ENABLED"

// hcloudLoadBalancersLocation specifies the default location where the Load Balancer will be
// HcloudLoadBalancersLocation specifies the default location where the Load Balancer will be
// created in.
//
// Mutually exclusive with [hcloudLoadBalancersNetworkZone].
// Mutually exclusive with [HcloudLoadBalancersNetworkZone].
//
// Type: string
hcloudLoadBalancersLocation = "HCLOUD_LOAD_BALANCERS_LOCATION"
HcloudLoadBalancersLocation = "HCLOUD_LOAD_BALANCERS_LOCATION"

// hcloudLoadBalancersNetworkZone specifies the default network zone where the Load Balancer will be
// HcloudLoadBalancersNetworkZone specifies the default network zone where the Load Balancer will be
// created in.
//
// Mutually exclusive with [hcloudLoadBalancersLocation].
// Mutually exclusive with [HcloudLoadBalancersLocation].
//
// Type: string
hcloudLoadBalancersNetworkZone = "HCLOUD_LOAD_BALANCERS_NETWORK_ZONE"
HcloudLoadBalancersNetworkZone = "HCLOUD_LOAD_BALANCERS_NETWORK_ZONE"

// hcloudLoadBalancersDisablePrivateIngress disables the use of the private network for ingress by default.
//
Expand Down
9 changes: 8 additions & 1 deletion internal/hcops/load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,14 @@ func (l *LoadBalancerOps) Create(
metrics.OperationCalled.WithLabelValues(op).Inc()

if spec.Location == "" && spec.NetworkZone == "" {
return nil, fmt.Errorf("%s: neither %s nor %s set", op, annotation.LBLocation, annotation.LBNetworkZone)
return nil, fmt.Errorf(
"%s: neither %s nor %s set, set one of these annotations or cluster-wide with the environment variable %s or %s",
op,
annotation.LBLocation,
annotation.LBNetworkZone,
config.HcloudLoadBalancersLocation,
config.HcloudLoadBalancersNetworkZone,
)
}

lbType, err := l.verifyType(ctx, svc, spec)
Expand Down
9 changes: 7 additions & 2 deletions internal/hcops/load_balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,13 @@ func TestLoadBalancerOps_Create(t *testing.T) {
{
name: "fails if location and network zone missing",
serviceAnnotations: map[string]string{},
err: fmt.Errorf("hcops/LoadBalancerOps.Create: neither %s nor %s set",
annotation.LBLocation, annotation.LBNetworkZone),
err: fmt.Errorf(
"hcops/LoadBalancerOps.Create: neither %s nor %s set, set one of these annotations or cluster-wide with the environment variable %s or %s",
annotation.LBLocation,
annotation.LBNetworkZone,
config.HcloudLoadBalancersLocation,
config.HcloudLoadBalancersNetworkZone,
),
},
{
name: "gives preference to location name",
Expand Down
Loading