2020-10-15 10:48:41 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
type kubectl struct {
|
|
|
|
props *properties
|
|
|
|
env environmentInfo
|
|
|
|
contextName string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (k *kubectl) string() string {
|
|
|
|
return k.contextName
|
|
|
|
}
|
|
|
|
|
|
|
|
func (k *kubectl) init(props *properties, env environmentInfo) {
|
|
|
|
k.props = props
|
|
|
|
k.env = env
|
|
|
|
}
|
|
|
|
|
|
|
|
func (k *kubectl) enabled() bool {
|
2020-12-27 23:33:58 -08:00
|
|
|
commandPath, commandExists := k.env.hasCommand("kubectl")
|
|
|
|
if !commandExists {
|
2020-10-15 10:48:41 -07:00
|
|
|
return false
|
|
|
|
}
|
2020-12-27 23:33:58 -08:00
|
|
|
k.contextName, _ = k.env.runCommand(commandPath, "config", "current-context")
|
2020-11-02 09:32:40 -08:00
|
|
|
return k.contextName != ""
|
2020-10-15 10:48:41 -07:00
|
|
|
}
|