1
0
mirror of https://github.com/openshift/installer.git synced 2026-02-05 15:47:14 +01:00

Move common code into NewCluster() method

This commit is contained in:
Pawan Pinjarkar
2024-06-24 11:52:26 -04:00
parent b96feb6666
commit 47edd6afcb
4 changed files with 10 additions and 17 deletions

View File

@@ -71,13 +71,8 @@ func newWaitForBootstrapCompleteCmd() *cobra.Command {
logrus.Fatal(err)
}
authToken, err := agentpkg.FindAuthTokenFromAssetStore(assetDir)
if err != nil {
logrus.Fatal(err)
}
ctx := context.Background()
cluster, err := agentpkg.NewCluster(ctx, assetDir, rendezvousIP, kubeconfigPath, sshKey, authToken, workflow.AgentWorkflowTypeInstall)
cluster, err := agentpkg.NewCluster(ctx, assetDir, rendezvousIP, kubeconfigPath, sshKey, workflow.AgentWorkflowTypeInstall)
if err != nil {
logrus.Exit(exitCodeBootstrapFailed)
}
@@ -111,13 +106,8 @@ func newWaitForInstallCompleteCmd() *cobra.Command {
logrus.Fatal(err)
}
authToken, err := agentpkg.FindAuthTokenFromAssetStore(assetDir)
if err != nil {
logrus.Fatal(err)
}
ctx := context.Background()
cluster, err := agentpkg.NewCluster(ctx, assetDir, rendezvousIP, kubeconfigPath, sshKey, authToken, workflow.AgentWorkflowTypeInstall)
cluster, err := agentpkg.NewCluster(ctx, assetDir, rendezvousIP, kubeconfigPath, sshKey, workflow.AgentWorkflowTypeInstall)
if err != nil {
logrus.Exit(exitCodeBootstrapFailed)
}

3
go.mod
View File

@@ -42,7 +42,7 @@ require (
github.com/diskfs/go-diskfs v1.4.0
github.com/form3tech-oss/jwt-go v3.2.3+incompatible
github.com/go-openapi/errors v0.22.0
github.com/go-openapi/runtime v0.26.2
github.com/go-openapi/runtime v0.28.0
github.com/go-openapi/strfmt v0.23.0
github.com/go-openapi/swag v0.23.0
github.com/go-playground/validator/v10 v10.19.0
@@ -178,7 +178,6 @@ require (
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/loads v0.22.0 // indirect
github.com/go-openapi/runtime v0.28.0 // indirect
github.com/go-openapi/spec v0.21.0 // indirect
github.com/go-openapi/validate v0.24.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect

View File

@@ -66,10 +66,15 @@ type clusterInstallStatusHistory struct {
}
// NewCluster initializes a Cluster object
func NewCluster(ctx context.Context, assetDir, rendezvousIP, kubeconfigPath, sshKey, authToken string, workflowType workflow.AgentWorkflowType) (*Cluster, error) {
func NewCluster(ctx context.Context, assetDir, rendezvousIP, kubeconfigPath, sshKey string, workflowType workflow.AgentWorkflowType) (*Cluster, error) {
czero := &Cluster{}
capi := &clientSet{}
authToken, err := FindAuthTokenFromAssetStore(assetDir)
if err != nil {
logrus.Fatal(err)
}
restclient, err := NewNodeZeroRestClient(ctx, rendezvousIP, sshKey, authToken)
if err != nil {
logrus.Fatal(err)

View File

@@ -16,8 +16,7 @@ func NewMonitorAddNodesCommand(directory, kubeconfigPath string, ips []string) e
return err
}
var token string
cluster, err := agentpkg.NewCluster(context.Background(), "", ips[0], kubeconfigPath, "", token, workflow.AgentWorkflowTypeAddNodes)
cluster, err := agentpkg.NewCluster(context.Background(), "", ips[0], kubeconfigPath, "", workflow.AgentWorkflowTypeAddNodes)
if err != nil {
// TODO exit code enumerate
logrus.Exit(1)