Skip to content

Commit

Permalink
test the service
Browse files Browse the repository at this point in the history
  • Loading branch information
indresh-28 committed Nov 24, 2023
1 parent 96db7e8 commit c8bcefc
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions capten/agent/internal/crossplane/cluster_claims.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (h *ClusterClaimSyncHandler) Sync() error {
}

func (h *ClusterClaimSyncHandler) updateManagedClusters(clusterCliams []model.ClusterClaim) error {
k8sclient, err := k8s.NewK8SClient(h.log)
_, err := k8s.NewK8SClient(h.log)
if err != nil {
return fmt.Errorf("failed to get k8s client, %v", err)
}
Expand Down Expand Up @@ -180,19 +180,20 @@ func (h *ClusterClaimSyncHandler) updateManagedClusters(clusterCliams []model.Cl
managedCluster.ClusterDeployStatus = clusterObj.ClusterDeployStatus
}

if status.Status == readyStatusValue {
secretName := fmt.Sprintf(clusterSecretName, clusterCliam.Spec.Id)
resp, err := k8sclient.GetSecretData(clusterCliam.Metadata.Namespace, secretName)
if err != nil {
h.log.Errorf("failed to get secret %s/%s, %v", clusterCliam.Metadata.Namespace, secretName, err)
continue
}
if status.Status != readyStatusValue {
// secretName := fmt.Sprintf(clusterSecretName, clusterCliam.Spec.Id)
// resp, err := k8sclient.GetSecretData(clusterCliam.Metadata.Namespace, secretName)
// if err != nil {
// h.log.Errorf("failed to get secret %s/%s, %v", clusterCliam.Metadata.Namespace, secretName, err)
// continue
// }

clusterEndpoint := resp.Data[k8sEndpoint]
resp := map[string]string{}
clusterEndpoint := resp[k8sEndpoint]
managedCluster.ClusterEndpoint = clusterEndpoint
cred := map[string]string{}
cred[kubeConfig] = resp.Data[kubeConfig]
cred[k8sClusterCA] = resp.Data[k8sClusterCA]
cred[kubeConfig] = resp[kubeConfig]
cred[k8sClusterCA] = resp[k8sClusterCA]
cred[k8sEndpoint] = clusterEndpoint

err = credential.PutGenericCredential(context.TODO(), managedClusterEntityName, managedCluster.Id, cred)
Expand All @@ -203,7 +204,7 @@ func (h *ClusterClaimSyncHandler) updateManagedClusters(clusterCliams []model.Cl

managedCluster.ClusterDeployStatus = clusterReadyStatus
// call config-worker.
err = h.UpdateClusterEndpoint(managedCluster.Id, clusterCliam.Metadata.Namespace, clusterCliam.Spec.Id, clusterEndpoint, resp.Data[kubeConfig])
err = h.UpdateClusterEndpoint(managedCluster.Id, clusterCliam.Metadata.Namespace, clusterCliam.Spec.Id, clusterEndpoint, resp[kubeConfig])
if err != nil {
h.log.Info("failed to update cluster endpoint information %v", err)
continue
Expand Down

0 comments on commit c8bcefc

Please sign in to comment.