ChangeSelectedAccount change selected account according to cluster name provided
(clusterName string)
| 60 | |
| 61 | // ChangeSelectedAccount change selected account according to cluster name provided |
| 62 | func ChangeSelectedAccount(clusterName string) error { |
| 63 | credential, err := GetCredentials() |
| 64 | if err != nil { |
| 65 | return err |
| 66 | } |
| 67 | |
| 68 | credential.SelectedAccount = "" |
| 69 | for _, v := range credential.Accounts { |
| 70 | // With version (v0.19.0) account id has a clusterName prefix separated by -- (default--someId) |
| 71 | if v.ID == "" { |
| 72 | // this condition occurs when space cli is logged in with a remote server |
| 73 | continue |
| 74 | } |
| 75 | if v.ID == clusterName { |
| 76 | credential.SelectedAccount = v.ID |
| 77 | break |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | if credential.SelectedAccount == "" { |
| 82 | return fmt.Errorf("no account found in account.yaml") |
| 83 | } |
| 84 | |
| 85 | if err := GenerateAccountsFile(credential); err != nil { |
| 86 | return err |
| 87 | } |
| 88 | |
| 89 | return nil |
| 90 | } |
| 91 | |
| 92 | //GetSCImageName get the sc image name and add the image prefix when required |
| 93 | func GetSCImageName(imagePrefix, version string, t model.ImageType) string { |
nothing calls this directly
no test coverage detected