Skip to content

Commit d911531

Browse files
committed
Add revive linting. Address linting errors. Remove unused code.
Signed-off-by: Matt Welke <matt.welke@spectrocloud.com>
1 parent 7fc64d1 commit d911531

21 files changed

+132
-144
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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ More information can be found via the [Kubebuilder Documentation](https://book.k
154154

155155
## License
156156

157-
Copyright 2023.
157+
Copyright 2024.
158158

159159
Licensed under the Apache License, Version 2.0 (the "License");
160160
you may not use this file except in compliance with the License.

api/v1alpha1/azurevalidator_types.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023.
2+
Copyright 2024.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@ type AzureValidatorSpec struct {
3333
Auth AzureAuth `json:"auth" yaml:"auth"`
3434
}
3535

36+
// ResultCount returns the number of validation results expected for an AzureValidatorSpec.
3637
func (s AzureValidatorSpec) ResultCount() int {
3738
return len(s.RBACRules) + len(s.CommunityGalleryImageRules)
3839
}
@@ -83,6 +84,7 @@ type CommunityGallery struct {
8384
Name string `json:"name" yaml:"name"`
8485
}
8586

87+
// AzureAuth defines authentication configuration for an AzureValidator.
8688
type AzureAuth struct {
8789
// If true, the AzureValidator will use the Azure SDK's default credential chain to authenticate.
8890
// Set to true if using WorkloadIdentityCredentials.
@@ -98,25 +100,25 @@ type AzureAuth struct {
98100
// +kubebuilder:validation:MaxLength=200
99101
type ActionStr string
100102

101-
// Conveys that the security principal should be the member of a role assignment that provides the
102-
// specified role for the specified scope. Scope can be either subscription, resource group, or
103-
// resource.
103+
// PermissionSet is part of an RBAC rule and verifies that a security principal has the specified
104+
// permissions (via role assignments) at the specified scope. Scope can be either subscription,
105+
// resource group, or resource.
104106
type PermissionSet struct {
105-
// If provided, the actions that the role must be able to perform. Must not contain any
107+
// Actions is a list of actions that the role must be able to perform. Must not contain any
106108
// wildcards. If not specified, the role is assumed to already be able to perform all required
107109
// actions.
108110
//+kubebuilder:validation:MaxItems=1000
109111
//+kubebuilder:validation:XValidation:message="Actions cannot have wildcards.",rule="self.all(item, !item.contains('*'))"
110112
Actions []ActionStr `json:"actions,omitempty" yaml:"actions,omitempty"`
111-
// If provided, the data actions that the role must be able to perform. Must not contain any
112-
// wildcards. If not provided, the role is assumed to already be able to perform all required
113-
// data actions.
113+
// DataActions is a list of data actions that the role must be able to perform. Must not
114+
// contain any wildcards. If not provided, the role is assumed to already be able to perform
115+
// all required data actions.
114116
//+kubebuilder:validation:MaxItems=1000
115117
//+kubebuilder:validation:XValidation:message="DataActions cannot have wildcards.",rule="self.all(item, !item.contains('*'))"
116118
DataActions []ActionStr `json:"dataActions,omitempty" yaml:"dataActions,omitempty"`
117-
// The minimum scope of the role. Role assignments found at higher level scopes will satisfy
118-
// this. For example, a role assignment found with subscription scope will satisfy a permission
119-
// set where the role scope specified is a resource group within that subscription.
119+
// Scope is the minimum scope of the role. Role assignments found at higher level scopes will
120+
// satisfy this. For example, a role assignment found with subscription scope will satisfy a
121+
// permission set where the role scope specified is a resource group within that subscription.
120122
Scope string `json:"scope" yaml:"scope"`
121123
}
122124

api/v1alpha1/groupversion_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023.
2+
Copyright 2024.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023.
2+
Copyright 2024.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -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 an AzureValidator controller.
1718
package main
1819

1920
import (

config/samples/azurevalidator-communitygalleryimages-one-image.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ spec:
1414
name: AKSUbuntu-38d80f77-467a-481f-a8d4-09b6d4220bd2
1515
images:
1616
- 1804gen2gpucontainerd
17-
subscriptionID: <subscription>
17+
subscriptionID: 9b16dd0b-1bea-4c9a-a291-65e6f44c4745

hack/boilerplate.go.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023.
2+
Copyright 2024.
33

44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -12,4 +12,4 @@ distributed under the License is distributed on an "AS IS" BASIS,
1212
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
15-
*/
15+
*/

internal/constants/constants.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
// Package constants contains Azure plugin constants.
12
package constants
23

34
const (
5+
// PluginCode is the code for the plugin.
46
PluginCode string = "Azure"
57

8+
// ValidationTypeRBAC is the validation type for RBAC rules.
69
ValidationTypeRBAC string = "azure-rbac"
710

11+
// ValidationTypeCommunityGalleryImages is the validation type for community gallery image rules.
812
ValidationTypeCommunityGalleryImages string = "azure-community-gallery-image"
913
)

internal/controller/azurevalidator_controller.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2023.
2+
Copyright 2024.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
// Package controller defines a controller for reconciling AzureValidator objects.
1718
package controller
1819

1920
import (
@@ -43,6 +44,7 @@ import (
4344
vres "github.com/validator-labs/validator/pkg/validationresult"
4445
)
4546

47+
// ErrSecretNameRequired is returned when the auth.secretName field is empty.
4648
var ErrSecretNameRequired = errors.New("auth.secretName is required")
4749

4850
// AzureValidatorReconciler reconciles an AzureValidator object
@@ -123,10 +125,10 @@ func (r *AzureValidatorReconciler) Reconcile(ctx context.Context, req ctrl.Reque
123125
defer cancel()
124126
}
125127

126-
daClient := azure_utils.NewAzureDenyAssignmentsClient(azureCtx, azureAPI.DenyAssignmentsClient)
127-
raClient := azure_utils.NewAzureRoleAssignmentsClient(azureCtx, azureAPI.RoleAssignmentsClient)
128-
rdClient := azure_utils.NewAzureRoleDefinitionsClient(azureCtx, azureAPI.RoleDefinitionsClient)
129-
cgiClient := azure_utils.NewAzureCommunityGalleryImagesClient(azureCtx, azureAPI.CommunityGalleryImagesClientProducer)
128+
daClient := azure_utils.NewDenyAssignmentsClient(azureCtx, azureAPI.DenyAssignmentsClient)
129+
raClient := azure_utils.NewRoleAssignmentsClient(azureCtx, azureAPI.RoleAssignmentsClient)
130+
rdClient := azure_utils.NewRoleDefinitionsClient(azureCtx, azureAPI.RoleDefinitionsClient)
131+
cgiClient := azure_utils.NewCommunityGalleryImagesClient(azureCtx, azureAPI.CommunityGalleryImagesClientProducer)
130132

131133
// RBAC rules
132134
rbacSvc := validators.NewRBACRuleService(daClient, raClient, rdClient)

0 commit comments

Comments
 (0)