Skip to content

Commit

Permalink
Merge pull request #174 from Mixaster995/main
Browse files Browse the repository at this point in the history
Added config option for network service register
  • Loading branch information
denis-tingaikin authored Jul 2, 2021
2 parents ce44144 + 48b7839 commit 9cc362e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
@@ -72,6 +72,7 @@ type Config struct {
Payload string `default:"ETHERNET" desc:"Name of provided service payload" split_words:"true"`
Labels map[string]string `default:"" desc:"Endpoint labels"`
CidrPrefix string `default:"169.254.0.0/16" desc:"CIDR Prefix to assign IPs from" split_words:"true"`
RegisterService bool `default:"true" desc:"if true then registers network service on startup" split_words:"true"`
}

// Process prints and processes env to config
@@ -219,14 +220,16 @@ func main() {
),
)

nsRegistryClient := registryclient.NewNetworkServiceRegistryClient(ctx, &config.ConnectTo, registryclient.WithDialOptions(clientOptions...))
_, err = nsRegistryClient.Register(ctx, &registryapi.NetworkService{
Name: config.ServiceName,
Payload: config.Payload,
})
if config.RegisterService {
nsRegistryClient := registryclient.NewNetworkServiceRegistryClient(ctx, &config.ConnectTo, registryclient.WithDialOptions(clientOptions...))
_, err = nsRegistryClient.Register(ctx, &registryapi.NetworkService{
Name: config.ServiceName,
Payload: config.Payload,
})

if err != nil {
log.FromContext(ctx).Fatalf("unable to register ns %+v", err)
if err != nil {
log.FromContext(ctx).Fatalf("unable to register ns %+v", err)
}
}

nseRegistryClient := registryclient.NewNetworkServiceEndpointRegistryClient(ctx, &config.ConnectTo, registryclient.WithDialOptions(clientOptions...))

0 comments on commit 9cc362e

Please sign in to comment.