[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

@ -256,9 +256,19 @@ var CLIBackOffSettings = &backoff.ExponentialBackOff{
Clock: backoff.SystemClock,
}
func getSetupKey() (string, error) {
if setupKeyPath != "" && setupKey == "" {
return getSetupKeyFromFile(setupKeyPath)
}
return setupKey, nil
}
func getSetupKeyFromFile(setupKeyPath string) (string, error) {
data, err := os.ReadFile(setupKeyPath)
return string(data), err
if err != nil {
return "", fmt.Errorf("failed to read setup key file: %v", err)
}
return strings.TrimSpace(string(data)), nil
}
func handleRebrand(cmd *cobra.Command) error {