MCPcopy Index your code
hub / github.com/cloudquery/cloudquery / mintSession

Function mintSession

cli/internal/platform/inject.go:520–540  ·  view source on GitHub ↗
(ctx context.Context, cl *cloudquery_api.ClientWithResponses, tenant cloudquery_api.PlatformTenantSummary)

Source from the content-addressed store, hash-verified

518}
519
520func mintSession(ctx context.Context, cl *cloudquery_api.ClientWithResponses, tenant cloudquery_api.PlatformTenantSummary) (session *cloudquery_api.CreatePlatformDestinationSession201Response, pluginVersion string, err error) {
521 ctx, cancel := context.WithTimeout(ctx, requestTimeout)
522 defer cancel()
523
524 resp, err := cl.CreatePlatformDestinationSessionWithResponse(ctx, cloudquery_api.CreatePlatformDestinationSessionRequest{TenantId: tenant.TenantId})
525 if err != nil {
526 return nil, "", err
527 }
528 if resp.JSON201 == nil {
529 return nil, "", fmt.Errorf("unexpected status %d minting platform destination session: %s", resp.StatusCode(), strings.TrimSpace(string(resp.Body)))
530 }
531 if resp.JSON201.Token == "" || resp.JSON201.ApiUrl == "" {
532 return nil, "", errors.New("platform destination session response missing token or api_url")
533 }
534 // plugin_version lets the platform pin the destination plugin version without
535 // a CLI release. Optional: nil/empty → caller falls back to the CLI default.
536 if resp.JSON201.PluginVersion != nil {
537 pluginVersion = *resp.JSON201.PluginVersion
538 }
539 return resp.JSON201, pluginVersion, nil
540}
541
542// IsInjectedDestination reports whether a destination spec name is the
543// auto-injected platform destination (a reserved name).

Callers 1

MaybeInjectDestinationFunction · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected