-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding linters and aligning code (#169)
* Adding linters and aligning code * Aligning ingressHostnames to AllowedListSpec
- Loading branch information
1 parent
89c66de
commit d270055
Showing
56 changed files
with
428 additions
and
562 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
linters-settings: | ||
govet: | ||
check-shadowing: true | ||
golint: | ||
min-confidence: 0 | ||
maligned: | ||
suggest-new: true | ||
goimports: | ||
local-prefixes: github.com/clastix/capsule | ||
dupl: | ||
threshold: 100 | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 2 | ||
linters: | ||
disable-all: true | ||
enable: | ||
- bodyclose | ||
- deadcode | ||
- depguard | ||
- dogsled | ||
- dupl | ||
- errcheck | ||
- goconst | ||
- gocritic | ||
- gofmt | ||
- goimports | ||
- golint | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- interfacer | ||
- misspell | ||
- nolintlint | ||
- rowserrcheck | ||
- scopelint | ||
- staticcheck | ||
- structcheck | ||
- stylecheck | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- varcheck | ||
- whitespace | ||
- maligned | ||
|
||
issues: | ||
exclude: | ||
- Using the variable on range scope .* in function literal | ||
|
||
service: | ||
golangci-lint-version: 1.33.x | ||
|
||
run: | ||
skip-files: | ||
- "zz_.*\\.go$" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
Copyright 2020 Clastix Labs. | ||
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 v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestAllowedListSpec_ExactMatch(t *testing.T) { | ||
type tc struct { | ||
In []string | ||
True []string | ||
False []string | ||
} | ||
for _, tc := range []tc{ | ||
{ | ||
[]string{"foo", "bar", "bizz", "buzz"}, | ||
[]string{"foo", "bar", "bizz", "buzz"}, | ||
[]string{"bing", "bong"}, | ||
}, | ||
{ | ||
[]string{"one", "two", "three"}, | ||
[]string{"one", "two", "three"}, | ||
[]string{"a", "b", "c"}, | ||
}, | ||
{ | ||
nil, | ||
nil, | ||
[]string{"any", "value"}, | ||
}, | ||
} { | ||
a := AllowedListSpec{ | ||
Exact: tc.In, | ||
} | ||
for _, ok := range tc.True { | ||
assert.True(t, a.ExactMatch(ok)) | ||
} | ||
for _, ko := range tc.False { | ||
assert.False(t, a.ExactMatch(ko)) | ||
} | ||
} | ||
} | ||
|
||
func TestAllowedListSpec_RegexMatch(t *testing.T) { | ||
type tc struct { | ||
Regex string | ||
True []string | ||
False []string | ||
} | ||
for _, tc := range []tc{ | ||
{`first-\w+-pattern`, []string{"first-date-pattern", "first-year-pattern"}, []string{"broken", "first-year", "second-date-pattern"}}, | ||
{``, nil, []string{"any", "value"}}, | ||
} { | ||
a := AllowedListSpec{ | ||
Regex: tc.Regex, | ||
} | ||
for _, ok := range tc.True { | ||
assert.True(t, a.RegexMatch(ok)) | ||
} | ||
for _, ko := range tc.False { | ||
assert.False(t, a.RegexMatch(ko)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.