diff --git a/cmd/all-in-one/main.go b/cmd/all-in-one/main.go index 1d8cd4a881ef..6a510dd3e9ae 100644 --- a/cmd/all-in-one/main.go +++ b/cmd/all-in-one/main.go @@ -33,6 +33,7 @@ import ( "github.com/jaegertracing/jaeger/cmd/all-in-one/setupcontext" collectorApp "github.com/jaegertracing/jaeger/cmd/collector/app" collectorFlags "github.com/jaegertracing/jaeger/cmd/collector/app/flags" + print_config "github.com/jaegertracing/jaeger/cmd/internal/config" "github.com/jaegertracing/jaeger/cmd/internal/docs" "github.com/jaegertracing/jaeger/cmd/internal/env" "github.com/jaegertracing/jaeger/cmd/internal/flags" @@ -229,6 +230,7 @@ by default uses only in-memory database.`, command.AddCommand(env.Command()) command.AddCommand(docs.Command(v)) command.AddCommand(status.Command(v, ports.CollectorAdminHTTP)) + command.AddCommand(print_config.Command(v)) config.AddFlags( v, diff --git a/cmd/collector/main.go b/cmd/collector/main.go index 8f86c0a23900..380d939857fe 100644 --- a/cmd/collector/main.go +++ b/cmd/collector/main.go @@ -28,6 +28,7 @@ import ( "github.com/jaegertracing/jaeger/cmd/collector/app" "github.com/jaegertracing/jaeger/cmd/collector/app/flags" + printConfig "github.com/jaegertracing/jaeger/cmd/internal/config" "github.com/jaegertracing/jaeger/cmd/internal/docs" "github.com/jaegertracing/jaeger/cmd/internal/env" cmdFlags "github.com/jaegertracing/jaeger/cmd/internal/flags" @@ -142,6 +143,7 @@ func main() { command.AddCommand(env.Command()) command.AddCommand(docs.Command(v)) command.AddCommand(status.Command(v, ports.CollectorAdminHTTP)) + command.AddCommand(printConfig.Command(v)) config.AddFlags( v, diff --git a/cmd/internal/config/config.go b/cmd/internal/config/config.go new file mode 100644 index 000000000000..271601971836 --- /dev/null +++ b/cmd/internal/config/config.go @@ -0,0 +1,41 @@ +// Copyright (c) 2018 The Jaeger Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package print_config + +import ( + "fmt" + "sort" + + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +func Command(v *viper.Viper) *cobra.Command { + c := &cobra.Command{ + Use: "print-config", + Short: "Print configurations", + Long: `Iterates through the environment variables and prints them out`, + RunE: func(cmd *cobra.Command, args []string) error { + keys := v.AllKeys() + sort.Strings(keys) + + for _, env := range keys { + value := v.Get(env) + fmt.Printf("%s=%v\n", env, value) + } + return nil + }, + } + return c +}