MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / loginWithApiKey

Function loginWithApiKey

pkg/cmd/login/login.go:156–182  ·  view source on GitHub ↗
(configProvider config.IConfigProvider, httpClient *http.Client, server string, apiKey string, cmd *cobra.Command)

Source from the content-addressed store, hash-verified

154}
155
156func loginWithApiKey(configProvider config.IConfigProvider, httpClient *http.Client, server string, apiKey string, cmd *cobra.Command) error {
157 serverLink := output.Cyan(server)
158
159 apiKeyCredentials, err := octopusApiClient.NewApiKey(apiKey)
160
161 if err != nil {
162 return err
163 }
164
165 err = testLogin(cmd, httpClient, server, apiKeyCredentials)
166
167 if err != nil {
168 cmd.Println(err)
169 return errors.New("login unsuccessful, please check that your API key is valid")
170 }
171
172 cmd.Printf("Configuring CLI to use API key for Octopus Server: %s", serverLink)
173 cmd.Println()
174
175 configProvider.Set(constants.ConfigUrl, server)
176 configProvider.Set(constants.ConfigApiKey, apiKey)
177 configProvider.Set(constants.ConfigAccessToken, "")
178
179 cmd.Printf("Login successful, happy deployments!")
180 cmd.Println()
181 return nil
182}
183
184type OpenIdConfigurationResponse struct {
185 Issuer string `json:"issuer"`

Callers 1

loginRunFunction · 0.85

Calls 3

CyanFunction · 0.92
testLoginFunction · 0.85
SetMethod · 0.65

Tested by

no test coverage detected