7.5 KiB
cli
import "github.com/effective-security/trustyca/api/cli"
Package cli configures the public trustyca command, client connections and output formatting.
Cli.AfterApply changes process-wide xlog and time formatting, so CLIs are never parsed concurrently in one process; the test suites of api/cli/command are not parallel for that reason.
Index
- Variables
- type Cli
- func (c *Cli) AfterApply(app *kong.Kong, vars kong.Vars) error
- func (c *Cli) AuthClient(skipAuth bool) (pb.AuthServer, error)
- func (c *Cli) CISClient() (pb.CISServer, error)
- func (c *Cli) Context() context.Context
- func (c *Cli) ErrWriter() io.Writer
- func (c *Cli) HTTPClient(skipAuth bool) (*retriable.Client, error)
- func (c *Cli) IsJSON() bool
- func (c *Cli) OrgsClient() (pb.OrgsServer, error)
- func (c *Cli) Print(value any) error
- func (c *Cli) RPCClient(skipAuth bool) (*rpcclient.Client, error)
- func (c *Cli) Reader() io.Reader
- func (c *Cli) StatusClient() (pb.StatusServer, error)
- func (c *Cli) StringPrompt(label string) string
- func (c *Cli) WithErrWriter(out io.Writer) *Cli
- func (c *Cli) WithReader(reader io.Reader) *Cli
- func (c *Cli) WithWriter(out io.Writer) *Cli
- func (c *Cli) Writer() io.Writer
Variables
var (
// DefaultStoragePath specifies default storage path
DefaultStoragePath = "~/.config/trustyca"
ServerAlias = map[string]string{
"local": "https://localhost:8880",
"dev": "https://wfe.dev.trustyca.io",
"prod": "https://wfe.prod.trustyca.io",
}
)
type Cli
Cli provides CLI context to run commands
type Cli struct {
Server string `short:"s" help:"Address of the remote server to connect. Use TRUSTYCA_SERVER environment to override"`
Debug bool `short:"D" help:"Enable debug mode"`
Version ctl.VersionFlag `name:"version" help:"Print version information and quit" hidden:""`
O string `help:"Print output format: json|yaml"`
Cfg string `help:"Configuration file" default:"~/.config/trustyca/config.yaml"`
Storage string `help:"flag specifies to override default location: ~/.trustyca. Use TRUSTYCA_STORAGE environment to override"`
HTTP bool `short:"H" help:"Use HTTP client"`
TimeFormat string `name:"time" help:"Print time format: utc|local|ago" hidden:"" default:"utc"`
Timeout int `help:"Connection timeout" default:"6"`
TrustedCA string `short:"r" help:"Trusted CA store for server TLS"`
// contains filtered or unexported fields
}
func (*Cli) AfterApply
func (c *Cli) AfterApply(app *kong.Kong, vars kong.Vars) error
AfterApply hook loads config. It sets the process-wide log formatter, log level and time format, so two CLIs must not be parsed concurrently in one process.
func (*Cli) AuthClient
func (c *Cli) AuthClient(skipAuth bool) (pb.AuthServer, error)
AuthClient returns AuthClient client from connection
func (*Cli) CISClient
func (c *Cli) CISClient() (pb.CISServer, error)
CISClient returns the client of the Certificate Information Service, the read-only view of the CA for authenticated callers: the token of the login is sent with every request
func (*Cli) Context
func (c *Cli) Context() context.Context
Context for requests
func (*Cli) ErrWriter
func (c *Cli) ErrWriter() io.Writer
ErrWriter returns a writer for control output
func (*Cli) HTTPClient
func (c *Cli) HTTPClient(skipAuth bool) (*retriable.Client, error)
HTTPClient returns client
func (*Cli) IsJSON
func (c *Cli) IsJSON() bool
IsJSON returns true if the output format us JSON
func (*Cli) OrgsClient
func (c *Cli) OrgsClient() (pb.OrgsServer, error)
OrgsClient returns Orgs client from connection
func (*Cli) Print
func (c *Cli) Print(value any) error
Print response to out
func (*Cli) RPCClient
func (c *Cli) RPCClient(skipAuth bool) (*rpcclient.Client, error)
RPCClient returns gRPC client
func (*Cli) Reader
func (c *Cli) Reader() io.Reader
Reader is the source to read from, typically set to os.Stdin
func (*Cli) StatusClient
func (c *Cli) StatusClient() (pb.StatusServer, error)
StatusClient returns StatusClient client from connection
func (*Cli) StringPrompt
func (c *Cli) StringPrompt(label string) string
func (*Cli) WithErrWriter
func (c *Cli) WithErrWriter(out io.Writer) *Cli
WithErrWriter allows to specify a custom error writer
func (*Cli) WithReader
func (c *Cli) WithReader(reader io.Reader) *Cli
WithReader allows to specify a custom reader
func (*Cli) WithWriter
func (c *Cli) WithWriter(out io.Writer) *Cli
WithWriter allows to specify a custom writer
func (*Cli) Writer
func (c *Cli) Writer() io.Writer
Writer returns a writer for control output
Generated by gomarkdoc