cli

package
v0.27.3 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: AGPL-3.0 Imports: 150 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Caret = cliui.DefaultStyles.Prompt.String()
)
View Source
var InterruptSignals = []os.Signal{
	os.Interrupt,
	syscall.SIGTERM,
	syscall.SIGHUP,
}

Functions

func BuildLogger added in v0.22.1

func BuildLogger(inv *clibase.Invocation, cfg *codersdk.DeploymentValues) (slog.Logger, func(), error)

func ConfigureHTTPClient added in v0.22.1

func ConfigureHTTPClient(ctx context.Context, clientCertFile, clientKeyFile string, tlsClientCAFile string) (context.Context, *http.Client, error)

func ConfigureTraceProvider added in v0.22.1

func ConfigureTraceProvider(
	ctx context.Context,
	logger slog.Logger,
	inv *clibase.Invocation,
	cfg *codersdk.DeploymentValues,
) (trace.TracerProvider, string, func(context.Context) error)

func ContextWithLogger added in v0.18.0

func ContextWithLogger(ctx context.Context, l slog.Logger) context.Context

func CurrentOrganization added in v0.12.0

func CurrentOrganization(inv *clibase.Invocation, client *codersdk.Client) (codersdk.Organization, error)

CurrentOrganization returns the currently active organization for the authenticated user.

func DumpHandler added in v0.22.1

func DumpHandler(ctx context.Context)

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

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

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

On Windows this immediately returns.

func IsLocalURL added in v0.22.1

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

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

func IsLocalhost added in v0.22.1

func IsLocalhost(host string) bool

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

func LoggerFromContext added in v0.18.0

func LoggerFromContext(ctx context.Context) (slog.Logger, bool)

func ParseProvisionerTags added in v0.12.8

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

func PrintDeprecatedOptions added in v0.22.1

func PrintDeprecatedOptions() clibase.MiddlewareFunc

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

func PrintLogo(inv *clibase.Invocation, daemonTitle string)

nolint: revive

func ReadGitAuthProvidersFromEnv added in v0.19.0

func ReadGitAuthProvidersFromEnv(environ []string) ([]codersdk.GitAuthConfig, error)

ReadGitAuthProvidersFromEnv is provided for compatibility purposes with the viper CLI. DEPRECATED

func ServeHandler added in v0.22.1

func ServeHandler(ctx context.Context, logger slog.Logger, handler http.Handler, addr, name string) (closeFunc func())

func WriteConfigMW added in v0.22.1

func WriteConfigMW(cfg *codersdk.DeploymentValues) clibase.MiddlewareFunc

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

Types

type HTTPServers added in v0.22.1

type HTTPServers struct {
	HTTPUrl      *url.URL
	HTTPListener net.Listener

	// TLS
	TLSUrl      *url.URL
	TLSListener net.Listener
	TLSConfig   *tls.Config
}

func ConfigureHTTPServers added in v0.22.1

func ConfigureHTTPServers(inv *clibase.Invocation, cfg *codersdk.DeploymentValues) (_ *HTTPServers, err error)

func (*HTTPServers) Close added in v0.22.1

func (s *HTTPServers) Close()

func (*HTTPServers) Serve added in v0.22.1

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

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

type RootCmd added in v0.21.0

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

RootCmd contains parameters and helpers useful to all commands.

func (*RootCmd) AGPL added in v0.21.0

func (r *RootCmd) AGPL() []*clibase.Cmd

func (*RootCmd) Command added in v0.21.0

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

func (*RootCmd) Core added in v0.21.0

func (r *RootCmd) Core() []*clibase.Cmd

func (*RootCmd) InitClient added in v0.21.0

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

InitClient sets client to a new client. It reads from global configuration files if flags are not set.

func (*RootCmd) RunMain added in v0.21.0

func (r *RootCmd) RunMain(subcommands []*clibase.Cmd)

Main is the entrypoint for the Coder CLI.

func (*RootCmd) Server added in v0.21.0

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

nolint:gocyclo

Directories

Path Synopsis
Package clibase offers an all-in-one solution for a highly configurable CLI application.
Package clibase offers an all-in-one solution for a highly configurable CLI application.

Jump to

Keyboard shortcuts

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