Skip to content

Commit

Permalink
PLT-185:Added Host config and fixed update operation (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
SivaanandM authored Dec 27, 2022
1 parent 10f4ef6 commit c169d2c
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions spectrocloud/resource_cluster_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ func toClusterGroup(d *schema.ResourceData) *models.V1ClusterGroupEntity {
endpointType = resources["host_endpoint_type"].(string)
}
}
var hostClusterConfig []*models.V1ClusterGroupHostClusterConfig
if endpointType == "Ingress" {
hostClusterConfig = toHostClusterConfigs(clusterRefObj.([]interface{}))
}

ret := &models.V1ClusterGroupEntity{
Metadata: &models.V1ObjectMeta{
Expand All @@ -279,15 +283,33 @@ func toClusterGroup(d *schema.ResourceData) *models.V1ClusterGroupEntity {
Type: "hostCluster",
ClusterRefs: clusterRefs,
ClustersConfig: &models.V1ClusterGroupClustersConfig{
EndpointType: endpointType,
LimitConfig: clusterGroupLimitConfig,
EndpointType: endpointType,
LimitConfig: clusterGroupLimitConfig,
HostClustersConfig: hostClusterConfig,
},
},
}

return ret
}

func toHostClusterConfigs(clusterConfig []interface{}) []*models.V1ClusterGroupHostClusterConfig {
var hostClusterConfigs []*models.V1ClusterGroupHostClusterConfig
for _, obj := range clusterConfig {
resources := obj.(map[string]interface{})
hostCluster := &models.V1ClusterGroupHostClusterConfig{
ClusterUID: resources["cluster_uid"].(string),
EndpointConfig: &models.V1HostClusterEndpointConfig{
IngressConfig: &models.V1IngressConfig{
Host: resources["host_dns"].(string),
},
},
}
hostClusterConfigs = append(hostClusterConfigs, hostCluster)
}
return hostClusterConfigs
}

func toClusterGroupUpdate(clusterGroupEntity *models.V1ClusterGroupEntity) *models.V1ClusterGroupHostClusterEntity {
ret := &models.V1ClusterGroupHostClusterEntity{
ClusterRefs: clusterGroupEntity.Spec.ClusterRefs,
Expand Down

0 comments on commit c169d2c

Please sign in to comment.