Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

feat: add CLI flag to print version #406

Merged
merged 1 commit into from
Nov 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pkg/phlare/phlare.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ type Config struct {
MultitenancyEnabled bool `yaml:"multitenancy_enabled,omitempty"`
Analytics usagestats.Config `yaml:"analytics"`

ConfigFile string `yaml:"-"`
ConfigFile string `yaml:"-"`
ShowVersion bool `yaml:"-"`
}

func newDefaultConfig() *Config {
Expand Down Expand Up @@ -92,6 +93,7 @@ func (c *Config) RegisterFlagsWithContext(ctx context.Context, f *flag.FlagSet)
f.Var(&c.Target, "target", "Comma-separated list of Phlare modules to load. "+
"The alias 'all' can be used in the list to load a number of core modules and will enable single-binary mode. ")
f.BoolVar(&c.MultitenancyEnabled, "auth.multitenancy-enabled", false, "When set to true, incoming HTTP requests must specify tenant ID in HTTP X-Scope-OrgId header. When set to false, tenant ID anonymous is used instead.")
f.BoolVar(&c.ShowVersion, "version", false, "Show the version of phlare and exit")

c.registerServerFlagsWithChangedDefaultValues(f)
c.AgentConfig.RegisterFlags(f)
Expand Down Expand Up @@ -192,6 +194,11 @@ func New(cfg Config) (*Phlare, error) {
logger := initLogger(&cfg.Server)
usagestats.Edition("oss")

if cfg.ShowVersion {
fmt.Println(version.Print("phlare"))
os.Exit(0)
}

phlare := &Phlare{
Cfg: cfg,
logger: logger,
Expand Down