Skip to content

Commit ece6404

Browse files
committed
golint
1 parent 287cfc0 commit ece6404

File tree

5 files changed

+18
-22
lines changed

5 files changed

+18
-22
lines changed

cmd/managed-kubernetes-auditing-toolkit/eks/role_relationships.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,9 @@ func doFindRoleRelationshipsCommand(targetCluster string) error {
7979
if outputFile != "" {
8080
log.Println("Writing " + strings.ToUpper(outputFormat) + " output to " + outputFile)
8181
return os.WriteFile(outputFile, []byte(output), 0644)
82-
} else {
83-
print(output)
8482
}
8583

84+
print(output)
8685
return nil
8786
}
8887

@@ -128,18 +127,17 @@ func getTextOutput(resolver *role_relationships.EKSCluster) (string, error) {
128127
}
129128
if !found {
130129
return "No service accounts found that can assume AWS roles", nil
131-
} else {
132-
return t.Render(), nil
133130
}
131+
return t.Render(), nil
134132
}
135133

136134
type Vertex struct {
137-
Id int
135+
ID int
138136
Label string
139137
}
140138

141-
func (v *Vertex) ID() int {
142-
return v.Id
139+
func (v *Vertex) GetID() int {
140+
return v.ID
143141
}
144142
func getDotOutput(resolver *role_relationships.EKSCluster) (string, error) {
145143
graphAst, _ := gographviz.ParseString(`digraph G { }`)

internal/aws/iam_evaluation/policy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func (m *Policy) Authorize(context *AuthorizationContext) *AuthorizationResult {
1818

1919
if willAllow {
2020
return &AuthorizationResultAllow
21-
} else {
22-
return &AuthorizationResultDeny // implicit deny
2321
}
22+
23+
return &AuthorizationResultDeny // implicit deny
2424
}

internal/aws/iam_evaluation/policy_parser.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func ParseRoleTrustPolicy(policy string) (*Policy, error) {
3131
}
3232
resultPolicy.Statements = append(resultPolicy.Statements, statement)
3333
}
34-
34+
3535
return &resultPolicy, nil
3636
}
3737

@@ -107,9 +107,8 @@ func parsePrincipals(principals interface{}) ([]*Principal, error) {
107107
case string:
108108
if principals == "*" {
109109
return []*Principal{{Type: PrincipalTypeUnknown, ID: "*"}}, nil
110-
} else {
111-
return nil, fmt.Errorf("invalid principal: %s", principals)
112110
}
111+
return nil, fmt.Errorf("invalid principal: %s", principals)
113112
case map[string]interface{}:
114113
results := []*Principal{}
115114
for principalType, principalValue := range principals {
@@ -125,7 +124,7 @@ func parsePrincipals(principals interface{}) ([]*Principal, error) {
125124
}
126125
}
127126

128-
func parseSinglePrincipal(rawPrincipalType string, principalId interface{}) ([]*Principal, error) {
127+
func parseSinglePrincipal(rawPrincipalType string, principalID interface{}) ([]*Principal, error) {
129128
types := map[string]PrincipalType{
130129
"aws": PrincipalTypeAWS,
131130
"federated": PrincipalTypeFederated,
@@ -136,9 +135,9 @@ func parseSinglePrincipal(rawPrincipalType string, principalId interface{}) ([]*
136135
if !ok {
137136
return nil, fmt.Errorf("invalid principal type: %s", rawPrincipalType)
138137
}
139-
values, err := ensureStringArray(principalId)
138+
values, err := ensureStringArray(principalID)
140139
if err != nil {
141-
return nil, fmt.Errorf("invalid principal value: %v", principalId)
140+
return nil, fmt.Errorf("invalid principal value: %v", principalID)
142141
}
143142

144143
principals := []*Principal{}

internal/aws/iam_evaluation/policy_parser_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func Test_ensureStringArray(t *testing.T) {
145145
func Test_parseSinglePrincipal(t *testing.T) {
146146
type args struct {
147147
rawPrincipalType string
148-
principalId interface{}
148+
principalID interface{}
149149
}
150150
tests := []struct {
151151
name string
@@ -157,15 +157,15 @@ func Test_parseSinglePrincipal(t *testing.T) {
157157
name: "parse string principal",
158158
args: args{
159159
rawPrincipalType: "aws",
160-
principalId: "foo",
160+
principalID: "foo",
161161
},
162162
want: []*Principal{{Type: PrincipalTypeAWS, ID: "foo"}},
163163
},
164164
{
165165
name: "parse array principal",
166166
args: args{
167167
rawPrincipalType: "federated",
168-
principalId: []string{"foo", "bar"},
168+
principalID: []string{"foo", "bar"},
169169
},
170170
want: []*Principal{
171171
{Type: PrincipalTypeFederated, ID: "foo"},
@@ -176,14 +176,14 @@ func Test_parseSinglePrincipal(t *testing.T) {
176176
name: "parse invalid principal",
177177
args: args{
178178
rawPrincipalType: "IDoNotExist",
179-
principalId: "foo",
179+
principalID: "foo",
180180
},
181181
wantErr: true,
182182
},
183183
}
184184
for _, tt := range tests {
185185
t.Run(tt.name, func(t *testing.T) {
186-
got, err := parseSinglePrincipal(tt.args.rawPrincipalType, tt.args.principalId)
186+
got, err := parseSinglePrincipal(tt.args.rawPrincipalType, tt.args.principalID)
187187
if (err != nil) != tt.wantErr {
188188
t.Errorf("parseSinglePrincipal() error = %v, wantErr %v", err, tt.wantErr)
189189
return

pkg/managed-kubernetes-auditing-toolkit/eks/imds/imds_tester.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ func (m *ImdsTester) TestImdsAccessible() (*ImdsTestResult, error) {
6767
}
6868
if strings.Contains(podLogs, "Failed to connect") {
6969
return &ImdsTestResult{IsImdsAccessible: false}, nil
70-
} else {
71-
return &ImdsTestResult{IsImdsAccessible: true, NodeRoleName: podLogs}, nil
7270
}
71+
return &ImdsTestResult{IsImdsAccessible: true, NodeRoleName: podLogs}, nil
7372
}
7473

7574
func (m *ImdsTester) handleCtrlC() {

0 commit comments

Comments
 (0)