Skip to content

Commit

Permalink
fix go linter issues
Browse files Browse the repository at this point in the history
Signed-off-by: NikitaSkrynnik <nikita.skrynnik@xored.com>
  • Loading branch information
NikitaSkrynnik committed Aug 21, 2024
1 parent 47ad2d0 commit 436721b
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type Config struct {
ConnectTo url.URL `default:"unix:///var/lib/networkservicemesh/nsm.io.sock" desc:"url to connect to" split_words:"true"`
MaxTokenLifetime time.Duration `default:"10m" desc:"maximum lifetime of tokens" split_words:"true"`
RegistryClientPolicies []string `default:"etc/nsm/opa/common/.*.rego,etc/nsm/opa/registry/.*.rego,etc/nsm/opa/client/.*.rego" desc:"paths to files and directories that contain registry client policies" split_words:"true"`
IPAMPolicy IPAMPolicy `default:"default" desc:"defines NSE's IPAM Policy. Possible values: default, strict" split_words:"true"`
IPAMPolicy ipamPolicy `default:"default" desc:"defines NSE's IPAM Policy. Possible values: default, strict" split_words:"true"`
ServiceNames []string `default:"icmp-responder" desc:"Name of provided services" split_words:"true"`
Payload string `default:"ETHERNET" desc:"Name of provided service payload" split_words:"true"`
Labels map[string]string `default:"" desc:"Endpoint labels"`
Expand All @@ -111,27 +111,27 @@ type Config struct {
PprofListenOn string `default:"localhost:6060" desc:"pprof URL to ListenAndServe" split_words:"true"`
}

type IPAMPolicy uint8
type ipamPolicy uint8

// Decode takes a string IPAM Policy and returns the IPAM Policy constant.
func (p *IPAMPolicy) Decode(policy string) error {
func (p *ipamPolicy) Decode(policy string) error {
switch strings.ToLower(policy) {
case "strict":
*p = StrictIPAMPolicy
*p = strictIPAMPolicy
return nil
case "default":
*p = DefaultIPAMPolicy
*p = defaultIPAMPolicy
return nil
}
return errors.Errorf("not a valid IPAM Policy: %s", policy)
}

const (
// DefaultIPAMPolicy - uses the default point2point IPAM without any policies.
DefaultIPAMPolicy IPAMPolicy = iota
defaultIPAMPolicy ipamPolicy = iota
// StrictIPAMPolicy - uses a strictipam wrapper for the default point2point IPAM that
// resets connetion's ip_context if any of the addresses are invalid.
StrictIPAMPolicy
strictIPAMPolicy
)

// Process prints and processes env to config
Expand Down Expand Up @@ -246,7 +246,7 @@ func main() {
tokenServer := getSriovTokenServerChainElement(ctx)

ipamFunc := point2pointipam.NewServer
if config.IPAMPolicy == StrictIPAMPolicy {
if config.IPAMPolicy == strictIPAMPolicy {
ipamFunc = func(prefixes ...*net.IPNet) networkservice.NetworkServiceServer {
return strictipam.NewServer(point2pointipam.NewServer, prefixes...)
}
Expand All @@ -273,14 +273,8 @@ func main() {
// ********************************************************************************
options := append(
tracing.WithTracing(),
grpc.Creds(
grpcfd.TransportCredentials(
credentials.NewTLS(
tlsServerConfig,
),
),
),
)
grpc.Creds(grpcfd.TransportCredentials(credentials.NewTLS(tlsServerConfig))))

server := grpc.NewServer(options...)
responderEndpoint.Register(server)
tmpDir, err := os.MkdirTemp("", config.Name)
Expand Down

0 comments on commit 436721b

Please sign in to comment.