From 4b6cc8f8fee791fefc0c586935050e673d19fb05 Mon Sep 17 00:00:00 2001 From: niravparikh05 Date: Thu, 14 Apr 2022 17:01:05 +0530 Subject: [PATCH] changes to support cluster proxy config --- pkg/service/cluster.go | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/pkg/service/cluster.go b/pkg/service/cluster.go index 28cd578..7eeab0c 100644 --- a/pkg/service/cluster.go +++ b/pkg/service/cluster.go @@ -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, ¶ms) + } 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: ¶ms, 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 {