Skip to content

Commit 93a1886

Browse files
authored
refactor: enable revive, resolve all lints, remove unused code (#194)
Also bumps 2023 copyright to 2024. --------- Signed-off-by: Matt Welke <matt.welke@spectrocloud.com>
1 parent 7fc64d1 commit 93a1886

22 files changed

+144
-154
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/crd/bases/validation.spectrocloud.labs_azurevalidators.yaml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ spec:
4040
description: AzureValidatorSpec defines the desired state of AzureValidator
4141
properties:
4242
auth:
43+
description: AzureAuth defines authentication configuration for an
44+
AzureValidator.
4345
properties:
4446
implicit:
4547
description: |-
@@ -125,13 +127,13 @@ spec:
125127
will pass.
126128
items:
127129
description: |-
128-
Conveys that the security principal should be the member of a role assignment that provides the
129-
specified role for the specified scope. Scope can be either subscription, resource group, or
130-
resource.
130+
PermissionSet is part of an RBAC rule and verifies that a security principal has the specified
131+
permissions (via role assignments) at the specified scope. Scope can be either subscription,
132+
resource group, or resource.
131133
properties:
132134
actions:
133135
description: |-
134-
If provided, the actions that the role must be able to perform. Must not contain any
136+
Actions is a list of actions that the role must be able to perform. Must not contain any
135137
wildcards. If not specified, the role is assumed to already be able to perform all required
136138
actions.
137139
items:
@@ -147,9 +149,9 @@ spec:
147149
rule: self.all(item, !item.contains('*'))
148150
dataActions:
149151
description: |-
150-
If provided, the data actions that the role must be able to perform. Must not contain any
151-
wildcards. If not provided, the role is assumed to already be able to perform all required
152-
data actions.
152+
DataActions is a list of data actions that the role must be able to perform. Must not
153+
contain any wildcards. If not provided, the role is assumed to already be able to perform
154+
all required data actions.
153155
items:
154156
description: |-
155157
ActionStr is a type used for Action strings and DataAction strings. Alias exists to enable
@@ -163,9 +165,9 @@ spec:
163165
rule: self.all(item, !item.contains('*'))
164166
scope:
165167
description: |-
166-
The minimum scope of the role. Role assignments found at higher level scopes will satisfy
167-
this. For example, a role assignment found with subscription scope will satisfy a permission
168-
set where the role scope specified is a resource group within that subscription.
168+
Scope is the minimum scope of the role. Role assignments found at higher level scopes will
169+
satisfy this. For example, a role assignment found with subscription scope will satisfy a
170+
permission set where the role scope specified is a resource group within that subscription.
169171
type: string
170172
required:
171173
- scope

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
)

0 commit comments

Comments
 (0)