fleet/cli/config_dump.go
Zachary Wasserman 885db1a597 Refactoring for config patterns (#159)
This PR refactors most of the codebase to use the new config patterns implemented in #149. Now the core service keeps a copy of the KolideConfig struct, and service methods can reference the configuration in that struct when they need it. The most significant refactoring is in the sessions code, separating the business logic from the storage layer.
2016-09-14 09:11:06 -07:00

37 lines
857 B
Go

package cli
import (
"fmt"
"github.com/kolide/kolide-ose/config"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
)
func createConfigDumpCmd(configManager config.Manager) *cobra.Command {
var configDumpCmd = &cobra.Command{
Use: "config_dump",
Short: "Dump the parsed configuration in yaml format",
Long: `
Dump the parsed configuration in yaml format.
Kolide retrieves configuration options from many locations, and it can be
useful to see the result of merging those configs.
The following precedence is used when reading configs:
1. CLI flags
2. Environment Variables
3. Config File
4. Default Values
`,
Run: func(cmd *cobra.Command, args []string) {
buf, err := yaml.Marshal(configManager.LoadConfig())
if err != nil {
initFatal(err, "marshalling config to yaml")
}
fmt.Println(string(buf))
}}
return configDumpCmd
}