MCPcopy Create free account
hub / github.com/apache/camel-k / kamelPostAddCommandInit

Function kamelPostAddCommandInit

pkg/cmd/root.go:97–133  ·  view source on GitHub ↗
(cmd *cobra.Command, v *viper.Viper)

Source from the content-addressed store, hash-verified

95}
96
97func kamelPostAddCommandInit(cmd *cobra.Command, v *viper.Viper) error {
98 if err := bindPFlagsHierarchy(cmd, v); err != nil {
99 return err
100 }
101
102 configName := os.Getenv("KAMEL_CONFIG_NAME")
103 if configName == "" {
104 configName = DefaultConfigName
105 }
106
107 v.SetConfigName(configName)
108
109 configPath := os.Getenv("KAMEL_CONFIG_PATH")
110 if configPath != "" {
111 // if a specific config path is set, don't add
112 // default locations
113 v.AddConfigPath(configPath)
114 } else {
115 v.AddConfigPath(".")
116 v.AddConfigPath(".kamel")
117 v.AddConfigPath("$HOME/.kamel")
118 }
119
120 v.AutomaticEnv()
121 v.SetEnvKeyReplacer(strings.NewReplacer(
122 ".", "_",
123 "-", "_",
124 ))
125
126 if err := v.ReadInConfig(); err != nil {
127 if !errors.As(err, &viper.ConfigFileNotFoundError{}) {
128 return err
129 }
130 }
131
132 return nil
133}
134
135func addKamelSubcommands(cmd *cobra.Command, options *RootCmdOptions) {
136 cmd.AddCommand(cmdOnly(newCmdVersion(options)))

Callers 2

NewKamelCommandFunction · 0.85

Calls 1

bindPFlagsHierarchyFunction · 0.85

Tested by 1