Merge "[#28] Fix bad defaults for config file paths."
This commit is contained in:
commit
07784ce97a
@ -47,7 +47,7 @@ func TestFlagLoading(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "default, no flags",
|
name: "default, no flags",
|
||||||
args: []string{},
|
args: []string{},
|
||||||
expected: "$HOME/.airship/config",
|
expected: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "alternate airshipconfig",
|
name: "alternate airshipconfig",
|
||||||
|
@ -12,4 +12,4 @@ const (
|
|||||||
Wide = "wide"
|
Wide = "wide"
|
||||||
)
|
)
|
||||||
|
|
||||||
const HomePlaceholder = "$HOME"
|
const HomeEnvVar = "$HOME"
|
||||||
|
@ -24,15 +24,27 @@ type AirshipCTLSettings struct {
|
|||||||
// InitFlags adds the default settings flags to cmd
|
// InitFlags adds the default settings flags to cmd
|
||||||
func (a *AirshipCTLSettings) InitFlags(cmd *cobra.Command) {
|
func (a *AirshipCTLSettings) InitFlags(cmd *cobra.Command) {
|
||||||
flags := cmd.PersistentFlags()
|
flags := cmd.PersistentFlags()
|
||||||
flags.BoolVar(&a.Debug, "debug", false, "enable verbose output")
|
flags.BoolVar(
|
||||||
|
&a.Debug,
|
||||||
|
"debug",
|
||||||
|
false,
|
||||||
|
"enable verbose output")
|
||||||
|
|
||||||
flags.StringVar(&a.airshipConfigPath, config.FlagConfigFilePath,
|
defaultAirshipConfigDir := filepath.Join(HomeEnvVar, config.AirshipConfigDir)
|
||||||
filepath.Join(HomePlaceholder, config.AirshipConfigDir, config.AirshipConfig),
|
|
||||||
"Path to file for airshipctl configuration.")
|
|
||||||
|
|
||||||
flags.StringVar(&a.kubeConfigPath, clientcmd.RecommendedConfigPathFlag,
|
defaultAirshipConfigPath := filepath.Join(defaultAirshipConfigDir, config.AirshipConfig)
|
||||||
filepath.Join(HomePlaceholder, config.AirshipConfigDir, config.AirshipKubeConfig),
|
flags.StringVar(
|
||||||
"Path to kubeconfig associated with airshipctl configuration.")
|
&a.airshipConfigPath,
|
||||||
|
config.FlagConfigFilePath,
|
||||||
|
"",
|
||||||
|
`Path to file for airshipctl configuration. (default "`+defaultAirshipConfigPath+`")`)
|
||||||
|
|
||||||
|
defaultKubeConfigPath := filepath.Join(defaultAirshipConfigDir, config.AirshipKubeConfig)
|
||||||
|
flags.StringVar(
|
||||||
|
&a.kubeConfigPath,
|
||||||
|
clientcmd.RecommendedConfigPathFlag,
|
||||||
|
"",
|
||||||
|
`Path to kubeconfig associated with airshipctl configuration. (default "`+defaultKubeConfigPath+`")`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AirshipCTLSettings) Config() *config.Config {
|
func (a *AirshipCTLSettings) Config() *config.Config {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user