diff --git a/internal/controller/kms.go b/internal/controller/kms.go index 416f9fa9..f536bfcc 100644 --- a/internal/controller/kms.go +++ b/internal/controller/kms.go @@ -50,7 +50,7 @@ func (clctrl *ClusterController) DetokenizeKMSKeyID() error { } if err := pkg.ReplaceFileContent( - fmt.Sprintf("%s/%s/%s/components/vault/application.yaml", clctrl.ProviderConfig.GitopsDir, registryPath, clctrl.ClusterName), + fmt.Sprintf("%s/%s/components/vault/application.yaml", clctrl.ProviderConfig.GitopsDir, registryPath), "", awsKmsKeyId, ); err != nil { diff --git a/internal/controller/kubefirst.go b/internal/controller/kubefirst.go index b3ebdebf..c43ad34b 100644 --- a/internal/controller/kubefirst.go +++ b/internal/controller/kubefirst.go @@ -27,6 +27,7 @@ func (clctrl *ClusterController) ExportClusterRecord() error { cluster, err := clctrl.MdbCl.GetCluster(clctrl.ClusterName) if err != nil { log.Errorf("Error exporting cluster record: %s", err) + clctrl.HandleError(err.Error()) return err } @@ -40,6 +41,9 @@ func (clctrl *ClusterController) ExportClusterRecord() error { err = runtime.IsAppAvailable(fmt.Sprintf("%s/api/proxyHealth", consoleCloudUrl), "kubefirst api") if err != nil { log.Error("unable to start kubefirst api") + + clctrl.HandleError(err.Error()) + return err } requestObject := pkgtypes.ProxyImportRequest{ @@ -52,12 +56,14 @@ func (clctrl *ClusterController) ExportClusterRecord() error { payload, err := json.Marshal(requestObject) if err != nil { + clctrl.HandleError(err.Error()) return err } req, err := http.NewRequest(http.MethodPost, fmt.Sprintf("%s/api/proxy", consoleCloudUrl), bytes.NewReader(payload)) if err != nil { log.Errorf("error %s", err) + clctrl.HandleError(err.Error()) return err } req.Header.Add("Content-Type", "application/json") @@ -71,15 +77,14 @@ func (clctrl *ClusterController) ExportClusterRecord() error { if res.StatusCode != http.StatusOK { log.Errorf("unable to import cluster %s", res.Status) + clctrl.HandleError(err.Error()) return errors.New(fmt.Sprintf("unable to import cluster %s", res.Status)) } - body, err := io.ReadAll(res.Body) + _, err = io.ReadAll(res.Body) if err != nil { return err } - log.Infof("Import: %s", string(body)) - return nil } diff --git a/internal/controller/state.go b/internal/controller/state.go index c5defbcd..52d44e4f 100644 --- a/internal/controller/state.go +++ b/internal/controller/state.go @@ -62,11 +62,15 @@ func (clctrl *ClusterController) StateStoreCredentials() error { stateStoreData = pkgtypes.StateStoreCredentials{ AccessKeyID: clctrl.AWSAuth.AccessKeyID, SecretAccessKey: clctrl.AWSAuth.SecretAccessKey, + SessionToken: clctrl.AWSAuth.SessionToken, + Name: clctrl.KubefirstStateStoreBucketName, } err = clctrl.MdbCl.UpdateCluster(clctrl.ClusterName, "state_store_details", pkgtypes.StateStoreDetails{ AWSStateStoreBucket: strings.ReplaceAll(*kubefirstStateStoreBucket.Location, "/", ""), AWSArtifactsBucket: strings.ReplaceAll(*kubefirstArtifactsBucket.Location, "/", ""), + Hostname: "s3.amazonaws.com", + Name: clctrl.KubefirstStateStoreBucketName, }) if err != nil { return err diff --git a/providers/civo/create.go b/providers/civo/create.go index 96318917..c87c3dd5 100644 --- a/providers/civo/create.go +++ b/providers/civo/create.go @@ -208,6 +208,7 @@ func CreateCivoCluster(definition *pkgtypes.ClusterDefinition) error { err = ctrl.ExportClusterRecord() if err != nil { log.Errorf("Error exporting cluster record: %s", err) + ctrl.HandleError(err.Error()) return err } else { err = ctrl.MdbCl.UpdateCluster(ctrl.ClusterName, "status", constants.ClusterStatusProvisioned)