mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-12-08 05:11:01 +01:00
refactor
This commit is contained in:
parent
885b2349e1
commit
a0b66b91f3
1
main.go
1
main.go
@ -42,7 +42,6 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cfg := externaldns.NewConfig()
|
cfg := externaldns.NewConfig()
|
||||||
|
|
||||||
if err := cfg.ParseFlags(os.Args); err != nil {
|
if err := cfg.ParseFlags(os.Args); err != nil {
|
||||||
log.Fatalf("flag parsing error: %v", err)
|
log.Fatalf("flag parsing error: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,11 @@ limitations under the License.
|
|||||||
|
|
||||||
package externaldns
|
package externaldns
|
||||||
|
|
||||||
import "github.com/spf13/pflag"
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/spf13/pflag"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
defaultHealthPort = "9090"
|
defaultHealthPort = "9090"
|
||||||
@ -41,6 +45,7 @@ func NewConfig() *Config {
|
|||||||
|
|
||||||
// ParseFlags adds and parses flags from command line
|
// ParseFlags adds and parses flags from command line
|
||||||
func (cfg *Config) ParseFlags(args []string) error {
|
func (cfg *Config) ParseFlags(args []string) error {
|
||||||
|
fmt.Println(args)
|
||||||
flags := pflag.NewFlagSet("", pflag.ContinueOnError)
|
flags := pflag.NewFlagSet("", pflag.ContinueOnError)
|
||||||
flags.BoolVar(&cfg.InCluster, "in-cluster", false, "whether to use in-cluster config")
|
flags.BoolVar(&cfg.InCluster, "in-cluster", false, "whether to use in-cluster config")
|
||||||
flags.StringVar(&cfg.KubeConfig, "kubeconfig", "", "path to a local kubeconfig file")
|
flags.StringVar(&cfg.KubeConfig, "kubeconfig", "", "path to a local kubeconfig file")
|
||||||
|
|||||||
41
pkg/apis/externaldns/types_test.go
Normal file
41
pkg/apis/externaldns/types_test.go
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2017 The Kubernetes Authors.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package externaldns
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestParseFlags(t *testing.T) {
|
||||||
|
// extra := "one-extra-argument"
|
||||||
|
// args := []string{
|
||||||
|
// "-bool",
|
||||||
|
// "-bool2=true",
|
||||||
|
// "--int", "22",
|
||||||
|
// "--int64", "0x23",
|
||||||
|
// "-uint", "24",
|
||||||
|
// "--uint64", "25",
|
||||||
|
// "-string", "hello",
|
||||||
|
// "-float64", "2718e28",
|
||||||
|
// "-duration", "2m",
|
||||||
|
// extra,
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
type arg struct {
|
||||||
|
raw string
|
||||||
|
key string
|
||||||
|
val string
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user