mirror of
https://github.com/yannh/kubeconform.git
synced 2026-04-23 03:54:23 +00:00
linting / refactor
This commit is contained in:
parent
7604a7aa7d
commit
300b571c33
10 changed files with 60 additions and 49 deletions
|
|
@ -13,8 +13,8 @@ type Config struct {
|
|||
Files []string
|
||||
SchemaLocations []string
|
||||
SkipTLS bool
|
||||
SkipKinds map[string]bool
|
||||
RejectKinds map[string]bool
|
||||
SkipKinds map[string]struct{}
|
||||
RejectKinds map[string]struct{}
|
||||
OutputFormat string
|
||||
KubernetesVersion string
|
||||
NumberOfWorkers int
|
||||
|
|
@ -37,13 +37,13 @@ func (ap *arrayParam) Set(value string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func splitCSV(csvStr string) map[string]bool {
|
||||
func splitCSV(csvStr string) map[string]struct{} {
|
||||
splitValues := strings.Split(csvStr, ",")
|
||||
valuesMap := map[string]bool{}
|
||||
valuesMap := map[string]struct{}{}
|
||||
|
||||
for _, kind := range splitValues {
|
||||
if len(kind) > 0 {
|
||||
valuesMap[kind] = true
|
||||
valuesMap[kind] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,27 +9,27 @@ func TestSkipKindMaps(t *testing.T) {
|
|||
for _, testCase := range []struct {
|
||||
name string
|
||||
csvSkipKinds string
|
||||
expect map[string]bool
|
||||
expect map[string]struct{}
|
||||
}{
|
||||
{
|
||||
"nothing to skip",
|
||||
"",
|
||||
map[string]bool{},
|
||||
map[string]struct{}{},
|
||||
},
|
||||
{
|
||||
"a single kind to skip",
|
||||
"somekind",
|
||||
map[string]bool{
|
||||
"somekind": true,
|
||||
map[string]struct{}{
|
||||
"somekind": {},
|
||||
},
|
||||
},
|
||||
{
|
||||
"multiple kinds to skip",
|
||||
"somekind,anotherkind,yetsomeotherkind",
|
||||
map[string]bool{
|
||||
"somekind": true,
|
||||
"anotherkind": true,
|
||||
"yetsomeotherkind": true,
|
||||
map[string]struct{}{
|
||||
"somekind": {},
|
||||
"anotherkind": {},
|
||||
"yetsomeotherkind": {},
|
||||
},
|
||||
},
|
||||
} {
|
||||
|
|
@ -53,8 +53,8 @@ func TestFromFlags(t *testing.T) {
|
|||
NumberOfWorkers: 4,
|
||||
OutputFormat: "text",
|
||||
SchemaLocations: nil,
|
||||
SkipKinds: map[string]bool{},
|
||||
RejectKinds: map[string]bool{},
|
||||
SkipKinds: map[string]struct{}{},
|
||||
RejectKinds: map[string]struct{}{},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -66,8 +66,8 @@ func TestFromFlags(t *testing.T) {
|
|||
NumberOfWorkers: 4,
|
||||
OutputFormat: "text",
|
||||
SchemaLocations: nil,
|
||||
SkipKinds: map[string]bool{},
|
||||
RejectKinds: map[string]bool{},
|
||||
SkipKinds: map[string]struct{}{},
|
||||
RejectKinds: map[string]struct{}{},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -78,8 +78,8 @@ func TestFromFlags(t *testing.T) {
|
|||
NumberOfWorkers: 4,
|
||||
OutputFormat: "text",
|
||||
SchemaLocations: nil,
|
||||
SkipKinds: map[string]bool{"a": true, "b": true, "c": true},
|
||||
RejectKinds: map[string]bool{},
|
||||
SkipKinds: map[string]struct{}{"a": {}, "b": {}, "c": {}},
|
||||
RejectKinds: map[string]struct{}{},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -90,8 +90,8 @@ func TestFromFlags(t *testing.T) {
|
|||
NumberOfWorkers: 4,
|
||||
OutputFormat: "text",
|
||||
SchemaLocations: nil,
|
||||
SkipKinds: map[string]bool{},
|
||||
RejectKinds: map[string]bool{},
|
||||
SkipKinds: map[string]struct{}{},
|
||||
RejectKinds: map[string]struct{}{},
|
||||
Summary: true,
|
||||
Verbose: true,
|
||||
},
|
||||
|
|
@ -107,8 +107,8 @@ func TestFromFlags(t *testing.T) {
|
|||
NumberOfWorkers: 2,
|
||||
OutputFormat: "json",
|
||||
SchemaLocations: []string{"folder", "anotherfolder"},
|
||||
SkipKinds: map[string]bool{"kinda": true, "kindb": true},
|
||||
RejectKinds: map[string]bool{"kindc": true, "kindd": true},
|
||||
SkipKinds: map[string]struct{}{"kinda": {}, "kindb": {}},
|
||||
RejectKinds: map[string]struct{}{"kindc": {}, "kindd": {}},
|
||||
Strict: true,
|
||||
Summary: true,
|
||||
Verbose: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue