Skip to content

Commit

Permalink
fix: cloudflare token, error handling for cluster creation
Browse files Browse the repository at this point in the history
  • Loading branch information
CristhianF7 committed Oct 26, 2023
1 parent 155d030 commit 4b7ee62
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions internal/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ func CreateCluster(cluster apiTypes.ClusterDefinition) error {
return err
}

if res.StatusCode != http.StatusOK {
log.Info().Msgf("unable to create cluster %s", res.Status)
return err
}

body, err := io.ReadAll(res.Body)
if err != nil {
log.Info().Msgf("unable to create cluster %s", err)

return err
}

if res.StatusCode != http.StatusOK {
log.Info().Msgf("unable to create cluster %s %s", res.Status, body)
return fmt.Errorf("unable to create cluster %s %s", res.Status, body)
}

log.Info().Msgf("Created cluster: %s", string(body))

return nil
Expand Down
3 changes: 2 additions & 1 deletion internal/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func Destroy(cmd *cobra.Command, args []string) error {
// Determine if there are active instal ls
gitProvider := viper.GetString("flags.git-provider")
gitProtocol := viper.GetString("flags.git-protocol")
cloudProvider := viper.GetString("kubefirst.cloud-provider")

log.Info().Msg("destroying kubefirst platform")

Expand Down Expand Up @@ -177,7 +178,7 @@ func Destroy(cmd *cobra.Command, args []string) error {
#### :tada: Success` + "`Your K3D kubefirst platform has been destroyed.`" + `
### :blue_book: To delete a management cluster please see documentation:
https://docs.kubefirst.io/aws/deprovision
https://docs.kubefirst.io/` + cloudProvider + `/deprovision
`

progress.Success(successMessage)
Expand Down
4 changes: 2 additions & 2 deletions internal/provision/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ func CreateMgmtCluster(gitAuth runtimeTypes.GitAuth, cliFlags types.CliFlags) {
}

if !clusterCreated.InProgress {
err := cluster.CreateCluster(clusterRecord)
err = cluster.CreateCluster(clusterRecord)
if err != nil {
progress.Error("Unable to create the cluster")
progress.Error(err.Error())
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/utilities/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func CreateClusterDefinitionRecordFromRaw(gitAuth apiTypes.GitAuth, cliFlags typ
PrivateKey: viper.GetString("kbot.private-key"),
},
CloudflareAuth: apiTypes.CloudflareAuth{
Token: os.Getenv("CF_API_TOKEN"),
APIToken: os.Getenv("CF_API_TOKEN"),
},
}

Expand Down

0 comments on commit 4b7ee62

Please sign in to comment.