From 41f4a633f5903d6aad13f7b1587eedec937e1859 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Wed, 17 Mar 2021 10:58:28 +0100 Subject: [PATCH] add config-file flag to ocis, propagate log config to graph & graph-explorer --- graph-explorer/pkg/flagset/flagset.go | 6 +++--- graph/pkg/flagset/flagset.go | 6 +++--- ocis-pkg/config/config.go | 1 + ocis/pkg/command/root.go | 8 -------- ocis/pkg/flagset/flagset.go | 6 ++++++ 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/graph-explorer/pkg/flagset/flagset.go b/graph-explorer/pkg/flagset/flagset.go index df69a637d4..0fc5c27d8e 100644 --- a/graph-explorer/pkg/flagset/flagset.go +++ b/graph-explorer/pkg/flagset/flagset.go @@ -12,19 +12,19 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "log-level", Usage: "Set logging level", - EnvVars: []string{"GRAPH_EXPLORER_LOG_LEVEL"}, + EnvVars: []string{"GRAPH_EXPLORER_LOG_LEVEL", "OCIS_LOG_LEVEL"}, Destination: &cfg.Log.Level, }, &cli.BoolFlag{ Name: "log-pretty", Usage: "Enable pretty logging", - EnvVars: []string{"GRAPH_EXPLORER_LOG_PRETTY"}, + EnvVars: []string{"GRAPH_EXPLORER_LOG_PRETTY", "OCIS_LOG_PRETTY"}, Destination: &cfg.Log.Pretty, }, &cli.BoolFlag{ Name: "log-color", Usage: "Enable colored logging", - EnvVars: []string{"GRAPH_EXPLORER_LOG_COLOR"}, + EnvVars: []string{"GRAPH_EXPLORER_LOG_COLOR", "OCIS_LOG_COLOR"}, Destination: &cfg.Log.Color, }, } diff --git a/graph/pkg/flagset/flagset.go b/graph/pkg/flagset/flagset.go index 0f161e9754..bd9efe93ce 100644 --- a/graph/pkg/flagset/flagset.go +++ b/graph/pkg/flagset/flagset.go @@ -19,19 +19,19 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "log-level", Usage: "Set logging level", - EnvVars: []string{"GRAPH_LOG_LEVEL"}, + EnvVars: []string{"GRAPH_LOG_LEVEL", "OCIS_LOG_LEVEL"}, Destination: &cfg.Log.Level, }, &cli.BoolFlag{ Name: "log-pretty", Usage: "Enable pretty logging", - EnvVars: []string{"GRAPH_LOG_PRETTY"}, + EnvVars: []string{"GRAPH_LOG_PRETTY", "OCIS_LOG_PRETTY"}, Destination: &cfg.Log.Pretty, }, &cli.BoolFlag{ Name: "log-color", Usage: "Enable colored logging", - EnvVars: []string{"GRAPH_LOG_COLOR"}, + EnvVars: []string{"GRAPH_LOG_COLOR", "OCIS_LOG_COLOR"}, Destination: &cfg.Log.Color, }, } diff --git a/ocis-pkg/config/config.go b/ocis-pkg/config/config.go index 973107f7a6..e015f957a1 100644 --- a/ocis-pkg/config/config.go +++ b/ocis-pkg/config/config.go @@ -70,6 +70,7 @@ type Mode int // Config combines all available configuration parts. type Config struct { Mode Mode + File string Registry string Log Log diff --git a/ocis/pkg/command/root.go b/ocis/pkg/command/root.go index e57b41a34c..bda4b1b00f 100644 --- a/ocis/pkg/command/root.go +++ b/ocis/pkg/command/root.go @@ -46,14 +46,6 @@ func Execute() error { ) } - //r := registry.GetRegistry() - - //opts := micro.Options{ - // Registry: r, - //} - - //runtime.AddMicroPlatform(app, opts) - cli.HelpFlag = &cli.BoolFlag{ Name: "help,h", Usage: "Show the help", diff --git a/ocis/pkg/flagset/flagset.go b/ocis/pkg/flagset/flagset.go index b1f4445293..4d8da2033f 100644 --- a/ocis/pkg/flagset/flagset.go +++ b/ocis/pkg/flagset/flagset.go @@ -8,6 +8,12 @@ import ( // RootWithConfig applies cfg to the root flagset func RootWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ + &cli.StringFlag{ + Name: "config-file", + Usage: "Load config file from a non standard location.", + EnvVars: []string{"OCIS_CONFIG_FILE"}, + Destination: &cfg.File, + }, &cli.StringFlag{ Name: "ocis-log-level", Value: "info",