kubens: Start implementing stubs

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
Ahmet Alp Balkan
2020-04-18 13:09:59 -07:00
parent 342d21683b
commit 1982becb15
16 changed files with 239 additions and 30 deletions

View File

@@ -0,0 +1,30 @@
package env
import (
"os"
"os/exec"
"github.com/mattn/go-isatty"
"github.com/ahmetb/kubectx/internal/env"
)
// isTerminal determines if given fd is a TTY.
func isTerminal(fd *os.File) bool {
return isatty.IsTerminal(fd.Fd())
}
// fzfInstalled determines if fzf(1) is in PATH.
func fzfInstalled() bool {
v, _ := exec.LookPath("fzf")
if v != "" {
return true
}
return false
}
// IsInteractiveMode determines if we can do choosing with fzf.
func IsInteractiveMode(stdout *os.File) bool {
v := os.Getenv(env.EnvFZFIgnore)
return v == "" && isTerminal(stdout) && fzfInstalled()
}