Skip to content

Commit

Permalink
Merge pull request #207 from dciangot/next
Browse files Browse the repository at this point in the history
fix flag management on vk main
  • Loading branch information
dciangot authored Apr 16, 2024
2 parents 95ad78f + 248c8c6 commit e1f7693
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions cmd/virtual-kubelet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,6 @@ type Opts struct {
ErrorsOnly bool
}

// NewOpts returns an Opts struct with the default values set.
func NewOpts(nodename string, configpath string) error {

if nodename == "" {
nodename = os.Getenv("NODENAME")
}

if configpath == "" {
configpath = os.Getenv("CONFIGPATH")
}

return nil
}

func initProvider() (func(context.Context) error, error) {
ctx := context.Background()

Expand Down Expand Up @@ -162,15 +148,29 @@ func initProvider() (func(context.Context) error, error) {
func main() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
nodename := flag.String("nodename", "", "The name of the node")
configpath := flag.String("configpath", "", "Path to the VK config")
flag.Parse()
err := NewOpts(*nodename, *configpath)
if err != nil {
panic(err)
flagnodename := flag.String("nodename", "", "The name of the node")
flagpath := flag.String("configpath", "", "Path to the VK config")
flag.Parse()

configpath := ""
if *flagpath != "" {
configpath = *flagpath
} else if os.Getenv("CONFIGPATH") != "" {
configpath = os.Getenv("CONFIGPATH")
} else {
configpath = "/etc/interlink/InterLinkConfig.yaml"
}

nodename := ""
if *flagnodename != "" {
nodename = *flagnodename
} else if os.Getenv("NODENAME") != "" {
nodename = os.Getenv("NODENAME")
} else {
panic(fmt.Errorf("You must specify a Node name"))
}

interLinkConfig, err := commonIL.LoadConfig(*configpath, *nodename, ctx)
interLinkConfig, err := commonIL.LoadConfig(configpath, nodename, ctx)
if err != nil {
panic(err)
}
Expand All @@ -190,7 +190,7 @@ func main() {
log.G(ctx).Fatal(err)
}
defer func() {
if err := shutdown(ctx); err != nil {
if err = shutdown(ctx); err != nil {
log.G(ctx).Fatal("failed to shutdown TracerProvider: %w", err)
}
}()
Expand All @@ -211,8 +211,8 @@ func main() {
}

cfg := Config{
ConfigPath: *configpath,
NodeName: *nodename,
ConfigPath: configpath,
NodeName: nodename,
OperatingSystem: "Linux",
// https://github.com/liqotech/liqo/blob/d8798732002abb7452c2ff1c99b3e5098f848c93/deployments/liqo/templates/liqo-gateway-deployment.yaml#L69
InternalIP: os.Getenv("POD_IP"),
Expand Down
Binary file removed interlink-install
Binary file not shown.

0 comments on commit e1f7693

Please sign in to comment.