Skip to content

Commit

Permalink
Removing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mayleighnmyers committed Jun 13, 2024
1 parent f43ecc0 commit 5418648
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1,645 deletions.
93 changes: 0 additions & 93 deletions pkg/apis/maistra/conversion/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,101 +390,8 @@ func populateClusterConfig(in *v1.HelmValues, out *v2.ControlPlaneSpec) error {
} else if err != nil {
return err
}

// patchup gateways
if rawMultiClusterOverrides, ok, err := in.GetMap("global.multiCluster.multiClusterOverrides"); ok && len(rawMultiClusterOverrides) > 0 {
multiClusterOverrides := v1.NewHelmValues(rawMultiClusterOverrides)
if addedExternal, ok, err := multiClusterOverrides.GetAndRemoveBool("addedExternal"); ok && addedExternal {
} else if err != nil {
return nil
}
} else if err != nil {
return err
}
in.RemoveField("global.multiCluster.multiClusterOverrides")

// multi-cluster
multiCluster := &v2.MultiClusterConfig{}
setMultiCluster := false
if multiClusterEnabled, ok, err := in.GetAndRemoveBool("global.multiCluster.enabled"); ok {
multiCluster.Enabled = &multiClusterEnabled
setMultiCluster = true
} else if err != nil {
return err
}
if rawMeshNetworks, ok, err := in.GetMap("global.meshNetworks"); ok && len(rawMeshNetworks) > 0 {
multiCluster.MeshNetworks = make(map[string]v2.MeshNetworkConfig)
if err := decodeAndRemoveFromValues(rawMeshNetworks, &multiCluster.MeshNetworks); err != nil {
return err
}
if len(rawMeshNetworks) == 0 {
in.RemoveField("global.meshNetworks")
} else if err := in.SetField("global.meshNetworks", rawMeshNetworks); err != nil {
return err
}
// remove defaulted mesh network
if addedLocalNetwork, ok, err := in.GetAndRemoveString("global.multiCluster.addedLocalNetwork"); ok {
delete(multiCluster.MeshNetworks, addedLocalNetwork)
} else if err != nil {
return nil
}
if len(multiCluster.MeshNetworks) == 0 {
multiCluster.MeshNetworks = nil
} else {
setMultiCluster = true
}
} else if err != nil {
return err
}

if setMultiCluster {
clusterConfig.MultiCluster = multiCluster
setClusterConfig = true
}

meshExpansionConfig := &v2.MeshExpansionConfig{}
setMeshExpansion := false
if expansionEnabled, ok, err := in.GetAndRemoveBool("global.meshExpansion.enabled"); ok {
setMeshExpansion = true
meshExpansionConfig.Enabled = &expansionEnabled
} else if err != nil {
return err
}
if ilbGatewayValues, ok, err := in.GetMap("gateways.istio-ilbgateway"); ok && len(ilbGatewayValues) > 0 {
in.RemoveField("gateways.istio-ilbgateway")
setMeshExpansion = true
meshExpansionConfig.ILBGateway = &v2.GatewayConfig{}
if err := gatewayValuesToConfig(v1.NewHelmValues(ilbGatewayValues), meshExpansionConfig.ILBGateway); err != nil {
return err
}
} else if err != nil {
return err
}

if setMeshExpansion {
clusterConfig.MeshExpansion = meshExpansionConfig
setClusterConfig = true
}

// clear out defaults
in.RemoveField("gateways.istio-ilbgateway.enabled")
in.RemoveField("global.meshExpansion.enabled")
in.RemoveField("global.meshExpansion.useILB")

if setClusterConfig {
out.Cluster = clusterConfig
}

return nil
}

func shouldDeleteGatewayValues(gateway map[string]interface{}) bool {
minGatewaySize := 0
if _, ok := gateway["name"]; ok {
minGatewaySize++
}
if _, ok := gateway["gatewayType"]; ok {
minGatewaySize++
}
return len(gateway) == minGatewaySize
}
Loading

0 comments on commit 5418648

Please sign in to comment.