Skip to content

Commit a476942

Browse files
author
Matt Welke
authored
refactor: add revive linter, fix linting errors, remove unused code (#63)
Signed-off-by: Matt Welke <matt.welke@spectrocloud.com>
1 parent 14f18c7 commit a476942

File tree

16 files changed

+56
-55
lines changed

16 files changed

+56
-55
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ linters:
2626
- misspell
2727
- nakedret
2828
- prealloc
29+
- revive
2930
- staticcheck
3031
- typecheck
3132
- unconvert

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
2-
# -include will silently skip missing files, which allows us
3-
# to load those files with a target in the Makefile. If only
4-
# "include" was used, the make command would fail and refuse
5-
# to run a target until the include commands succeeded.
6-
-include build/makelib/common.mk
1+
include build/makelib/common.mk
2+
include build/makelib/plugin.mk
73

84
# Image URL to use all building/pushing image targets
95
IMG ?= quay.io/validator-labs/validator-plugin-kubescape:latest
106

117
# Helm vars
128
CHART_NAME=validator-plugin-kubescape
9+
10+
.PHONY: dev
11+
dev:
12+
devspace dev -n validator

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pre-commit install --hook-type pre-commit
113113
```
114114

115115
## License
116-
Copyright 2023.
116+
Copyright 2024.
117117

118118
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
119119

api/v1alpha1/groupversion_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// Package v1 contains API Schema definitions for the validation v1 API group
17+
// Package v1alpha1 contains API Schema definitions for the validation v1alpha1 API group
1818
// +kubebuilder:object:generate=true
1919
// +groupName=validation.spectrocloud.labs
2020
package v1alpha1

api/v1alpha1/kubescapevalidator_types.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,31 @@ type KubescapeValidatorSpec struct {
3131
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
3232
// Global Severity Limit Rule
3333
SeverityLimitRule SeverityLimitRule `json:"severityLimitRule,omitempty" yaml:"severityLimitRule,omitempty"`
34-
// Global Ignore CVEs
35-
IgnoredCVERule []string `json:"ignoredCVERule,omitempty" yaml:"ignoredCVERule,omitempty"`
3634
// Rule for Flagged CVEs
3735
FlaggedCVERule []FlaggedCVE `json:"flaggedCVERule,omitempty" yaml:"flaggedCVERule,omitempty"`
3836
}
3937

38+
// FlaggedCVE is a flagged CVE rule.
4039
type FlaggedCVE string
4140

41+
// Name returns the formatted name of the flagged CVE.
4242
func (r FlaggedCVE) Name() string {
4343
return fmt.Sprintf("FLAG-%s", string(r))
4444
}
4545

46-
// Increase for every rule
46+
// ResultCount returns the number of validation results expected for an KubescapeValidatorSpec.
4747
func (s KubescapeValidatorSpec) ResultCount() int {
4848
count := 0
4949
if s.SeverityLimitRule != (SeverityLimitRule{}) {
5050
count++
5151
}
52-
count += len(s.IgnoredCVERule)
5352
count += len(s.FlaggedCVERule)
5453

5554
return count
5655
}
5756

57+
// SeverityLimitRule verifies that the number of vulnerabilities of each severity level does not
58+
// exceed the specified limit.
5859
type SeverityLimitRule struct {
5960
Critical *int `json:"critical,omitempty"`
6061
High *int `json:"high,omitempty"`
@@ -64,6 +65,7 @@ type SeverityLimitRule struct {
6465
Unknown *int `json:"unknown,omitempty"`
6566
}
6667

68+
// Name is the name of all severity limit rules.
6769
func (r SeverityLimitRule) Name() string {
6870
return "SeverityLimitRule"
6971
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build

chart/validator-plugin-kubescape/crds/validation.spectrocloud.labs_kubescapevalidators.yaml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.12.0
6+
controller-gen.kubebuilder.io/version: v0.15.0
77
name: kubescapevalidators.validation.spectrocloud.labs
88
spec:
99
group: validation.spectrocloud.labs
@@ -21,14 +21,19 @@ spec:
2121
API
2222
properties:
2323
apiVersion:
24-
description: 'APIVersion defines the versioned schema of this representation
25-
of an object. Servers should convert recognized schemas to the latest
26-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
24+
description: |-
25+
APIVersion defines the versioned schema of this representation of an object.
26+
Servers should convert recognized schemas to the latest internal value, and
27+
may reject unrecognized values.
28+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
2729
type: string
2830
kind:
29-
description: 'Kind is a string value representing the REST resource this
30-
object represents. Servers may infer this from the endpoint the client
31-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
31+
description: |-
32+
Kind is a string value representing the REST resource this object represents.
33+
Servers may infer this from the endpoint the client submits requests to.
34+
Cannot be updated.
35+
In CamelCase.
36+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
3237
type: string
3338
metadata:
3439
type: object
@@ -38,11 +43,7 @@ spec:
3843
flaggedCVERule:
3944
description: Rule for Flagged CVEs
4045
items:
41-
type: string
42-
type: array
43-
ignoredCVERule:
44-
description: Global Ignore CVEs
45-
items:
46+
description: FlaggedCVE is a flagged CVE rule.
4647
type: string
4748
type: array
4849
namespace:

cmd/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
// Package main initializes a KubescapeValidator controller.
1718
package main
1819

1920
import (

config/crd/bases/validation.spectrocloud.labs_kubescapevalidators.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@ spec:
4343
flaggedCVERule:
4444
description: Rule for Flagged CVEs
4545
items:
46-
type: string
47-
type: array
48-
ignoredCVERule:
49-
description: Global Ignore CVEs
50-
items:
46+
description: FlaggedCVE is a flagged CVE rule.
5147
type: string
5248
type: array
5349
namespace:

0 commit comments

Comments
 (0)