Movatterモバイル変換


[0]ホーム

URL:


cli

package
v2.23.0Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2025 License:AGPL-3.0Imports:189Imported by:0

Details

Repository

github.com/coder/coder

Links

Documentation

Index

Constants

View Source
const (// Client ID forhttps://github.com/apps/coderGithubOAuth2DefaultProviderClientID      = "Iv1.6a2b4b4aec4f4fe7"GithubOAuth2DefaultProviderAllowEveryone =trueGithubOAuth2DefaultProviderDeviceFlow    =true)

Variables

View Source
var (Caret =pretty.Sprint(cliui.DefaultStyles.Prompt, "")// ErrSilent is a sentinel error that tells the command handler to just exit with a non-zero error, but not print// anything.ErrSilent =xerrors.New("silent error"))
View Source
var InterruptSignals = []os.Signal{os.Interrupt,}

InterruptSignals is the list of signals that are used for handlingimmediate shutdown behavior.

StopSignals is the list of signals that are used for handlingshutdown behavior.

View Source
var StopSignalsNoInterrupt = []os.Signal{syscall.SIGTERM,syscall.SIGHUP,}

StopSignals is the list of signals that are used for handlinggraceful shutdown behavior.

Functions

funcConfigureHTTPClient

func ConfigureHTTPClient(ctxcontext.Context, clientCertFile, clientKeyFilestring, tlsClientCAFilestring) (context.Context, *http.Client,error)

funcConnectToPostgresadded inv2.2.0

func ConnectToPostgres(ctxcontext.Context, loggerslog.Logger, driverstring, dbURLstring, migrate func(db *sql.DB)error) (*sql.DB,error)

ConnectToPostgres takes in the migration command to run on the database onceit connects. To avoid running migrations, pass in `nil` or a no-op function.Regardless of the passed in migration function, if the database is not fullymigrated, an error will be returned. This can happen if the database is on afuture or past migration version.

If no error is returned, the database is fully migrated and up to date.

funcDumpHandler

func DumpHandler(ctxcontext.Context, namestring)

DumpHandler provides a custom SIGQUIT and SIGTRAP handler that dumps thestacktrace of all goroutines to stderr and a well-known file in the homedirectory. This is useful for debugging deadlock issues that may occur inproduction in workspaces, since the default Go runtime will only dump tostderr (which is often difficult/impossible to read in a workspace).

SIGQUITs will still cause the program to exit (similarly to the default Goruntime behavior).

A SIGQUIT handler will not be registered if GOTRACEBACK=crash.

On Windows this immediately returns.

funcExitErroradded inv2.5.0

func ExitError(codeint, errerror)error

ExitError returns an error that will cause the CLI to exit with the givenexit code. If err is non-nil, it will be wrapped by the returned error.

funcFormatExamplesadded inv2.12.0

func FormatExamples(examples ...Example)string

FormatExamples formats the examples as width wrapped bulletpointdescriptions with the command underneath.

funcIsLocalURL

func IsLocalURL(ctxcontext.Context, u *url.URL) (bool,error)

isLocalURL returns true if the hostname of the provided URL appears toresolve to a loopback address.

funcIsLocalhost

func IsLocalhost(hoststring)bool

IsLocalhost returns true if the host points to the local machine. Intended tobe called with `u.Hostname()`.

funcParseProvisionerTags

func ParseProvisionerTags(rawTags []string) (map[string]string,error)

funcPrintDeprecatedOptions

func PrintDeprecatedOptions()serpent.MiddlewareFunc

printDeprecatedOptions loops through all command options, and printsa warning for usage of deprecated options.

funcPrintLogo

func PrintLogo(inv *serpent.Invocation, daemonTitlestring)

nolint: revive

funcReadAIProvidersFromEnvadded inv2.23.0

func ReadAIProvidersFromEnv(environ []string) ([]codersdk.AIProviderConfig,error)

funcReadExternalAuthProvidersFromEnvadded inv2.2.1

func ReadExternalAuthProvidersFromEnv(environ []string) ([]codersdk.ExternalAuthConfig,error)

ReadExternalAuthProvidersFromEnv is provided for compatibility purposes withthe viper CLI.

funcServeHandler

func ServeHandler(ctxcontext.Context, loggerslog.Logger, handlerhttp.Handler, addr, namestring) (closeFunc func())

funcSlimUnsupportedadded inv2.1.5

func SlimUnsupported(wio.Writer, cmdstring)

funcWithTestOnlyCoderConnectDialeradded inv2.22.0

func WithTestOnlyCoderConnectDialer(ctxcontext.Context, dialer coderConnectDialer)context.Context

funcWriteConfigMW

writeConfigMW will prevent the main command from running if the write-configflag is set. Instead, it will marshal the command options to YAML and writethem to stdout.

Types

typeClaudeConfigadded inv2.21.0

type ClaudeConfig struct {ConfigPathstringProjectDirectorystringAPIKeystringAllowedTools     []stringMCPServers       map[string]ClaudeConfigMCP}

typeClaudeConfigMCPadded inv2.21.0

type ClaudeConfigMCP struct {Commandstring            `json:"command"`Args    []string          `json:"args"`Env     map[string]string `json:"env"`}

typeExampleadded inv2.12.0

type Example struct {DescriptionstringCommandstring}

Example represents a standard example for command usage, to be usedwith FormatExamples.

typeHTTPServers

type HTTPServers struct {HTTPUrl      *url.URLHTTPListenernet.Listener// TLSTLSUrl      *url.URLTLSListenernet.ListenerTLSConfig   *tls.Config}

funcConfigureHTTPServers

func ConfigureHTTPServers(loggerslog.Logger, inv *serpent.Invocation, cfg *codersdk.DeploymentValues) (_ *HTTPServers, errerror)

func (*HTTPServers)Close

func (s *HTTPServers) Close()

func (*HTTPServers)Serve

func (s *HTTPServers) Serve(srv *http.Server)error

Serve acts just like http.Serve. It is a blocking call until the serveris closed, and an error is returned if any underlying Serve call fails.

typeOrganizationContextadded inv2.14.0

type OrganizationContext struct {// FlagSelect is the value passed in via the --org flagFlagSelectstring}

funcNewOrganizationContextadded inv2.14.0

func NewOrganizationContext() *OrganizationContext

func (*OrganizationContext)AttachOptionsadded inv2.14.0

func (o *OrganizationContext) AttachOptions(cmd *serpent.Command)

func (*OrganizationContext)Selectedadded inv2.14.0

func (*OrganizationContext)ValueSourceadded inv2.14.0

typeParameterResolver

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

func (*ParameterResolver)Resolve

func (*ParameterResolver)WithEphemeralParametersadded inv2.17.0

func (pr *ParameterResolver) WithEphemeralParameters(params []codersdk.WorkspaceBuildParameter) *ParameterResolver

func (*ParameterResolver)WithLastBuildParameters

func (pr *ParameterResolver) WithLastBuildParameters(params []codersdk.WorkspaceBuildParameter) *ParameterResolver

func (*ParameterResolver)WithPromptEphemeralParametersadded inv2.17.0

func (pr *ParameterResolver) WithPromptEphemeralParameters(promptEphemeralParametersbool) *ParameterResolver

func (*ParameterResolver)WithPromptRichParameters

func (pr *ParameterResolver) WithPromptRichParameters(promptRichParametersbool) *ParameterResolver

func (*ParameterResolver)WithRichParameters

func (pr *ParameterResolver) WithRichParameters(params []codersdk.WorkspaceBuildParameter) *ParameterResolver

func (*ParameterResolver)WithRichParametersDefaultsadded inv2.11.0

func (pr *ParameterResolver) WithRichParametersDefaults(params []codersdk.WorkspaceBuildParameter) *ParameterResolver

func (*ParameterResolver)WithRichParametersFile

func (pr *ParameterResolver) WithRichParametersFile(fileMap map[string]string) *ParameterResolver

func (*ParameterResolver)WithSourceWorkspaceParametersadded inv2.4.0

func (pr *ParameterResolver) WithSourceWorkspaceParameters(params []codersdk.WorkspaceBuildParameter) *ParameterResolver

typePrettyErrorFormatteradded inv2.10.0

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

funcNewPrettyErrorFormatteradded inv2.10.0

func NewPrettyErrorFormatter(wio.Writer, verbosebool) *PrettyErrorFormatter

NewPrettyErrorFormatter creates a new PrettyErrorFormatter.

func (*PrettyErrorFormatter)Formatadded inv2.10.0

func (p *PrettyErrorFormatter) Format(errerror)

Format formats the error to the writer in PrettyErrorFormatter.This error should be human readable.

typeRootCmd

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

RootCmd contains parameters and helpers useful to all commands.

func (*RootCmd)AGPL

func (r *RootCmd) AGPL() []*serpent.Command

func (*RootCmd)Command

func (r *RootCmd) Command(subcommands []*serpent.Command) (*serpent.Command,error)

func (*RootCmd)CoreSubcommandsadded inv2.10.0

func (r *RootCmd) CoreSubcommands() []*serpent.Command

func (*RootCmd)HeaderTransportadded inv2.5.0

func (r *RootCmd) HeaderTransport(ctxcontext.Context, serverURL *url.URL) (*codersdk.HeaderTransport,error)

HeaderTransport creates a new transport that executes `--header-command`if it is set to add headers for all outbound requests.

func (*RootCmd)InitClient

func (r *RootCmd) InitClient(client *codersdk.Client)serpent.MiddlewareFunc

InitClient authenticates the client with files from diskand injects header middlewares for telemetry, authentication,and version checks.

func (*RootCmd)Provisionersadded inv2.19.0

func (r *RootCmd) Provisioners() *serpent.Command

func (*RootCmd)RunWithSubcommandsadded inv2.10.0

func (r *RootCmd) RunWithSubcommands(subcommands []*serpent.Command)

RunWithSubcommands runs the root command with the given subcommands.It is abstracted to enable the Enterprise code to add commands.

func (*RootCmd)Server

func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.API,io.Closer,error)) *serpent.Command

func (*RootCmd)TryInitClientadded inv2.22.0

func (r *RootCmd) TryInitClient(client *codersdk.Client)serpent.MiddlewareFunc

TryInitClient is similar to InitClient but doesn't error when credentials are missing.This allows commands to run without requiring authentication, but still use auth if available.

func (*RootCmd)Verbosefadded inv2.1.4

func (r *RootCmd) Verbosef(inv *serpent.Invocation, fmtStrstring, args ...interface{})

Verbosef logs a message if verbose mode is enabled.

typeSpeedtestResultadded inv2.13.0

type SpeedtestResult struct {OverallSpeedtestResultInterval   `json:"overall"`Intervals []SpeedtestResultInterval `json:"intervals"`}

typeSpeedtestResultIntervaladded inv2.13.0

type SpeedtestResultInterval struct {StartTimeSecondsfloat64 `json:"start_time_seconds"`EndTimeSecondsfloat64 `json:"end_time_seconds"`ThroughputMbitsfloat64 `json:"throughput_mbits"`}

typeStdioRwcadded inv2.22.0

type StdioRwc struct {io.Readerio.Writer}

func (*StdioRwc)Closeadded inv2.22.0

func (*StdioRwc) Close()error

typeWorkspaceCLIAction

type WorkspaceCLIActionint
const (WorkspaceCreateWorkspaceCLIAction =iotaWorkspaceStartWorkspaceUpdateWorkspaceRestart)

Source Files

View all Source files

Directories

PathSynopsis
Package clilog provides a fluent API for configuring structured logging.
Package clilog provides a fluent API for configuring structured logging.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp