本文整理汇总了Golang中github.com/openshift/origin/pkg/cmd/cli/config.NewOpenShiftClientConfigLoadingRules函数的典型用法代码示例。如果您正苦于以下问题:Golang NewOpenShiftClientConfigLoadingRules函数的具体用法?Golang NewOpenShiftClientConfigLoadingRules怎么用?Golang NewOpenShiftClientConfigLoadingRules使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewOpenShiftClientConfigLoadingRules函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: loggedInUserFactory
func loggedInUserFactory() (*clientcmd.Factory, error) {
cfg, err := config.NewOpenShiftClientConfigLoadingRules().Load()
if err != nil {
return nil, err
}
defaultCfg := kclientcmd.NewDefaultClientConfig(*cfg, &kclientcmd.ConfigOverrides{})
return clientcmd.NewFactory(defaultCfg), nil
}
开发者ID:Xmagicer,项目名称:origin,代码行数:8,代码来源:project.go
示例2: DefaultClientConfig
func DefaultClientConfig(flags *pflag.FlagSet) clientcmd.ClientConfig {
loadingRules := config.NewOpenShiftClientConfigLoadingRules()
flags.StringVar(&loadingRules.ExplicitPath, config.OpenShiftConfigFlagName, "", "Path to the config file to use for CLI requests.")
overrides := &clientcmd.ConfigOverrides{}
overrideFlags := clientcmd.RecommendedConfigOverrideFlags("")
overrideFlags.ContextOverrideFlags.Namespace.ShortName = "n"
overrideFlags.AuthOverrideFlags.Username.LongName = ""
overrideFlags.AuthOverrideFlags.Password.LongName = ""
clientcmd.BindOverrideFlags(overrides, flags, overrideFlags)
clientConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, overrides)
return clientConfig
}
开发者ID:cjnygard,项目名称:origin,代码行数:15,代码来源:clientconfig.go
示例3: getKubeConfig
func (d *NetworkDiagnostic) getKubeConfig() ([]byte, error) {
// KubeConfig path search order:
// 1. User given config path
// 2. Default admin config paths
// 3. Default openshift client config search paths
paths := []string{}
paths = append(paths, d.ClientFlags.Lookup(config.OpenShiftConfigFlagName).Value.String())
paths = append(paths, diagutil.AdminKubeConfigPaths...)
paths = append(paths, config.NewOpenShiftClientConfigLoadingRules().Precedence...)
for _, path := range paths {
if configData, err := ioutil.ReadFile(path); err == nil {
return configData, nil
}
}
return nil, fmt.Errorf("Unable to find kube config")
}
开发者ID:LalatenduMohanty,项目名称:origin,代码行数:17,代码来源:setup.go
示例4: NewCmdConfig
// NewCmdConfig is a wrapper for the Kubernetes cli config command
func NewCmdConfig(parentName, name string) *cobra.Command {
pathOptions := &kclientcmd.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)
adjustCmdExamples(cmd, parentName, name)
return cmd
}
开发者ID:ncdc,项目名称:origin,代码行数:20,代码来源:wrappers.go
示例5: NewCmdConfig
// NewCmdConfig is a wrapper for the Kubernetes cli config command
func NewCmdConfig(parentName, name string, out, errOut io.Writer) *cobra.Command {
pathOptions := &kclientcmd.PathOptions{
GlobalFile: cmdconfig.RecommendedHomeFile,
EnvVar: cmdconfig.OpenShiftConfigPathEnvVar,
ExplicitFileFlag: cmdconfig.OpenShiftConfigFlagName,
GlobalFileSubpath: cmdconfig.OpenShiftConfigHomeDirFileName,
LoadingRules: cmdconfig.NewOpenShiftClientConfigLoadingRules(),
}
pathOptions.LoadingRules.DoNotResolvePaths = true
cmd := config.NewCmdConfig(pathOptions, out, errOut)
cmd.Short = "Change configuration files for the client"
cmd.Long = configLong
cmd.Example = fmt.Sprintf(configExample, parentName, name)
// normalize long descs and examples
// TODO remove when normalization is moved upstream
templates.NormalizeAll(cmd)
adjustCmdExamples(cmd, parentName, name)
return cmd
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:23,代码来源:wrappers.go
示例6: main
func main() {
cmds := &cobra.Command{
Use: "qtz",
Short: "Quantezza CLI.",
Long: `Quantezza Data Foundry client.`,
// Run: runHelp,
}
in, out := os.Stdin, os.Stdout
loadingRules := config.NewOpenShiftClientConfigLoadingRules()
cmds.PersistentFlags().StringVar(&loadingRules.ExplicitPath, config.OpenShiftConfigFlagName, "", "Path to the config file to use for CLI requests.")
overrides := &clientcmd.ConfigOverrides{}
// overrideFlags := clientcmd.RecommendedConfigOverrideFlags("")
// // overrideFlags.ContextOverrideFlags.Namespace.ShortName = "n"
// overrideFlags.ClusterOverrideFlags.APIVersion.LongName = ""
// overrideFlags.ClusterOverrideFlags.CertificateAuthority.LongName = ""
// overrideFlags.ClusterOverrideFlags.CertificateAuthority.LongName = ""
// overrideFlags.ContextOverrideFlags.ClusterName.LongName = ""
// overrideFlags.ContextOverrideFlags.Namespace.LongName = ""
//
// overrideFlags.AuthOverrideFlags.ClientCertificate.LongName = ""
//
// clientcmd.BindOverrideFlags(overrides, cmds.PersistentFlags(), overrideFlags)
clientConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, overrides)
f := occlientcmd.NewFactory(clientConfig)
fullName := "qtz"
loginCmd := occmd.NewCmdLogin(fullName, f, in, out)
cmds.AddCommand(loginCmd)
whoamiCmd := occmd.NewCmdWhoAmI(occmd.WhoAmIRecommendedCommandName, fullName+" "+occmd.WhoAmIRecommendedCommandName, f, out)
cmds.AddCommand(whoamiCmd)
cmds.AddCommand(occmd.NewCmdProject(fullName+" project", f, out))
cmds.Execute()
}
开发者ID:quantezza,项目名称:qtz,代码行数:39,代码来源:qtz.go
示例7: DefaultClientConfig
func DefaultClientConfig(flags *pflag.FlagSet) clientcmd.ClientConfig {
loadingRules := config.NewOpenShiftClientConfigLoadingRules()
flags.StringVar(&loadingRules.ExplicitPath, config.OpenShiftConfigFlagName, "", "Path to the config file to use for CLI requests.")
cobra.MarkFlagFilename(flags, config.OpenShiftConfigFlagName)
// set our explicit defaults
defaultOverrides := &clientcmd.ConfigOverrides{ClusterDefaults: clientcmdapi.Cluster{Server: os.Getenv("KUBERNETES_MASTER")}}
loadingRules.DefaultClientConfig = clientcmd.NewDefaultClientConfig(clientcmdapi.Config{}, defaultOverrides)
overrides := &clientcmd.ConfigOverrides{ClusterDefaults: defaultOverrides.ClusterDefaults}
overrideFlags := clientcmd.RecommendedConfigOverrideFlags("")
overrideFlags.ContextOverrideFlags.Namespace.ShortName = "n"
overrideFlags.AuthOverrideFlags.Username.LongName = ""
overrideFlags.AuthOverrideFlags.Password.LongName = ""
clientcmd.BindOverrideFlags(overrides, flags, overrideFlags)
cobra.MarkFlagFilename(flags, overrideFlags.AuthOverrideFlags.ClientCertificate.LongName)
cobra.MarkFlagFilename(flags, overrideFlags.AuthOverrideFlags.ClientKey.LongName)
cobra.MarkFlagFilename(flags, overrideFlags.ClusterOverrideFlags.CertificateAuthority.LongName)
clientConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, overrides)
return clientConfig
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:23,代码来源:clientconfig.go
示例8: Check
// Check is part of the Diagnostic interface; it runs the actual diagnostic logic
func (d *ConfigLoading) Check() types.DiagnosticResult {
r := types.NewDiagnosticResult("ConfigLoading")
confFlagValue := d.ClientFlags.Lookup(d.ConfFlagName).Value.String()
var foundPath string
rules := config.NewOpenShiftClientConfigLoadingRules()
paths := append([]string{confFlagValue}, rules.Precedence...)
for index, path := range paths {
errmsg := ""
switch index {
case 0:
errmsg = fmt.Sprintf("--%s specified that client config should be at %s\n", d.ConfFlagName, path)
case len(paths) - 1: // config in ~/.kube
// no error message indicated if it is not there... user didn't say it would be
default: // can be multiple paths from the env var in theory; all cases should go here
if len(os.Getenv(config.OpenShiftConfigPathEnvVar)) != 0 {
errmsg = fmt.Sprintf("Env var %s specified that client config could be at %s\n", config.OpenShiftConfigPathEnvVar, path)
}
}
if d.canOpenConfigFile(path, errmsg, r) && foundPath == "" {
d.successfulLoad = true
foundPath = path
}
}
if foundPath != "" {
if confFlagValue != "" && confFlagValue != foundPath {
// found config but not where --config said
r.Error("DCli1001", nil, fmt.Sprintf(`
The client configuration file was not found where the --%s flag indicated:
%s
A config file was found at the following location:
%s
If you wish to use this file for client configuration, you can specify it
with the --%[1]s flag, or just not specify the flag.
`, d.ConfFlagName, confFlagValue, foundPath))
}
} else { // not found, check for master-generated ones to recommend
if confFlagValue != "" {
r.Error("DCli1002", nil, fmt.Sprintf("Did not find config file where --%s=%s indicated", d.ConfFlagName, confFlagValue))
}
adminWarningF := `
No client config file was available; however, one exists at
%[2]s
which may have been generated automatically by the master.
If you want to use this config, you should copy it to the
standard location (%[3]s),
or you can set the environment variable %[1]s:
export %[1]s=%[2]s
If not, obtain a config file and place it in the standard
location for use by the client and diagnostics.
`
// look for it in auto-generated locations when not found properly
for _, path := range util.AdminKubeConfigPaths {
msg := fmt.Sprintf("Looking for a possible client config at %s\n", path)
if d.canOpenConfigFile(path, msg, r) {
r.Warn("DCli1003", nil, fmt.Sprintf(adminWarningF, config.OpenShiftConfigPathEnvVar, path, config.RecommendedHomeFile))
break
}
}
}
return r
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:64,代码来源:config_loading.go
注:本文中的github.com/openshift/origin/pkg/cmd/cli/config.NewOpenShiftClientConfigLoadingRules函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论