| 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 |
err := local.Set("v", "4") |
| 40 |
if err != nil { |
| 41 |
fmt.Fprintf(os.Stderr, "error setting klog flags: %v", err) |
| 42 |
} |
| 43 |
local.VisitAll(func(fl *flag.Flag) { |
| 44 |
fl.Name = util.Normalize(fl.Name) |
| 45 |
flags.AddGoFlag(fl) |
| 46 |
}) |
| 47 |
if err := command.Execute(); err != nil { |
| 48 |
klog.Errorf("error: %v\n", err) |
| 49 |
klog.Flush() |
| 50 |
os.Exit(1) |
| 51 |
} |
| 52 |
} |