Skip to content

Commit 47edd6a

Browse files
Move common code into NewCluster() method
1 parent b96feb6 commit 47edd6a

File tree

4 files changed

+10
-17
lines changed

4 files changed

+10
-17
lines changed

cmd/openshift-install/agent/waitfor.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,8 @@ func newWaitForBootstrapCompleteCmd() *cobra.Command {
7171
logrus.Fatal(err)
7272
}
7373

74-
authToken, err := agentpkg.FindAuthTokenFromAssetStore(assetDir)
75-
if err != nil {
76-
logrus.Fatal(err)
77-
}
78-
7974
ctx := context.Background()
80-
cluster, err := agentpkg.NewCluster(ctx, assetDir, rendezvousIP, kubeconfigPath, sshKey, authToken, workflow.AgentWorkflowTypeInstall)
75+
cluster, err := agentpkg.NewCluster(ctx, assetDir, rendezvousIP, kubeconfigPath, sshKey, workflow.AgentWorkflowTypeInstall)
8176
if err != nil {
8277
logrus.Exit(exitCodeBootstrapFailed)
8378
}
@@ -111,13 +106,8 @@ func newWaitForInstallCompleteCmd() *cobra.Command {
111106
logrus.Fatal(err)
112107
}
113108

114-
authToken, err := agentpkg.FindAuthTokenFromAssetStore(assetDir)
115-
if err != nil {
116-
logrus.Fatal(err)
117-
}
118-
119109
ctx := context.Background()
120-
cluster, err := agentpkg.NewCluster(ctx, assetDir, rendezvousIP, kubeconfigPath, sshKey, authToken, workflow.AgentWorkflowTypeInstall)
110+
cluster, err := agentpkg.NewCluster(ctx, assetDir, rendezvousIP, kubeconfigPath, sshKey, workflow.AgentWorkflowTypeInstall)
121111
if err != nil {
122112
logrus.Exit(exitCodeBootstrapFailed)
123113
}

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ require (
4242
github.com/diskfs/go-diskfs v1.4.0
4343
github.com/form3tech-oss/jwt-go v3.2.3+incompatible
4444
github.com/go-openapi/errors v0.22.0
45-
github.com/go-openapi/runtime v0.26.2
45+
github.com/go-openapi/runtime v0.28.0
4646
github.com/go-openapi/strfmt v0.23.0
4747
github.com/go-openapi/swag v0.23.0
4848
github.com/go-playground/validator/v10 v10.19.0
@@ -178,7 +178,6 @@ require (
178178
github.com/go-openapi/jsonpointer v0.21.0 // indirect
179179
github.com/go-openapi/jsonreference v0.21.0 // indirect
180180
github.com/go-openapi/loads v0.22.0 // indirect
181-
github.com/go-openapi/runtime v0.28.0 // indirect
182181
github.com/go-openapi/spec v0.21.0 // indirect
183182
github.com/go-openapi/validate v0.24.0 // indirect
184183
github.com/go-playground/locales v0.14.1 // indirect

pkg/agent/cluster.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,15 @@ type clusterInstallStatusHistory struct {
6666
}
6767

6868
// NewCluster initializes a Cluster object
69-
func NewCluster(ctx context.Context, assetDir, rendezvousIP, kubeconfigPath, sshKey, authToken string, workflowType workflow.AgentWorkflowType) (*Cluster, error) {
69+
func NewCluster(ctx context.Context, assetDir, rendezvousIP, kubeconfigPath, sshKey string, workflowType workflow.AgentWorkflowType) (*Cluster, error) {
7070
czero := &Cluster{}
7171
capi := &clientSet{}
7272

73+
authToken, err := FindAuthTokenFromAssetStore(assetDir)
74+
if err != nil {
75+
logrus.Fatal(err)
76+
}
77+
7378
restclient, err := NewNodeZeroRestClient(ctx, rendezvousIP, sshKey, authToken)
7479
if err != nil {
7580
logrus.Fatal(err)

pkg/nodejoiner/monitoraddnodes.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ func NewMonitorAddNodesCommand(directory, kubeconfigPath string, ips []string) e
1616
return err
1717
}
1818

19-
var token string
20-
cluster, err := agentpkg.NewCluster(context.Background(), "", ips[0], kubeconfigPath, "", token, workflow.AgentWorkflowTypeAddNodes)
19+
cluster, err := agentpkg.NewCluster(context.Background(), "", ips[0], kubeconfigPath, "", workflow.AgentWorkflowTypeAddNodes)
2120
if err != nil {
2221
// TODO exit code enumerate
2322
logrus.Exit(1)

0 commit comments

Comments
 (0)