diff --git a/docs/docs/100-reference/01-command-line/acorn_install.md b/docs/docs/100-reference/01-command-line/acorn_install.md index 89d6c4f06..3c101a436 100644 --- a/docs/docs/100-reference/01-command-line/acorn_install.md +++ b/docs/docs/100-reference/01-command-line/acorn_install.md @@ -63,6 +63,7 @@ acorn install --propagate-project-annotation strings The list of keys of annotations to propagate from acorn project to app namespaces --propagate-project-label strings The list of keys of labels to propagate from acorn project to app namespaces --publish-builders Publish the builders through ingress to so build traffic does not traverse the api-server + --quiet Only output errors encountered during installation --record-builds Keep a record of each acorn build that happens --registry-cpu string The CPU to allocate to the registry in the format of : (example 200m:1000m) --registry-memory string The memory to allocate to the registry in the format of : (example 256Mi:1Gi) diff --git a/pkg/cli/install.go b/pkg/cli/install.go index dc4131288..1bf1f59d0 100644 --- a/pkg/cli/install.go +++ b/pkg/cli/install.go @@ -29,10 +29,10 @@ acorn install`, } type Install struct { - SkipChecks bool `usage:"Bypass installation checks"` - - Image string `usage:"Override the default image used for the deployment"` - Output string `usage:"Output manifests instead of applying them (json, yaml)" short:"o"` + SkipChecks bool `usage:"Bypass installation checks"` + Quiet bool `usage:"Only output errors encountered during installation"` + Image string `usage:"Override the default image used for the deployment"` + Output string `usage:"Output manifests instead of applying them (json, yaml)" short:"o"` APIServerReplicas *int `usage:"acorn-api deployment replica count" name:"api-server-replicas"` APIServerPodAnnotations []string `usage:"annotations to apply to acorn-api pods" name:"api-server-pod-annotations" split:"false"` @@ -96,6 +96,7 @@ func (i *Install) Run(cmd *cobra.Command, args []string) error { opts := &install.Options{ SkipChecks: i.SkipChecks, + Quiet: i.Quiet, OutputFormat: i.Output, Config: i.Config, APIServerReplicas: i.APIServerReplicas, diff --git a/pkg/install/install.go b/pkg/install/install.go index 3159f39a5..dfd1543da 100644 --- a/pkg/install/install.go +++ b/pkg/install/install.go @@ -66,6 +66,7 @@ type Options struct { ControllerServiceAccountAnnotations map[string]string Config apiv1.Config Progress progress.Builder + Quiet bool } func (o *Options) complete() *Options { @@ -75,7 +76,11 @@ func (o *Options) complete() *Options { } if o.Progress == nil { - o.Progress = &term.Builder{} + if o.Quiet { + o.Progress = &term.QuietBuilder{} + } else { + o.Progress = &term.Builder{} + } } if o.APIServerReplicas == nil { @@ -293,7 +298,9 @@ func Install(ctx context.Context, image string, opts *Options) error { } } - pterm.Success.Println("Installation done") + if !opts.Quiet { + pterm.Success.Println("Installation done") + } return nil } diff --git a/pkg/term/quiet.go b/pkg/term/quiet.go new file mode 100644 index 000000000..d029f856c --- /dev/null +++ b/pkg/term/quiet.go @@ -0,0 +1,42 @@ +package term + +import ( + "github.com/acorn-io/runtime/pkg/install/progress" + "github.com/sirupsen/logrus" +) + +type QuietBuilder struct { +} + +func (b *QuietBuilder) New(msg string) progress.Progress { + return newQuietSpinner(msg) +} + +type quietSpinner struct { + text string +} + +func newQuietSpinner(text string) *quietSpinner { + return &quietSpinner{ + text: text, + } +} + +func (s *quietSpinner) Fail(err error) error { + if err != nil { + logrus.Errorf("Error encountered during '%v': %v", s.text, err) + } + return err +} + +func (*quietSpinner) Infof(string, ...any) { + // No-op, we're being quiet +} + +func (*quietSpinner) SuccessWithWarning(string, ...any) { + // No-op, we're being quiet +} + +func (*quietSpinner) Success() { + // No-op, we're being quiet +}