MCPcopy
hub / github.com/spacecloud-io/space-cloud / ChangeSelectedAccount

Function ChangeSelectedAccount

space-cli/cmd/utils/operations.go:62–90  ·  view source on GitHub ↗

ChangeSelectedAccount change selected account according to cluster name provided

(clusterName string)

Source from the content-addressed store, hash-verified

60
61// ChangeSelectedAccount change selected account according to cluster name provided
62func 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
93func GetSCImageName(imagePrefix, version string, t model.ImageType) string {

Callers

nothing calls this directly

Calls 2

GetCredentialsFunction · 0.85
GenerateAccountsFileFunction · 0.85

Tested by

no test coverage detected