mirror of
https://github.com/kubernetes/client-go.git
synced 2025-08-14 13:33:22 +00:00
Fix kubectl version should print version info
Kubernetes-commit: 948f4de2dbba3affca2de460d836158cbde5db78
This commit is contained in:
parent
1be5940d0d
commit
1c7ee45b9b
@ -30,11 +30,24 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
ErrNoContext = errors.New("no context chosen")
|
ErrNoContext = errors.New("no context chosen")
|
||||||
ErrEmptyConfig = errors.New("no configuration has been provided, try setting KUBERNETES_MASTER environment variable")
|
ErrEmptyConfig = NewEmptyConfigError("no configuration has been provided, try setting KUBERNETES_MASTER environment variable")
|
||||||
// message is for consistency with old behavior
|
// message is for consistency with old behavior
|
||||||
ErrEmptyCluster = errors.New("cluster has no server defined")
|
ErrEmptyCluster = errors.New("cluster has no server defined")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// NewEmptyConfigError returns an error wrapping the given message which IsEmptyConfig() will recognize as an empty config error
|
||||||
|
func NewEmptyConfigError(message string) error {
|
||||||
|
return &errEmptyConfig{message}
|
||||||
|
}
|
||||||
|
|
||||||
|
type errEmptyConfig struct {
|
||||||
|
message string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *errEmptyConfig) Error() string {
|
||||||
|
return e.message
|
||||||
|
}
|
||||||
|
|
||||||
type errContextNotFound struct {
|
type errContextNotFound struct {
|
||||||
ContextName string
|
ContextName string
|
||||||
}
|
}
|
||||||
@ -60,9 +73,14 @@ func IsContextNotFound(err error) bool {
|
|||||||
func IsEmptyConfig(err error) bool {
|
func IsEmptyConfig(err error) bool {
|
||||||
switch t := err.(type) {
|
switch t := err.(type) {
|
||||||
case errConfigurationInvalid:
|
case errConfigurationInvalid:
|
||||||
return len(t) == 1 && t[0] == ErrEmptyConfig
|
if len(t) != 1 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
_, ok := t[0].(*errEmptyConfig)
|
||||||
|
return ok
|
||||||
}
|
}
|
||||||
return err == ErrEmptyConfig
|
_, ok := err.(*errEmptyConfig)
|
||||||
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
// errConfigurationInvalid is a set of errors indicating the configuration is invalid.
|
// errConfigurationInvalid is a set of errors indicating the configuration is invalid.
|
||||||
|
Loading…
Reference in New Issue
Block a user