Add --quiet flag

pull/862/head
Carl Tashian 2 years ago
parent 91a25b52bd
commit 91be50cf70

@ -31,6 +31,7 @@ import (
type options struct { type options struct {
configFile string configFile string
linkedCAToken string linkedCAToken string
quiet bool
password []byte password []byte
issuerPassword []byte issuerPassword []byte
sshHostPassword []byte sshHostPassword []byte
@ -101,6 +102,14 @@ func WithLinkedCAToken(token string) Option {
} }
} }
// WithQuiet sets the quiet flag.
func WithQuiet(quiet bool) Option {
return func(o *options) {
o.quiet = quiet
}
}
// CA is the type used to build the complete certificate authority. It builds // CA is the type used to build the complete certificate authority. It builds
// the HTTP server, set ups the middlewares and the HTTP handlers. // the HTTP server, set ups the middlewares and the HTTP handlers.
type CA struct { type CA struct {
@ -288,9 +297,11 @@ func (ca *CA) Run() error {
var wg sync.WaitGroup var wg sync.WaitGroup
errs := make(chan error, 1) errs := make(chan error, 1)
log.Printf("Documentation: https://u.step.sm/docs/ca") if !ca.opts.quiet {
log.Printf("Community Discord: https://u.step.sm/discord") log.Printf("Documentation: https://u.step.sm/docs/ca")
log.Printf("Config File: %s", ca.opts.configFile) log.Printf("Community Discord: https://u.step.sm/discord")
log.Printf("Config File: %s", ca.opts.configFile)
}
if ca.insecureSrv != nil { if ca.insecureSrv != nil {
wg.Add(1) wg.Add(1)
@ -359,6 +370,7 @@ func (ca *CA) Reload() error {
WithSSHUserPassword(ca.opts.sshUserPassword), WithSSHUserPassword(ca.opts.sshUserPassword),
WithIssuerPassword(ca.opts.issuerPassword), WithIssuerPassword(ca.opts.issuerPassword),
WithLinkedCAToken(ca.opts.linkedCAToken), WithLinkedCAToken(ca.opts.linkedCAToken),
WithQuiet(ca.opts.quiet),
WithConfigFile(ca.opts.configFile), WithConfigFile(ca.opts.configFile),
WithDatabase(ca.auth.GetDatabase()), WithDatabase(ca.auth.GetDatabase()),
) )

@ -57,6 +57,10 @@ certificate issuer private key used in the RA mode.`,
Usage: "token used to enable the linked ca.", Usage: "token used to enable the linked ca.",
EnvVar: "STEP_CA_TOKEN", EnvVar: "STEP_CA_TOKEN",
}, },
cli.BoolFlag{
Name: "quiet",
Usage: "disable startup information",
},
}, },
} }
@ -68,6 +72,7 @@ func appAction(ctx *cli.Context) error {
issuerPassFile := ctx.String("issuer-password-file") issuerPassFile := ctx.String("issuer-password-file")
resolver := ctx.String("resolver") resolver := ctx.String("resolver")
token := ctx.String("token") token := ctx.String("token")
quiet := ctx.Bool("quiet")
// If zero cmd line args show help, if >1 cmd line args show error. // If zero cmd line args show help, if >1 cmd line args show error.
if ctx.NArg() == 0 { if ctx.NArg() == 0 {
@ -141,7 +146,8 @@ To get a linked authority token:
ca.WithSSHHostPassword(sshHostPassword), ca.WithSSHHostPassword(sshHostPassword),
ca.WithSSHUserPassword(sshUserPassword), ca.WithSSHUserPassword(sshUserPassword),
ca.WithIssuerPassword(issuerPassword), ca.WithIssuerPassword(issuerPassword),
ca.WithLinkedCAToken(token)) ca.WithLinkedCAToken(token),
ca.WithQuiet(quiet))
if err != nil { if err != nil {
fatal(err) fatal(err)
} }

Loading…
Cancel
Save