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 336881c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ linters-settings:
threshold: 150
funlen:
Lines: 175
Statements: 85
Statements: 90
goconst:
min-len: 2
min-occurrences: 2
Expand Down
16 changes: 8 additions & 8 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 Down

0 comments on commit 336881c

Please sign in to comment.