Skip to content

Commit

Permalink
Corrected issues found by "make static-checks"
Browse files Browse the repository at this point in the history
And added license headers.
  • Loading branch information
Lars Ekman committed Jul 6, 2020
1 parent d5cd2b3 commit a6a6ad4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config/config_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ type Config struct {
IptablesLockFilePath string `config:"file;/run/xtables.lock"`
IptablesLockTimeoutSecs time.Duration `config:"seconds;0"`
IptablesLockProbeIntervalMillis time.Duration `config:"millis;50"`
FeatureDetectOverride map[string]string `config:"keyvaluelist;"";;local"`
FeatureDetectOverride map[string]string `config:"keyvaluelist;;local"`
IpsetsRefreshInterval time.Duration `config:"seconds;10"`
MaxIpsetSize int `config:"int;1048576;non-zero"`
XDPRefreshInterval time.Duration `config:"seconds;90"`
Expand Down
18 changes: 16 additions & 2 deletions stringutils/parse_keyvalue_list.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Copyright (c) 2020 Tigera, Inc. All rights reserved.
// Copyright (c) 2020 Nordix Foundation
//
// 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 stringutils

// https://play.golang.org/p/xSEX1CAcQE
Expand All @@ -8,11 +23,10 @@ import (
"strings"
)

var rex = regexp.MustCompile("\\s*(\\w+)=(.*)")
var rex = regexp.MustCompile(`\s*(\w+)=(.*)`)

// ParseKeyValueList parses a comma-separated key=value list to a map.
// Keys must contain only word characters (leading spaces ignored).
// A valid map is always returned even when the error is != nil.
// Spaces in the value are preserved.
func ParseKeyValueList(param string) (map[string]string, error) {
res := make(map[string]string)
Expand Down
14 changes: 14 additions & 0 deletions stringutils/parse_keyvalue_list_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright (c) 2020 Tigera, Inc. All rights reserved.
//
// 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 stringutils_test

import (
Expand Down

0 comments on commit a6a6ad4

Please sign in to comment.