essobedo commented on code in PR #3599: URL: https://github.com/apache/camel-k/pull/3599#discussion_r962677365
########## pkg/cmd/config.go: ########## @@ -0,0 +1,163 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You 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 cmd + +import ( + "errors" + "fmt" + "os" + "path/filepath" + + "github.com/spf13/cobra" + "github.com/spf13/viper" + "gopkg.in/yaml.v2" +) + +// ConfigFolder defines the different types of folder containing the configuration file +type ConfigFolder string + +const ( + // The path of the folder containing the configuration file is retrieved from the environment + // variable KAMEL_CONFIG_PATH + ConfigFolderEnvVar ConfigFolder = "env" + // The path of the folder containing the configuration file is $HOME/.kamel + ConfigFolderHome ConfigFolder = "home" + // The folder containing the configuration file is .kamel located in the working directory + ConfigFolderSubDirectory ConfigFolder = "sub" + // The folder containing the configuration file is the working directory + ConfigFolderWorking ConfigFolder = "working" + // The folder containing the configuration file is the directory currently used by the kamel script + ConfigFolderUsed ConfigFolder = "used" +) + +func newCmdConfig(rootCmdOptions *RootCmdOptions) (*cobra.Command, *configCmdOptions) { + options := configCmdOptions{} + cmd := cobra.Command{ + Use: "config", + Short: "Configure the default settings", + PreRunE: decode(&options), + Args: options.validateArgs, + RunE: options.run, + } + + cmd.Flags().String("folder", "used", "The type of folder containing the configuration file to read/write. The supported values are env, home, sub, working and used for respectively $KAMEL_CONFIG_PATH, $HOME/.kamel, .kamel, . and the folder used by kamel") Review Comment: If you use the flag `save` on commands like `install` and `run`, if `$KAMEL_CONFIG_PATH` is not set and the config file doesn't exist in the 3 other locations, by default, it will save the changes in the working directory while you could rather prefer to set it in the home directory for example so this config command can allow you to have better control on where it should be stored by creating a config file before. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org