Skip to content

Commit

Permalink
auto format linters
Browse files Browse the repository at this point in the history
Signed-off-by: Will Beason <willbeason@google.com>
  • Loading branch information
Will Beason committed Jul 13, 2021
1 parent 86b495b commit 60f191c
Show file tree
Hide file tree
Showing 112 changed files with 350 additions and 376 deletions.
5 changes: 4 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,21 @@ linters:
enable:
- deadcode
- errcheck
- ineffassign
- gocritic
- goconst
- godot
- gofmt
- gofumpt
- goimports
- gosec
- gosimple
- govet
- ineffassign
- misspell
- revive # replacement for golint
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
- whitespace
4 changes: 2 additions & 2 deletions apis/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import (
"k8s.io/apimachinery/pkg/runtime"
)

// AddToSchemes may be used to add all resources defined in the project to a Scheme
// AddToSchemes may be used to add all resources defined in the project to a Scheme.
var AddToSchemes runtime.SchemeBuilder

// AddToScheme adds all Resources to the Scheme
// AddToScheme adds all Resources to the Scheme.
func AddToScheme(s *runtime.Scheme) error {
return AddToSchemes.AddToScheme(s)
}
11 changes: 5 additions & 6 deletions apis/config/v1alpha1/config_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// ConfigSpec defines the desired state of Config
// ConfigSpec defines the desired state of Config.
type ConfigSpec struct {
// Important: Run "make" to regenerate code after modifying this file

Expand Down Expand Up @@ -71,9 +71,8 @@ type ReadinessSpec struct {
StatsEnabled bool `json:"statsEnabled,omitempty"`
}

// ConfigStatus defines the observed state of Config
type ConfigStatus struct {
// Important: Run "make" to regenerate code after modifying this file
// ConfigStatus defines the observed state of Config.
type ConfigStatus struct { // Important: Run "make" to regenerate code after modifying this file
}

type GVK struct {
Expand All @@ -85,7 +84,7 @@ type GVK struct {
// +kubebuilder:resource:scope=Namespaced
// +kubebuilder:object:root=true

// Config is the Schema for the configs API
// Config is the Schema for the configs API.
type Config struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -96,7 +95,7 @@ type Config struct {

// +kubebuilder:object:root=true

// ConfigList contains a list of Config
// ConfigList contains a list of Config.
type ConfigList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions apis/config/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import (
)

var (
// GroupVersion is group version used to register these objects
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "config.gatekeeper.sh", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
Expand Down
10 changes: 5 additions & 5 deletions apis/config/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions apis/mutations/v1alpha1/assign_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// AssignSpec defines the desired state of Assign
// AssignSpec defines the desired state of Assign.
type AssignSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
Expand Down Expand Up @@ -59,13 +59,13 @@ type Parameters struct {
//
// Available Tests:
// * MustExist - the path must exist or do not mutate
// * MustNotExist - the path must not exist or do not mutate
// * MustNotExist - the path must not exist or do not mutate.
type PathTest struct {
SubPath string `json:"subPath,omitempty"`
Condition tester.Condition `json:"condition,omitempty"`
}

// AssignStatus defines the observed state of Assign
// AssignStatus defines the observed state of Assign.
type AssignStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
Expand All @@ -78,7 +78,7 @@ type AssignStatus struct {
// +kubebuilder:resource:scope="Cluster"
// +kubebuilder:subresource:status

// Assign is the Schema for the assign API
// Assign is the Schema for the assign API.
type Assign struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -89,7 +89,7 @@ type Assign struct {

// +kubebuilder:object:root=true

// AssignList contains a list of Assign
// AssignList contains a list of Assign.
type AssignList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand All @@ -101,7 +101,7 @@ func init() {
}

// ValueTests returns tests that the mutator is expected
// to run against the value
// to run against the value.
func (a *Assign) ValueTests() (AssignIf, error) {
raw := a.Spec.Parameters.AssignIf
out := AssignIf{}
Expand All @@ -117,7 +117,7 @@ func (a *Assign) ValueTests() (AssignIf, error) {
// +kubebuilder:object:generate=false

// AssignIf describes tests against the pre-existing value.
// The object will be mutated only if assertions pass
// The object will be mutated only if assertions pass.
type AssignIf struct {
// In Asserts that the value is a member of the provided list before mutating
In []interface{} `json:"in,omitempty"`
Expand Down
8 changes: 4 additions & 4 deletions apis/mutations/v1alpha1/assignmetadata_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// AssignMetadataSpec defines the desired state of AssignMetadata
// AssignMetadataSpec defines the desired state of AssignMetadata.
type AssignMetadataSpec struct {
Match match.Match `json:"match,omitempty"`
Location string `json:"location,omitempty"`
Expand All @@ -38,7 +38,7 @@ type MetadataParameters struct {
Assign runtime.RawExtension `json:"assign,omitempty"`
}

// AssignMetadataStatus defines the observed state of AssignMetadata
// AssignMetadataStatus defines the observed state of AssignMetadata.
type AssignMetadataStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
Expand All @@ -49,7 +49,7 @@ type AssignMetadataStatus struct {
// +kubebuilder:resource:scope="Cluster"
// +kubebuilder:subresource:status

// AssignMetadata is the Schema for the assignmetadata API
// AssignMetadata is the Schema for the assignmetadata API.
type AssignMetadata struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -60,7 +60,7 @@ type AssignMetadata struct {

// +kubebuilder:object:root=true

// AssignMetadataList contains a list of AssignMetadata
// AssignMetadataList contains a list of AssignMetadata.
type AssignMetadataList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions apis/mutations/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import (
)

var (
// GroupVersion is group version used to register these objects
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "mutations.gatekeeper.sh", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
Expand Down
12 changes: 6 additions & 6 deletions apis/status/v1beta1/constraintpodstatus_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
// ConstraintsGroup is the API Group for Gatekeeper Constraints.
const ConstraintsGroup = "constraints.gatekeeper.sh"

// ConstraintPodStatusStatus defines the observed state of ConstraintPodStatus
// ConstraintPodStatusStatus defines the observed state of ConstraintPodStatus.
type ConstraintPodStatusStatus struct {
// Important: Run "make" to regenerate code after modifying this file

Expand All @@ -46,7 +46,7 @@ type ConstraintPodStatusStatus struct {
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

// Error represents a single error caught while adding a constraint to OPA
// Error represents a single error caught while adding a constraint to OPA.
type Error struct {
Code string `json:"code"`
Message string `json:"message"`
Expand All @@ -56,7 +56,7 @@ type Error struct {
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Namespaced

// ConstraintPodStatus is the Schema for the constraintpodstatuses API
// ConstraintPodStatus is the Schema for the constraintpodstatuses API.
type ConstraintPodStatus struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -66,7 +66,7 @@ type ConstraintPodStatus struct {

// +kubebuilder:object:root=true

// ConstraintPodStatusList contains a list of ConstraintPodStatus
// ConstraintPodStatusList contains a list of ConstraintPodStatus.
type ConstraintPodStatusList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand All @@ -79,7 +79,7 @@ func init() {

// NewConstraintStatusForPod returns a constraint status object
// that has been initialized with the bare minimum of fields to make it functional
// with the constraint status controller
// with the constraint status controller.
func NewConstraintStatusForPod(pod *corev1.Pod, constraint *unstructured.Unstructured, scheme *runtime.Scheme) (*ConstraintPodStatus, error) {
obj := &ConstraintPodStatus{}
name, err := KeyForConstraint(pod.Name, constraint)
Expand All @@ -106,7 +106,7 @@ func NewConstraintStatusForPod(pod *corev1.Pod, constraint *unstructured.Unstruc
}

// KeyForConstraint returns a unique status object name given the Pod ID and
// a constraint object
// a constraint object.
func KeyForConstraint(id string, constraint *unstructured.Unstructured) (string, error) {
// We don't need to worry that lower-casing the kind will cause a collision because
// the constraint framework requires resource == lower-case kind. We must do this
Expand Down
10 changes: 5 additions & 5 deletions apis/status/v1beta1/constrainttemplatepodstatus_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
)

// ConstraintTemplatePodStatusStatus defines the observed state of ConstraintTemplatePodStatus
// ConstraintTemplatePodStatusStatus defines the observed state of ConstraintTemplatePodStatus.
type ConstraintTemplatePodStatusStatus struct {
// Important: Run "make" to regenerate code after modifying this file
ID string `json:"id,omitempty"`
Expand All @@ -39,7 +39,7 @@ type ConstraintTemplatePodStatusStatus struct {
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Namespaced

// ConstraintTemplatePodStatus is the Schema for the constrainttemplatepodstatuses API
// ConstraintTemplatePodStatus is the Schema for the constrainttemplatepodstatuses API.
type ConstraintTemplatePodStatus struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -49,7 +49,7 @@ type ConstraintTemplatePodStatus struct {

// +kubebuilder:object:root=true

// ConstraintTemplatePodStatusList contains a list of ConstraintTemplatePodStatus
// ConstraintTemplatePodStatusList contains a list of ConstraintTemplatePodStatus.
type ConstraintTemplatePodStatusList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand All @@ -62,7 +62,7 @@ func init() {

// NewConstraintTemplateStatusForPod returns a constraint template status object
// that has been initialized with the bare minimum of fields to make it functional
// with the constraint template status controller
// with the constraint template status controller.
func NewConstraintTemplateStatusForPod(pod *corev1.Pod, templateName string, scheme *runtime.Scheme) (*ConstraintTemplatePodStatus, error) {
obj := &ConstraintTemplatePodStatus{}
name, err := KeyForConstraintTemplate(pod.Name, templateName)
Expand All @@ -86,7 +86,7 @@ func NewConstraintTemplateStatusForPod(pod *corev1.Pod, templateName string, sch
}

// KeyForConstraintTemplate returns a unique status object name given the Pod ID and
// a template object
// a template object.
func KeyForConstraintTemplate(id string, templateName string) (string, error) {
return dashPacker(id, templateName)
}
4 changes: 2 additions & 2 deletions apis/status/v1beta1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import (
)

var (
// GroupVersion is group version used to register these objects
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "status.gatekeeper.sh", Version: "v1beta1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
Expand Down
12 changes: 6 additions & 6 deletions apis/status/v1beta1/mutatorpodstatus_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
// MutationsGroup is the API Group for Gatekeeper Mutators.
const MutationsGroup = "mutations.gatekeeper.sh"

// MutatorPodStatusStatus defines the observed state of MutatorPodStatus
// MutatorPodStatusStatus defines the observed state of MutatorPodStatus.
type MutatorPodStatusStatus struct {
// Important: Run "make" to regenerate code after modifying this file

Expand All @@ -46,15 +46,15 @@ type MutatorPodStatusStatus struct {
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

// MutatorError represents a single error caught while adding a mutator to a system
// MutatorError represents a single error caught while adding a mutator to a system.
type MutatorError struct {
Message string `json:"message"`
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Namespaced

// MutatorPodStatus is the Schema for the mutationpodstatuses API
// MutatorPodStatus is the Schema for the mutationpodstatuses API.
type MutatorPodStatus struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -64,7 +64,7 @@ type MutatorPodStatus struct {

// +kubebuilder:object:root=true

// MutatorPodStatusList contains a list of MutatorPodStatus
// MutatorPodStatusList contains a list of MutatorPodStatus.
type MutatorPodStatusList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand All @@ -77,7 +77,7 @@ func init() {

// NewMutatorStatusForPod returns a mutator status object
// that has been initialized with the bare minimum of fields to make it functional
// with the mutator status controller
// with the mutator status controller.
func NewMutatorStatusForPod(pod *corev1.Pod, mutatorID mtypes.ID, scheme *runtime.Scheme) (*MutatorPodStatus, error) {
obj := &MutatorPodStatus{}
name, err := KeyForMutatorID(pod.Name, mutatorID)
Expand All @@ -103,7 +103,7 @@ func NewMutatorStatusForPod(pod *corev1.Pod, mutatorID mtypes.ID, scheme *runtim
}

// KeyForMutatorID returns a unique status object name given the Pod ID and
// a mutator object
// a mutator object.
func KeyForMutatorID(id string, mID mtypes.ID) (string, error) {
// This adds a requirement that the lowercase of all mutator kinds must be unique.
// Though this should already be the case because resource ~= lower(kind) (usually).
Expand Down

0 comments on commit 60f191c

Please sign in to comment.