forked from openshift/origin
/
config.go
44 lines (31 loc) · 1.16 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl/cmd/config"
cmdconfig "github.com/openshift/origin/pkg/cmd/cli/config"
)
const (
configLong = `Manages the OpenShift config files.
Reference: https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/kubeconfig-file.md`
configExample = ` // Change the config context to use
%[1]s %[2]s use-context my-context
// Set the value of a config preference
%[1]s %[2]s set preferences.some true`
)
func NewCmdConfig(parentName, name string) *cobra.Command {
pathOptions := &config.PathOptions{
GlobalFile: cmdconfig.RecommendedHomeFile,
EnvVar: cmdconfig.OpenShiftConfigPathEnvVar,
ExplicitFileFlag: cmdconfig.OpenShiftConfigFlagName,
GlobalFileSubpath: cmdconfig.OpenShiftConfigHomeDirFileName,
LoadingRules: cmdconfig.NewOpenShiftClientConfigLoadingRules(),
}
pathOptions.LoadingRules.DoNotResolvePaths = true
cmd := config.NewCmdConfig(pathOptions, os.Stdout)
cmd.Short = "Change configuration files for the client"
cmd.Long = configLong
cmd.Example = fmt.Sprintf(configExample, parentName, name)
return cmd
}