Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CantRunInteractiveCASetupErr = errors.New("EnsureCA: Could not resort to interactive CA setup: non-interactive frontend.")
View Source
var Command = &cli.Command{ Name: "setup", Usage: "Setup Komagome PKI", Flags: append(structflags.MustPopulateFlagsFromStruct(&Config{}), &cli.BoolFlag{ Name: "dump-template", Usage: "dump configuration template yaml without making actual changes", }, ), Action: func(c *cli.Context) error { env := action.GlobalEnvironment slog := env.Logger.Sugar() af := c.App.Metadata["AppFlags"].(*appflags.AppFlags) profile, err := env.Profile() if err != nil { return err } slog.Debugf("config dump: %+v", af) var cfg *Config if c.Bool("dump-template") || !af.NoDefault { slog.Debugf("Constructing default config.") cfg = DefaultConfig(env) } else { slog.Debugf("Config is from scratch.") cfg = &Config{Setup: setup.EmptyConfig()} } if cfgbs, ok := c.App.Metadata["config"]; ok { r := bytes.NewBuffer(cfgbs.([]byte)) d := yaml.NewDecoder(r) d.KnownFields(true) if err := d.Decode(cfg); err != nil { return err } } if err := structflags.PopulateStructFromCliContext(cfg, c); err != nil { return err } if c.Bool("dump-template") { if err := frontend.DumpTemplate(configTemplateText, cfg); err != nil { return err } return nil } mode := AllowNonInteractiveSetup if af.NoDefault { mode = AllowNonInteractiveSetupAndRequireCompatibleConfig } if err := EnsureCA(env, cfg, profile, mode); err != nil { return err } if err := CopyCACert(env, cfg, profile); err != nil { return err } return nil }, }
Functions ¶
func CopyCACert ¶ added in v0.3.0
func EnsureCA ¶
func EnsureCA(env *action.Environment, cfg *Config, profile *storage.Profile, mode EnsureCAMode) error
Types ¶
type Config ¶ added in v0.1.0
type Config struct { Setup *setup.Config `yaml:",inline" flags:""` CopyCACertPath string `yaml:"copyCACertPath" flags:"copy-ca-cert-path,copy CA cert to the specified path,,path"` // This is here to avoid yaml.v3 Decoder with KnownFields(true) throwing error for valid AppFlags fields XXX_AppFlags appflags.AppFlags `yaml:",inline"` }
func DefaultConfig ¶ added in v0.1.0
func DefaultConfig(env *action.Environment) *Config
func EmptyConfig ¶ added in v0.3.0
func EmptyConfig() *Config
type EnsureCAMode ¶ added in v0.1.0
type EnsureCAMode int
const ( DisallowNonInteractiveSetup EnsureCAMode = iota AllowNonInteractiveSetup AllowNonInteractiveSetupAndRequireCompatibleConfig )
type IncompatibleCertErr ¶ added in v0.1.0
type IncompatibleCertErr struct {
Wrap error
}
func (IncompatibleCertErr) Error ¶ added in v0.1.0
func (e IncompatibleCertErr) Error() string
func (IncompatibleCertErr) Is ¶ added in v0.1.0
func (IncompatibleCertErr) Is(target error) bool
func (IncompatibleCertErr) Unwrap ¶ added in v0.1.0
func (e IncompatibleCertErr) Unwrap() error
Click to show internal directories.
Click to hide internal directories.