Skip to content

Commit

Permalink
Merge branch 'cluster-api-simple-test' of github.com:pluralsh/plural-…
Browse files Browse the repository at this point in the history
…cli into cluster-api-simple-test
  • Loading branch information
floreks committed Sep 14, 2023
2 parents da889a7 + 17895cf commit 3ca2833
Showing 1 changed file with 18 additions and 34 deletions.
52 changes: 18 additions & 34 deletions pkg/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,6 @@ import (
"github.com/pluralsh/plural/pkg/utils/capi"
)

// saveKindKubeconfig exports kind kubeconfig to file.
func saveKindKubeconfig(_ []string) error {
man, err := manifest.FetchProject()
if err != nil {
return err
}

bootstrapPath, err := GetBootstrapPath()
if err != nil {
return err
}

cmd := exec.Command("kind", "export", "kubeconfig", "--name", man.Cluster,
"--kubeconfig", filepath.Join(bootstrapPath, "terraform", "kube_config_cluster.yaml"))
return utils.Execute(cmd)
}

func enableAzureOIDCIssuer(_ []string) error {
man, err := manifest.FetchProject()
if err != nil {
return err
}

cmd := exec.Command("az", "aks", "update", "-g", man.Project, "-n", man.Cluster, "--enable-oidc-issuer")
return utils.Execute(cmd)
}

func bootstrapClusterExists() bool {
clusterName := "bootstrap"
p := cluster.NewProvider()
Expand All @@ -60,6 +33,11 @@ func getBootstrapSteps(runPlural ActionFunc, additionalFlags []string) ([]*Step,
return nil, err
}

bootstrapPath, err := GetBootstrapPath()
if err != nil {
return nil, err
}

flags := append(getBootstrapFlags(man.Provider), additionalFlags...)

prov, err := provider.GetProvider()
Expand Down Expand Up @@ -139,9 +117,13 @@ func getBootstrapSteps(runPlural ActionFunc, additionalFlags []string) ([]*Step,
Skip: man.Provider != api.ProviderKind,
},
{
Name: "Save kubeconfig",
Execute: saveKindKubeconfig,
Skip: man.Provider != api.ProviderKind,
Name: "Save kubeconfig",
Execute: func(_ []string) error {
cmd := exec.Command("kind", "export", "kubeconfig", "--name", man.Cluster,
"--kubeconfig", filepath.Join(bootstrapPath, "terraform", "kube_config_cluster.yaml"))
return utils.Execute(cmd)
},
Skip: man.Provider != api.ProviderKind,
},
{
Name: "Wait for machine pools",
Expand All @@ -157,17 +139,19 @@ func getBootstrapSteps(runPlural ActionFunc, additionalFlags []string) ([]*Step,

err := capi.SaveMoveBackup(options)
if err != nil {
capi.RemoveStateBackup()
_ = capi.RemoveStateBackup()
utils.Error("error during saving state backup: %s", err)
}
},
},
{
// TODO: Once https://github.com/kubernetes-sigs/cluster-api-provider-azure/issues/2498
// will be done we can use it and remove this step.
Name: "Enable OIDC issuer",
Execute: enableAzureOIDCIssuer,
Skip: man.Provider != api.ProviderAzure,
Name: "Enable OIDC issuer",
Execute: func(_ []string) error {
return utils.Exec("az", "aks", "update", "-g", man.Project, "-n", man.Cluster, "--enable-oidc-issuer")
},
Skip: man.Provider != api.ProviderAzure,
},
{
Name: "Initialize kubeconfig for target cluster",
Expand Down

0 comments on commit 3ca2833

Please sign in to comment.