Help us shape the future of Go! Take the 2026 Go Developer Survey

session

package
v0.37.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package session resolves the authenticated client and active project for a command run.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory struct {
	// contains filtered or unexported fields
}

Factory builds API clients and authenticated sessions.

func NewFactory

func NewFactory(deps cliruntime.Deps) Factory

NewFactory returns a session factory using the provided runtime dependencies.

func (Factory) APIClient

func (f Factory) APIClient(apiURL, token string) (*api.Client, error)

APIClient constructs an API client with runtime overrides. In local mode it sends no credential: local is a single-tenant sandbox with no attacker model, and the local server defaults an absent credential to the pre-provisioned local user, so every local command behaves the same way. Cloud is unaffected.

func (Factory) APIURL

func (f Factory) APIURL(cfg *config.Config) string

APIURL returns the cloud API URL with runtime overrides applied.

func (Factory) AccountScoped added in v0.31.0

func (f Factory) AccountScoped() (*Session, error)

AccountScoped loads config and builds an API client for a workflow that reaches beyond one project, rejecting a project access token before it can produce a 403 the caller cannot act on.

func (Factory) Authenticated

func (f Factory) Authenticated() (*Session, error)

Authenticated loads config, requires authentication, and builds an API client.

func (Factory) Config

func (f Factory) Config() (*config.Config, error)

Config loads CLI config with runtime overrides.

func (Factory) CurrentProject

func (f Factory) CurrentProject() (*ProjectSession, error)

CurrentProject builds an authenticated API client for the current project.

type ProjectSession

type ProjectSession struct {
	Config    *config.Config
	API       *api.Client
	ProjectID uuid.UUID
	APIURL    string
	// contains filtered or unexported fields
}

ProjectSession contains config, an API client, and the current project ID.

func (*ProjectSession) APIWithToken

func (s *ProjectSession) APIWithToken(token string) (*api.Client, error)

APIWithToken constructs an API client for the same API URL and runtime dependencies as this project session, using the provided bearer token.

type Session

type Session struct {
	Config *config.Config
	API    *api.Client
	// contains filtered or unexported fields
}

Session contains config and an API client for authenticated workflows.

func (*Session) APIWithToken added in v0.0.4

func (s *Session) APIWithToken(token string) (*api.Client, error)

APIWithToken constructs an API client for the same API URL and runtime dependencies as this authenticated session, using the provided bearer token.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL