Files

8.3 KiB

ctl

import "github.com/effective-security/trustyca/internal/ctl"

Index

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: ~/.config/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"`
    Cert      string `short:"c" help:"Client certificate file for mTLS"`
    CertKey   string `short:"k" help:"Client certificate key for mTLS"`
    TrustedCA string `short:"r" help:"Trusted CA store for server TLS"`
    // contains filtered or unexported fields
}

func (*Cli) AdminClient

func (c *Cli) AdminClient() (privpb.AdminServer, error)

AdminClient returns Admin client from connection

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 Auth client from connection

func (*Cli) BackendClient

func (c *Cli) BackendClient() (privpb.BackendServer, error)

BackendClient returns the CA client of the connection: the CA of the service identities (privpb.Backend), which names the org of every request. It is served by the backend listener over gRPC only, to the operator's DPoP token (the trustyca-admin role of its email).

func (*Cli) CISClient

func (c *Cli) CISClient() (pb.CISServer, error)

CISClient returns the client of the Certificate Information Service, the public, read-only side of the CA: it needs no token

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) Resolve

func (c *Cli) Resolve(val string) (string, error)

func (*Cli) StatusClient

func (c *Cli) StatusClient() (pb.StatusServer, error)

StatusClient returns StatusClient client from connection

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