Skip to content

Commit

Permalink
Request enabled should be treated as true if not set in request (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
berkayoz authored Mar 4, 2024
1 parent bbc49b5 commit b81e215
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/k8s/pkg/component/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func DisableDNSComponent(ctx context.Context, s snap.Snap) error {
}

func ReconcileDNSComponent(ctx context.Context, s snap.Snap, alreadyEnabled *bool, requestEnabled *bool, clusterConfig types.ClusterConfig) (string, string, error) {
if vals.OptionalBool(requestEnabled, false) && vals.OptionalBool(alreadyEnabled, false) {
if vals.OptionalBool(requestEnabled, true) && vals.OptionalBool(alreadyEnabled, false) {
// If already enabled, and request does not contain `enabled` key
// or if already enabled and request contains `enabled=true`
dnsIP, clusterDomain, err := UpdateDNSComponent(ctx, s, true, clusterConfig.Kubelet.ClusterDomain, clusterConfig.Kubelet.ClusterDNS, clusterConfig.DNS.UpstreamNameservers)
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/component/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func DisableGatewayComponent(s snap.Snap) error {
}

func ReconcileGatewayComponent(ctx context.Context, s snap.Snap, alreadyEnabled *bool, requestEnabled *bool, clusterConfig types.ClusterConfig) error {
if vals.OptionalBool(requestEnabled, false) && vals.OptionalBool(alreadyEnabled, false) {
if vals.OptionalBool(requestEnabled, true) && vals.OptionalBool(alreadyEnabled, false) {
// If already enabled, and request does not contain `enabled` key
// or if already enabled and request contains `enabled=true`
err := UpdateGatewayComponent(ctx, s, true)
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/component/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func ReconcileIngressComponent(ctx context.Context, s snap.Snap, alreadyEnabled
enableProxyProtocol = *clusterConfig.Ingress.EnableProxyProtocol
}

if vals.OptionalBool(requestEnabled, false) && vals.OptionalBool(alreadyEnabled, false) {
if vals.OptionalBool(requestEnabled, true) && vals.OptionalBool(alreadyEnabled, false) {
// If already enabled, and request does not contain `enabled` key
// or if already enabled and request contains `enabled=true`
err := UpdateIngressComponent(ctx, s, true, clusterConfig.Ingress.DefaultTLSSecret, enableProxyProtocol)
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/component/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func ReconcileLoadBalancerComponent(ctx context.Context, s snap.Snap, alreadyEna
l2Enabled = *clusterConfig.LoadBalancer.L2Enabled
}

if vals.OptionalBool(requestEnabled, false) && vals.OptionalBool(alreadyEnabled, false) {
if vals.OptionalBool(requestEnabled, true) && vals.OptionalBool(alreadyEnabled, false) {
// If already enabled, and request does not contain `enabled` key
// or if already enabled and request contains `enabled=true`
err := UpdateLoadBalancerComponent(ctx, s, true, clusterConfig.LoadBalancer.CIDRs, l2Enabled, clusterConfig.LoadBalancer.L2Interfaces, bgpEnabled, clusterConfig.LoadBalancer.BGPLocalASN, clusterConfig.LoadBalancer.BGPPeerAddress, clusterConfig.LoadBalancer.BGPPeerASN, clusterConfig.LoadBalancer.BGPPeerPort)
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/component/metrics_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func DisableMetricsServerComponent(s snap.Snap) error {
}

func ReconcileMetricsServerComponent(ctx context.Context, s snap.Snap, alreadyEnabled *bool, requestEnabled *bool, clusterConfig types.ClusterConfig) error {
if vals.OptionalBool(requestEnabled, false) && vals.OptionalBool(alreadyEnabled, false) {
if vals.OptionalBool(requestEnabled, true) && vals.OptionalBool(alreadyEnabled, false) {
// If already enabled, and request does not contain `enabled` key
// or if already enabled and request contains `enabled=true`
err := UpdateMetricsServerComponent(ctx, s, true)
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/component/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func DisableNetworkComponent(s snap.Snap) error {
}

func ReconcileNetworkComponent(ctx context.Context, s snap.Snap, alreadyEnabled *bool, requestEnabled *bool, clusterConfig types.ClusterConfig) error {
if vals.OptionalBool(requestEnabled, false) && vals.OptionalBool(alreadyEnabled, false) {
if vals.OptionalBool(requestEnabled, true) && vals.OptionalBool(alreadyEnabled, false) {
// If already enabled, and request does not contain `enabled` key
// or if already enabled and request contains `enabled=true`
err := UpdateNetworkComponent(ctx, s, true, clusterConfig.Network.PodCIDR)
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/component/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func ReconcileLocalStorageComponent(ctx context.Context, s snap.Snap, alreadyEna
setDefault = *clusterConfig.LocalStorage.SetDefault
}

if vals.OptionalBool(requestEnabled, false) && vals.OptionalBool(alreadyEnabled, false) {
if vals.OptionalBool(requestEnabled, true) && vals.OptionalBool(alreadyEnabled, false) {
// If already enabled, and request does not contain `enabled` key
// or if already enabled and request contains `enabled=true`
err := UpdateStorageComponent(ctx, s, true, clusterConfig.LocalStorage.LocalPath, clusterConfig.LocalStorage.ReclaimPolicy, setDefault)
Expand Down

0 comments on commit b81e215

Please sign in to comment.