oh-my-posh/segment_kubectl.go
Travis Illig 7537f6dc70 feat: kubectl context display segment
Segment displays the current Kubernetes context name when available.
2020-10-15 10:54:49 -07:00

25 lines
449 B
Go

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 {
if !k.env.hasCommand("kubectl") {
return false
}
k.contextName = k.env.runCommand("kubectl", "config", "current-context")
return true
}