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