| 1 | /* |
| 2 | Copyright 2019 The Kubernetes Authors. |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package main |
| 18 | |
| 19 | import ( |
| 20 | "flag" |
| 21 | "fmt" |
| 22 | "os" |
| 23 | |
| 24 | "k8s.io/klog/v2" |
| 25 | |
| 26 | "sigs.k8s.io/apiserver-network-proxy/cmd/server/app" |
| 27 | "sigs.k8s.io/apiserver-network-proxy/cmd/server/app/options" |
| 28 | "sigs.k8s.io/apiserver-network-proxy/pkg/util" |
| 29 | ) |
| 30 | |
| 31 | func main() { |
| 32 | proxy := &app.Proxy{} |
| 33 | o := options.NewProxyRunOptions() |
| 34 | command := app.NewProxyCommand(proxy, o) |
| 35 | flags := command.Flags() |
| 36 | flags.AddFlagSet(o.Flags()) |
| 37 | local := flag.NewFlagSet(os.Args[0], flag.ExitOnError) |
| 38 | klog.InitFlags(local) |
| 39 | if local.Lookup("v") == nil { |
| 40 | err := local.Set("v", "4") |
| 41 | if err != nil { |
| 42 | fmt.Fprintf(os.Stderr, "error setting klog flags: %v", err) |
| 43 | } |
| 44 | } |
| 45 | local.VisitAll(func(fl *flag.Flag) { |
| 46 | fl.Name = util.Normalize(fl.Name) |
| 47 | flags.AddGoFlag(fl) |
| 48 | }) |
| 49 | if err := command.Execute(); err != nil { |
| 50 | klog.Errorf("error: %v\n", err) |
| 51 | klog.Flush() |
| 52 | os.Exit(1) |
| 53 | } |
| 54 | } |