cli

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: MIT Imports: 24 Imported by: 0

README

GitHub Anchor Banner

Introduction

anchor provides a command line interface for the Anchor.dev certificate management platform.

  • Need a secure browser context for development?
  • There's a better option than localhost.
  • Effortlessly get HTTPS in your local development environment. Get set up in two easy commmands.

For more information visit Lcl.host or the Anchor Docs

Installation

macOS

Available via Homebrew or as a downloadable binary from the releases page.

Homebrew

Install:

brew install anchordotdev/tap/anchor

Upgrade:

brew update && brew upgrade anchordotdev/tap/anchor
Linux & BSD

Available via Homebrew or as a downloadable binary from the releases page.

Homebrew

Install:

brew install anchordotdev/tap/anchor

Upgrade:

brew upgrade anchordotdev/tap/anchor
Windows

Available via Winget or as a downloadable binary from the releases page.

Winget

Install:

winget install anchor

Upgrade:

winget upgrade anchor
Install from source

Install:

go install github.com/anchordotdev/cli/cmd/anchor@latest

Setup

  • After installing, run anchor lcl and follow the instructions.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CmdRoot = NewCmd[ShowHelp](nil, "anchor", func(cmd *cobra.Command) {
	cfg := ConfigFromCmd(cmd)

	cmd.PersistentFlags().StringVar(&cfg.API.Token, "api-token", Defaults.API.Token, "Anchor API personal access token (PAT).")
	cmd.PersistentFlags().StringVar(&cfg.API.URL, "api-url", Defaults.API.URL, "Anchor API endpoint URL.")
	cmd.PersistentFlags().StringVar(&cfg.File.Path, "config", Defaults.File.Path, "Service configuration file.")
	cmd.PersistentFlags().StringVar(&cfg.Dashboard.URL, "dashboard-url", Defaults.Dashboard.URL, "Anchor dashboard URL.")
	cmd.PersistentFlags().BoolVar(&cfg.File.Skip, "skip-config", Defaults.File.Skip, "Skip loading configuration file.")

	if err := cmd.PersistentFlags().MarkHidden("api-url"); err != nil {
		panic(err)
	}
	if err := cmd.PersistentFlags().MarkHidden("dashboard-url"); err != nil {
		panic(err)
	}
})
View Source
var Defaults = defaultConfig()
View Source
var Executable string
View Source
var Version = struct {
	Version, Commit, Date string

	Os, Arch string
}{
	Version: "dev",
	Commit:  "none",
	Date:    "unknown",
	Os:      runtime.GOOS,
	Arch:    runtime.GOARCH,
}

Functions

func CalledAsFromContext added in v0.1.0

func CalledAsFromContext(ctx context.Context) string

func Client

func Client(cfg *Config) (http.Client, error)

func ContextWithCalledAs added in v0.1.0

func ContextWithCalledAs(ctx context.Context, calledAs string) context.Context

func ContextWithConfig added in v0.0.21

func ContextWithConfig(ctx context.Context, cfg *Config) context.Context

func IsDevVersion added in v0.0.25

func IsDevVersion() bool

func NewCmd added in v0.0.21

func NewCmd[T UIer](parent *cobra.Command, name string, fn func(*cobra.Command)) *cobra.Command

func NewTestCmd added in v0.0.23

func NewTestCmd(cmd *cobra.Command) *cobra.Command

func ReleaseTagName added in v0.0.25

func ReleaseTagName() string

func ReportError added in v0.0.26

func ReportError(ctx context.Context, err error, drv *ui.Driver, cmd *cobra.Command, args []string)

func UserAgent added in v0.0.25

func UserAgent() string

func VersionString added in v0.0.25

func VersionString() string

Types

type CmdDef added in v0.0.21

type CmdDef struct {
	Name string

	Aliases []string
	Args    cobra.PositionalArgs
	Long    string
	Short   string
	Use     string

	SubDefs []CmdDef
}

type Config

type Config struct {
	NonInteractive bool `env:"NON_INTERACTIVE" toml:",omitempty,readonly"`

	API struct {
		URL   string `default:"https://api.anchor.dev/v0" env:"API_URL" toml:"url,omitempty"`
		Token string `env:"API_TOKEN" toml:"api-token,omitempty,readonly"`
	} `toml:"api,omitempty"`

	File struct {
		Path string `default:"anchor.toml" env:"ANCHOR_CONFIG" toml:",omitempty,readonly"`
		Skip bool   `env:"ANCHOR_SKIP_CONFIG" toml:",omitempty,readonly"`
	} `toml:",omitempty,readonly"`

	Dashboard struct {
		URL string `default:"https://anchor.dev" env:"ANCHOR_HOST" toml:"url,omitempty"`
	} `toml:"dashboard,omitempty"`

	Lcl struct {
		LclHostURL string `default:"https://lcl.host" env:"LCL_HOST_URL" toml:",omitempty,readonly"`

		RealmAPID string `env:"REALM" toml:"realm-apid,omitempty"`

		Diagnostic struct {
			Addr      string `default:":4433" env:"DIAGNOSTIC_ADDR" toml:",omitempty"`
			Subdomain string `env:"DIAGNOSTIC_SUBDOMAIN" toml:",omitempty"`
		} `toml:",omitempty,readonly"`

		MkCert struct {
			Domains []string `flag:"domains" toml:",omitempty"`
			SubCa   string   `flag:"subca" toml:",omitempty"`
		} `toml:",omitempty,readonly"`
	} `toml:"lcl-host,omitempty"`

	Org struct {
		APID string `env:"ORG" toml:"apid,omitempty"`
	} `toml:"org,omitempty"`

	Realm struct {
		APID string `env:"REALM"`
	} `toml:",omitempty,readonly"`

	Service struct {
		APID      string `env:"SERVICE" toml:"apid,omitempty"`
		Category  string `env:"SERVICE_CATEGORY" toml:"category,omitempty"`
		Framework string `env:"SERVICE_FRAMEWORK" toml:"framework,omitempty"`
		Name      string `env:"SERVICE_NAME" toml:",omitempty,readonly"`

		EnvOutput string `env:"ENV_OUTPUT" toml:",omitempty,readonly"`
		CertStyle string `env:"CERT_STYLE" toml:"cert-style,omitempty"`
	} `toml:"service,omitempty"`

	Trust struct {
		NoSudo bool `flag:"no-sudo" env:"NO_SUDO" toml:",omitempty"`

		MockMode bool `env:"ANCHOR_CLI_TRUSTSTORE_MOCK_MODE" toml:",omitempty"`

		Stores []string `default:"[homebrew,nss,system]" env:"TRUST_STORES" toml:",omitempty"`

		Clean struct {
			States []string `default:"[expired]" env:"CERT_STATES" toml:",omitempty"`
		} `toml:",omitempty"`
	} `toml:",omitempty,readonly"`

	Keyring struct {
		MockMode bool `env:"ANCHOR_CLI_KEYRING_MOCK_MODE"`
	} `toml:",omitempty,readonly"`

	Test ConfigTest `fake:"-" toml:",omitempty,readonly"`
	TOML *Config    `fake:"-" toml:",omitempty,readonly"`
}

func ConfigFromCmd added in v0.0.21

func ConfigFromCmd(cmd *cobra.Command) *Config

func ConfigFromContext added in v0.0.21

func ConfigFromContext(ctx context.Context) *Config

func (*Config) AcmeURL added in v0.1.0

func (c *Config) AcmeURL(orgAPID string, realmAPID string, chainAPID string) string

func (*Config) GOOS added in v0.0.35

func (c *Config) GOOS() string

func (*Config) LclHostPort added in v0.1.0

func (c *Config) LclHostPort() *int

func (*Config) Load added in v0.1.0

func (c *Config) Load(ctx context.Context) error

func (*Config) ProcFS added in v0.0.35

func (c *Config) ProcFS() fs.FS

func (*Config) SetupGuideURL added in v0.1.0

func (c *Config) SetupGuideURL(orgAPID string, serviceAPID string) string

func (*Config) SystemFS added in v0.1.0

func (c *Config) SystemFS() SystemFS

func (*Config) Timestamp added in v0.0.35

func (c *Config) Timestamp() time.Time

func (*Config) WriteTOML added in v0.1.0

func (c *Config) WriteTOML() error

type ConfigTest added in v0.0.36

type ConfigTest struct {
	Prefer map[string]ConfigTestPrefer // values for prism prefer header

	ACME struct {
		URL string
	}
	Browserless bool      // run as though browserless
	GOOS        string    // change OS identifier in tests
	ProcFS      fs.FS     // change the proc filesystem in tests
	LclHostPort int       // specify lcl host port in tests
	SkipRunE    bool      // skip RunE for testing purposes
	SystemFS    SystemFS  // change the system filesystem in tests
	Timestamp   time.Time // timestamp to use/display in tests
}

values used for testing

type ConfigTestPrefer added in v0.0.38

type ConfigTestPrefer struct {
	Code    int    `desc:"override response status"`
	Dynamic bool   `desc:"set dynamic mocking"`
	Example string `desc:"override example"`
}

type ShowHelp added in v0.0.21

type ShowHelp struct{}

func (ShowHelp) UI added in v0.0.21

func (c ShowHelp) UI() UI

type SystemFS added in v0.1.0

type SystemFS interface {
	Open(string) (fs.File, error)
	ReadDir(string) ([]fs.DirEntry, error)
	Stat(string) (fs.FileInfo, error)
	WriteFile(string, []byte, os.FileMode) error
}

type UI added in v0.0.8

type UI struct {
	RunTUI func(context.Context, *ui.Driver) error
}

type UIer added in v0.0.21

type UIer interface {
	UI() UI
}

type UserError added in v0.0.39

type UserError struct {
	Err error
}

func (UserError) Error added in v0.0.39

func (u UserError) Error() string

Directories

Path Synopsis
api
Package api provides primitives to interact with the openapi HTTP API.
Package api provides primitives to interact with the openapi HTTP API.
cmd
oid
internal
lcl
Package truststore manages local trust stores and certificates.
Package truststore manages local trust stores and certificates.
ui

Jump to

Keyboard shortcuts

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