[client] Parse data from setup key (#2411)

refactor functions and variable assignment
This commit is contained in:
Maycon Santos
2024-08-09 20:38:58 +02:00
committed by GitHub
parent 12f9d12a11
commit af1b42e538
3 changed files with 28 additions and 17 deletions

View File

@@ -39,11 +39,9 @@ var loginCmd = &cobra.Command{
ctx = context.WithValue(ctx, system.DeviceNameCtxKey, hostName)
}
if setupKeyPath != "" && setupKey == "" {
setupKey, err = getSetupKeyFromFile(setupKeyPath)
if err != nil {
return err
}
providedSetupKey, err := getSetupKey()
if err != nil {
return err
}
// workaround to run without service
@@ -69,7 +67,7 @@ var loginCmd = &cobra.Command{
config, _ = internal.UpdateOldManagementURL(ctx, config, configPath)
err = foregroundLogin(ctx, cmd, config, setupKey)
err = foregroundLogin(ctx, cmd, config, providedSetupKey)
if err != nil {
return fmt.Errorf("foreground login failed: %v", err)
}
@@ -88,7 +86,7 @@ var loginCmd = &cobra.Command{
client := proto.NewDaemonServiceClient(conn)
loginRequest := proto.LoginRequest{
SetupKey: setupKey,
SetupKey: providedSetupKey,
ManagementUrl: managementURL,
IsLinuxDesktopClient: isLinuxRunningDesktop(),
Hostname: hostName,