changes to support cluster proxy config

This commit is contained in:
niravparikh05
2022-04-14 17:01:05 +05:30
parent e7d436a232
commit 4b6cc8f8fe

View File

@@ -119,12 +119,6 @@ func (s *clusterService) Create(ctx context.Context, cluster *infrav3.Cluster) (
return &infrav3.Cluster{}, err
}
/*reqAuth, err := c.requestAuth(r, ctx, ps)
if err != nil {
http.Error(w, err.Error(), http.StatusUnauthorized)
returnrequestAuth
}*/
if cluster.Metadata.Name == "" {
return &infrav3.Cluster{}, fmt.Errorf("invalid cluster data, name is missing")
}
@@ -237,6 +231,11 @@ func (s *clusterService) Create(ctx context.Context, cluster *infrav3.Cluster) (
cluster.Spec.ClusterData.Health = infrav3.Health_EDGE_IGNORE
if cluster.Spec.Params != nil {
prmssByts, _ := json.Marshal(cluster.Spec.Params)
edb.Extra = json.RawMessage(prmssByts)
}
tx, err := s.db.BeginTx(ctx, &sql.TxOptions{})
if err != nil {
return &infrav3.Cluster{}, err
@@ -435,6 +434,10 @@ func (s *clusterService) prepareClusterResponse(ctx context.Context, clstr *infr
if c.ProxyConfig != nil {
json.Unmarshal(c.ProxyConfig, &proxy)
}
var params infrav3.ProvisionParams
if c.Extra != nil {
json.Unmarshal(c.Extra, &params)
}
var pcs []*infrav3.ProjectCluster
if len(projects) > 0 {
pcs = make([]*infrav3.ProjectCluster, len(projects)-1)
@@ -454,6 +457,7 @@ func (s *clusterService) prepareClusterResponse(ctx context.Context, clstr *infr
OverrideSelector: c.OverrideSelector,
ShareMode: infrav3.ClusterShareMode(sm),
ProxyConfig: &proxy,
Params: &params,
ClusterData: &infrav3.ClusterData{
ClusterBlueprint: c.BlueprintRef,
Projects: pcs,
@@ -558,6 +562,11 @@ func (s *clusterService) Update(ctx context.Context, cluster *infrav3.Cluster) (
cdb.ProxyConfig = json.RawMessage(pcfgsByts)
}
if cluster.Spec.Params != nil {
prmsByts, _ := json.Marshal(cluster.Spec.Params)
cdb.Extra = json.RawMessage(prmsByts)
}
if cluster.Spec.ClusterData != nil {
cdb.BlueprintRef = cluster.Spec.ClusterData.ClusterBlueprint
if cluster.Spec.ClusterData.ClusterStatus != nil {