forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
34 lines (29 loc) · 1.22 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
package diagnostics
import (
"errors"
clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
"github.com/openshift/origin/pkg/cmd/cli/config"
clientdiagnostics "github.com/openshift/origin/pkg/diagnostics/client"
"github.com/openshift/origin/pkg/diagnostics/types"
)
// determine if we even have a client config
func (o DiagnosticsOptions) detectClientConfig() (bool, []types.DiagnosticError, []types.DiagnosticError) {
diagnostic := &clientdiagnostics.ConfigLoading{ConfFlagName: config.OpenShiftConfigFlagName, ClientFlags: o.ClientFlags}
o.Logger.Notice("CED2011", "Determining if client configuration exists for client/cluster diagnostics")
result := diagnostic.Check()
for _, entry := range result.Logs() {
o.Logger.LogEntry(entry)
}
return diagnostic.SuccessfulLoad(), result.Warnings(), result.Errors()
}
// use the base factory to return a raw config (not specific to a context)
func (o DiagnosticsOptions) buildRawConfig() (*clientcmdapi.Config, error) {
kubeConfig, configErr := o.Factory.OpenShiftClientConfig.RawConfig()
if configErr != nil {
return nil, configErr
}
if len(kubeConfig.Contexts) == 0 {
return nil, errors.New("No contexts found in config file.")
}
return &kubeConfig, nil
}