Handle namespace
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Rob Watson 2022-06-10 21:38:38 +02:00
parent b1a8a75bdb
commit 5ebeabd3c1
1 changed files with 13 additions and 10 deletions

17
main.go
View File

@ -9,12 +9,14 @@ import (
"os"
"git.netflux.io/rob/kubectl-persistent-logger/logs"
corev1 "k8s.io/api/core/v1"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
clientconfig "sigs.k8s.io/controller-runtime/pkg/client/config"
)
var (
version = "0.1.0"
gitChanges = "unknown"
gitSHA1 = "unknown"
buildTime = "unknown"
@ -22,20 +24,22 @@ var (
func main() {
var (
namespace string
container string
strictExist bool
debug bool
version bool
printVersion bool
)
flag.StringVar(&namespace, "namespace", corev1.NamespaceDefault, "namespace")
flag.StringVar(&container, "container", "", "name of a specific container")
flag.BoolVar(&strictExist, "strict", false, "require deployment to exist on launch")
flag.BoolVar(&debug, "debug", false, "enable debug logging to stderr")
flag.BoolVar(&version, "version", false, "print version and exit")
flag.BoolVar(&printVersion, "version", false, "print version and exit")
flag.Parse()
if version {
fmt.Fprintf(os.Stderr, "kubectl-persistent-logger, gitSHA1 = %s, gitChanges = %s, buildTime = %v\n", gitSHA1, gitChanges, buildTime)
if printVersion {
fmt.Fprintf(os.Stderr, "kubectl-persistent-logger %s, gitSHA1 = %s, gitChanges = %s, buildTime = %v\n", version, gitSHA1, gitChanges, buildTime)
os.Exit(0)
}
@ -59,7 +63,7 @@ func main() {
params = logs.WatcherParams{
Type: kind,
Name: flag.Arg(1),
Namespace: "default",
Namespace: namespace,
}
default:
flag.Usage()
@ -81,7 +85,6 @@ func main() {
log.Fatal(err)
}
ctx := context.Background()
watcher := logs.NewWatcher(
params,
logs.KubernetesClient{Typed: clientset, Untyped: dynamicclient},
@ -89,7 +92,7 @@ func main() {
os.Stdout,
logger,
)
if err := watcher.Watch(ctx); err != nil {
if err := watcher.Watch(context.Background()); err != nil {
log.Fatal(err)
}
}