Skip to content

Commit fd27cee

Browse files
📝 Add docstrings to lio/agent-context-cancel
Docstrings generation was requested by @lionello. * #1707 (comment) The following files were modified: * `src/pkg/migrate/heroku.go`
1 parent b641b33 commit fd27cee

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/pkg/migrate/heroku.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,11 @@ func (h *HerokuClient) GetPGInfo(ctx context.Context, addonID string) (PGInfo, e
273273
return herokuGet[PGInfo](ctx, h, url)
274274
}
275275

276+
// herokuGet performs an HTTP GET to the given URL using the HerokuClient's token,
277+
// decodes the JSON response into a value of type T, and returns that value.
278+
// The request uses the provided context and sets Heroku-specific Accept and
279+
// Content-Type headers. If the response has a non-2xx status or the body cannot
280+
// be decoded as JSON, an error is returned describing the failure.
276281
func herokuGet[T any](ctx context.Context, h *HerokuClient, url string) (T, error) {
277282
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
278283
if err != nil {
@@ -328,6 +333,13 @@ func authenticateHerokuCLI() error {
328333
return nil
329334
}
330335

336+
// getHerokuAuthTokenFromCLI obtains a short-lived Heroku API token by invoking the local Heroku CLI.
337+
//
338+
// It checks that the `heroku` executable is available, ensures the CLI is authenticated, runs
339+
// `heroku authorizations:create --expires-in=300 --json`, and parses the resulting JSON for the token.
340+
//
341+
// The returned string is the extracted access token. An error is returned if the CLI is not installed,
342+
// authentication fails, the command cannot be executed, or the command output cannot be parsed.
331343
func getHerokuAuthTokenFromCLI() (string, error) {
332344
_, err := exec.LookPath("heroku")
333345
if err != nil {
@@ -400,4 +412,4 @@ func getHerokuAuthToken() (string, error) {
400412
}
401413

402414
return token, nil
403-
}
415+
}

0 commit comments

Comments
 (0)