@@ -50,15 +50,15 @@ type JoinCmdFlags struct {
5050}
5151
5252// JoinCmd returns a cobra command for joining a node to the cluster.
53- func JoinCmd (ctx context.Context , name string ) * cobra.Command {
53+ func JoinCmd (ctx context.Context , appSlug , appTitle string ) * cobra.Command {
5454 var flags JoinCmdFlags
5555
5656 ctx , cancel := context .WithCancel (ctx )
5757 rc := runtimeconfig .New (nil )
5858
5959 cmd := & cobra.Command {
6060 Use : "join <url> <token>" ,
61- Short : fmt .Sprintf ("Join a node to the %s cluster" , name ),
61+ Short : fmt .Sprintf ("Join a node to the %s cluster" , appTitle ),
6262 Args : cobra .ExactArgs (2 ),
6363 PreRunE : func (cmd * cobra.Command , args []string ) error {
6464 if err := preRunJoin (& flags ); err != nil {
@@ -87,7 +87,7 @@ func JoinCmd(ctx context.Context, name string) *cobra.Command {
8787 joinReporter .ReportSignalAborted (ctx , sig )
8888 })
8989
90- if err := runJoin (cmd .Context (), name , flags , rc , jcmd , args [0 ], joinReporter ); err != nil {
90+ if err := runJoin (cmd .Context (), appSlug , flags , rc , jcmd , args [0 ], joinReporter ); err != nil {
9191 // Check if this is an interrupt error from the terminal
9292 if errors .Is (err , terminal .InterruptErr ) {
9393 joinReporter .ReportSignalAborted (ctx , syscall .SIGINT )
@@ -106,8 +106,8 @@ func JoinCmd(ctx context.Context, name string) *cobra.Command {
106106 panic (err )
107107 }
108108
109- cmd .AddCommand (JoinRunPreflightsCmd (ctx , name ))
110- cmd .AddCommand (JoinPrintCommandCmd (ctx , name ))
109+ cmd .AddCommand (JoinRunPreflightsCmd (ctx , appSlug , appTitle ))
110+ cmd .AddCommand (JoinPrintCommandCmd (ctx , appTitle ))
111111
112112 return cmd
113113}
@@ -153,18 +153,18 @@ func addJoinFlags(cmd *cobra.Command, flags *JoinCmdFlags) error {
153153 return nil
154154}
155155
156- func runJoin (ctx context.Context , name string , flags JoinCmdFlags , rc runtimeconfig.RuntimeConfig , jcmd * join.JoinCommandResponse , kotsAPIAddress string , joinReporter * JoinReporter ) error {
156+ func runJoin (ctx context.Context , appSlug string , flags JoinCmdFlags , rc runtimeconfig.RuntimeConfig , jcmd * join.JoinCommandResponse , kotsAPIAddress string , joinReporter * JoinReporter ) error {
157157 // both controller and worker nodes will have 'worker' in the join command
158158 isWorker := ! strings .Contains (jcmd .K0sJoinCommand , "controller" )
159159 if ! isWorker {
160160 logrus .Warn ("\n Do not join another node until this node has joined successfully." )
161161 }
162162
163- if err := runJoinVerifyAndPrompt (name , flags , rc , jcmd ); err != nil {
163+ if err := runJoinVerifyAndPrompt (appSlug , flags , rc , jcmd ); err != nil {
164164 return err
165165 }
166166
167- cidrCfg , err := initializeJoin (ctx , name , rc , jcmd , kotsAPIAddress )
167+ cidrCfg , err := initializeJoin (ctx , appSlug , rc , jcmd , kotsAPIAddress )
168168 if err != nil {
169169 return fmt .Errorf ("unable to initialize join: %w" , err )
170170 }
@@ -180,7 +180,7 @@ func runJoin(ctx context.Context, name string, flags JoinCmdFlags, rc runtimecon
180180 logrus .Debugf ("installing and joining cluster" )
181181 loading := spinner .Start ()
182182 loading .Infof ("Installing node" )
183- if err := installAndJoinCluster (ctx , rc , jcmd , name , flags , isWorker ); err != nil {
183+ if err := installAndJoinCluster (ctx , rc , jcmd , appSlug , flags , isWorker ); err != nil {
184184 loading .ErrorClosef ("Failed to install node" )
185185 return err
186186 }
@@ -226,9 +226,9 @@ func runJoin(ctx context.Context, name string, flags JoinCmdFlags, rc runtimecon
226226 return nil
227227}
228228
229- func runJoinVerifyAndPrompt (name string , flags JoinCmdFlags , rc runtimeconfig.RuntimeConfig , jcmd * join.JoinCommandResponse ) error {
229+ func runJoinVerifyAndPrompt (appSlug string , flags JoinCmdFlags , rc runtimeconfig.RuntimeConfig , jcmd * join.JoinCommandResponse ) error {
230230 logrus .Debugf ("checking if k0s is already installed" )
231- err := verifyNoInstallation (name , "join a node" )
231+ err := verifyNoInstallation (appSlug , "join a node" )
232232 if err != nil {
233233 return err
234234 }
@@ -284,7 +284,7 @@ func runJoinVerifyAndPrompt(name string, flags JoinCmdFlags, rc runtimeconfig.Ru
284284 return nil
285285}
286286
287- func initializeJoin (ctx context.Context , name string , rc runtimeconfig.RuntimeConfig , jcmd * join.JoinCommandResponse , kotsAPIAddress string ) (cidrCfg * newconfig.CIDRConfig , err error ) {
287+ func initializeJoin (ctx context.Context , appSlug string , rc runtimeconfig.RuntimeConfig , jcmd * join.JoinCommandResponse , kotsAPIAddress string ) (cidrCfg * newconfig.CIDRConfig , err error ) {
288288 logrus .Info ("" )
289289 spinner := spinner .Start ()
290290 spinner .Infof ("Initializing" )
@@ -306,7 +306,7 @@ func initializeJoin(ctx context.Context, name string, rc runtimeconfig.RuntimeCo
306306 logrus .Debugf ("unable to chmod embedded-cluster home dir: %s" , err )
307307 }
308308
309- logrus .Debugf ("materializing %s binaries" , name )
309+ logrus .Debugf ("materializing %s binaries" , appSlug )
310310 if err := materializeFilesForJoin (ctx , rc , jcmd , kotsAPIAddress ); err != nil {
311311 return nil , fmt .Errorf ("failed to materialize files: %w" , err )
312312 }
@@ -382,13 +382,13 @@ func getJoinCIDRConfig(rc runtimeconfig.RuntimeConfig) (*newconfig.CIDRConfig, e
382382 }, nil
383383}
384384
385- func installAndJoinCluster (ctx context.Context , rc runtimeconfig.RuntimeConfig , jcmd * join.JoinCommandResponse , name string , flags JoinCmdFlags , isWorker bool ) error {
385+ func installAndJoinCluster (ctx context.Context , rc runtimeconfig.RuntimeConfig , jcmd * join.JoinCommandResponse , appSlug string , flags JoinCmdFlags , isWorker bool ) error {
386386 logrus .Debugf ("saving token to disk" )
387387 if err := saveTokenToDisk (jcmd .K0sToken ); err != nil {
388388 return fmt .Errorf ("unable to save token to disk: %w" , err )
389389 }
390390
391- logrus .Debugf ("installing %s binaries" , name )
391+ logrus .Debugf ("installing %s binaries" , appSlug )
392392 if err := installK0sBinary (rc ); err != nil {
393393 return fmt .Errorf ("unable to install k0s binary: %w" , err )
394394 }
@@ -424,7 +424,7 @@ func installAndJoinCluster(ctx context.Context, rc runtimeconfig.RuntimeConfig,
424424 return fmt .Errorf ("unable to join node to cluster: %w" , err )
425425 }
426426
427- if err := startAndWaitForK0s (name ); err != nil {
427+ if err := startAndWaitForK0s (appSlug ); err != nil {
428428 return err
429429 }
430430
@@ -495,8 +495,8 @@ func applyNetworkConfiguration(rc runtimeconfig.RuntimeConfig, jcmd *join.JoinCo
495495}
496496
497497// startAndWaitForK0s starts the k0s service and waits for the node to be ready.
498- func startAndWaitForK0s (name string ) error {
499- logrus .Debugf ("starting %s service" , name )
498+ func startAndWaitForK0s (appSlug string ) error {
499+ logrus .Debugf ("starting %s service" , appSlug )
500500 if _ , err := helpers .RunCommand (runtimeconfig .K0sBinaryPath , "start" ); err != nil {
501501 return fmt .Errorf ("unable to start service: %w" , err )
502502 }
0 commit comments