Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[main] Format Go code #285

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/discovery/v1alpha1/clusterducktype_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/discovery/v1alpha1/register_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
13 changes: 8 additions & 5 deletions pkg/collection/ducks.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ func (dh *duckHunter) Ducks() map[string][]v1alpha1.ResourceMeta {
}

// setAccessibleViaClusterRole sets the AccessibleViaClusterRole flag on each duck if
// the ClusterRole can preform the expected verbs on the duck
//
// the ClusterRole can preform the expected verbs on the duck
func setAccessibleViaClusterRole(metas []v1alpha1.ResourceMeta, accessibleGroupResources map[string]bool, kindToResource map[string]string) {
for index, meta := range metas {
// TODO: it would be nice if ResourceMeta had a version-free unique hash to do this.
Expand Down Expand Up @@ -333,8 +334,9 @@ func version(meta v1alpha1.ResourceMeta) string {

// accessibleGroupResources finds the rules in the ClusterRole that satisfy the expectedVerbs
// and returns a map of
// key: apiGroup + ":" + resource
// value: true if Rule satisfies the expectedVerbs, false otherwise
//
// key: apiGroup + ":" + resource
// value: true if Rule satisfies the expectedVerbs, false otherwise
func accessibleGroupResources(expectedVerbs []string, clusterRole *rbacv1.ClusterRole) map[string]bool {
groupResources := map[string]bool{}
if clusterRole == nil {
Expand All @@ -355,8 +357,9 @@ func accessibleGroupResources(expectedVerbs []string, clusterRole *rbacv1.Cluste
}

// Returns true if first is a fully contained subset of second
// returns false otherwise
// supports "*" as a wildcard
//
// returns false otherwise
// supports "*" as a wildcard
func isSubset(first, second []string) bool {
set := map[string]bool{}
for _, value := range second {
Expand Down
5 changes: 3 additions & 2 deletions pkg/reconciler/clusterducktype/clusterducktype.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, dt *v1alpha1.ClusterDuck
}

// getAggregatingClusterRole fetches the ClusterRole specified by Spec.Role.RoleRef
// if not set, it will default to using the first LabelSelector in Spec.Selectors to
// match any ClusterRole with a matching AggregationRule
//
// if not set, it will default to using the first LabelSelector in Spec.Selectors to
// match any ClusterRole with a matching AggregationRule
func (r *Reconciler) getAggregatingClusterRole(ctx context.Context, dt *v1alpha1.ClusterDuckType) (*rbacv1.ClusterRole, error) {
if dt.Spec.Role != nil && dt.Spec.Role.RoleRef != nil {
return r.client.RbacV1().ClusterRoles().Get(ctx, dt.Spec.Role.RoleRef.Name, metav1.GetOptions{})
Expand Down