Documentation
¶
Index ¶
- type BrowserOpener
- type OAuth
- type State
- func (s *State) AccountID() (string, error)
- func (s *State) Client(ctx context.Context) (*qcloudapi.Client, error)
- func (s *State) ConfigDir() string
- func (s *State) HasCredentials() (bool, error)
- func (s *State) OAuth() OAuth
- func (s *State) OAuthClient(ctx context.Context) (*qcloudapi.Client, error)
- func (s *State) OpenBrowser(url string) error
- func (s *State) SetBrowserOpener(fn BrowserOpener)
- func (s *State) SetClient(c *qcloudapi.Client)
- func (s *State) SetOAuth(o OAuth)
- func (s *State) SetOAuthClient(c *qcloudapi.Client)
- func (s *State) SetUnAuthenticatedClient(c *qcloudapi.Client)
- func (s *State) SetUpdater(u Updater)
- func (s *State) UnAuthenticatedClient(ctx context.Context) (*qcloudapi.Client, error)
- func (s *State) Updater() (Updater, error)
- type Updater
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BrowserOpener ¶ added in v0.25.0
BrowserOpener opens a URL in the user's default browser.
type OAuth ¶ added in v0.34.0
type OAuth interface {
Discover(ctx context.Context, endpoint string) (oauth.Discovery, error)
Login(ctx context.Context, opts oauth.LoginOptions) (oauth.LoginResult, error)
// Session returns the stored session without its tokens, or false when there is none.
Session(endpoint string) (oauth.Token, bool, error)
// Token returns the session with a fresh access token.
Token(ctx context.Context, endpoint string) (oauth.Token, error)
TokenSource(ctx context.Context, endpoint string) (oauth2.TokenSource, error)
Logout(ctx context.Context, endpoint string) (warnings []error, err error)
}
OAuth is the OAuth login: discovery of the login server, the browser and device logins, and the stored session of each endpoint, which it refreshes and removes.
type State ¶
type State struct {
Version string
Config *config.Config
Logger *slog.Logger
// contains filtered or unexported fields
}
State holds shared dependencies for all commands.
func (*State) Client ¶
Client returns the gRPC client, creating it lazily on first call. It uses the configured API key, or else the OAuth login of the endpoint.
func (*State) ConfigDir ¶ added in v0.34.0
ConfigDir is the directory of the config file, or of the default one when none was loaded.
func (*State) HasCredentials ¶ added in v0.35.0
HasCredentials reports whether Client can authenticate: an API key is configured, or there is an OAuth login for the endpoint. An expired login still counts, Client refreshes it.
func (*State) OAuth ¶ added in v0.34.0
OAuth returns the OAuth login, creating it lazily on first call: the OS keychain, and credentials.yaml next to the config file.
func (*State) OAuthClient ¶ added in v0.34.0
OAuthClient returns the gRPC client that uses the OAuth login of the endpoint, whatever API key is configured, creating it lazily on first call.
func (*State) OpenBrowser ¶ added in v0.25.0
OpenBrowser opens the given URL in the user's default browser.
func (*State) SetBrowserOpener ¶ added in v0.25.0
func (s *State) SetBrowserOpener(fn BrowserOpener)
SetBrowserOpener injects a browser opener, bypassing the default. For testing.
func (*State) SetOAuthClient ¶ added in v0.34.0
SetOAuthClient injects a pre-built OAuth client, bypassing lazy creation.
func (*State) SetUnAuthenticatedClient ¶ added in v0.29.0
SetUnAuthenticatedClient injects a pre-built unauthenticated client, bypassing lazy creation.
func (*State) SetUpdater ¶ added in v0.5.0
SetUpdater injects an Updater implementation.
func (*State) UnAuthenticatedClient ¶ added in v0.29.0
UnAuthenticatedClient returns the gRPC client without authentication, creating it lazily on first call.
type Updater ¶ added in v0.5.0
type Updater interface {
DetectLatest(ctx context.Context) (*selfupgrade.ReleaseInfo, bool, error)
UpdateSelf(ctx context.Context, currentVersion string) (*selfupgrade.ReleaseInfo, error)
}
Updater checks for and applies CLI updates.