Skip to content

Commit 270e27d

Browse files
committed
fix golint failures of test/e2e_kubeadm/util.go
1 parent 18533fe commit 270e27d

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

test/e2e_kubeadm/util.go

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ import (
2525
clientset "k8s.io/client-go/kubernetes"
2626
"k8s.io/kubernetes/test/e2e/framework"
2727

28-
. "github.com/onsi/gomega"
28+
"github.com/onsi/gomega"
2929
"github.com/onsi/gomega/gstruct"
3030
)
3131

3232
// ServiceAccounts utils
3333

34+
// ExpectServiceAccount expects to be able to get the ServiceAccount with specific name from the namespace
3435
func ExpectServiceAccount(c clientset.Interface, namespace, name string) {
3536
_, err := c.CoreV1().
3637
ServiceAccounts(namespace).
@@ -40,6 +41,7 @@ func ExpectServiceAccount(c clientset.Interface, namespace, name string) {
4041

4142
// Secret utils
4243

44+
// GetSecret gets Secret with specific name from the namespace
4345
func GetSecret(c clientset.Interface, namespace, name string) *corev1.Secret {
4446
r, err := c.CoreV1().
4547
Secrets(namespace).
@@ -50,6 +52,7 @@ func GetSecret(c clientset.Interface, namespace, name string) *corev1.Secret {
5052

5153
// ConfigMaps utils
5254

55+
// GetConfigMap gets ConfigMap with specific name from the namespace
5356
func GetConfigMap(c clientset.Interface, namespace, name string) *corev1.ConfigMap {
5457
r, err := c.CoreV1().
5558
ConfigMaps(namespace).
@@ -60,6 +63,7 @@ func GetConfigMap(c clientset.Interface, namespace, name string) *corev1.ConfigM
6063

6164
// Service utils
6265

66+
// ExpectService expects to be able to get the Service with specific name from the namespace
6367
func ExpectService(c clientset.Interface, namespace, name string) {
6468
_, err := c.CoreV1().
6569
Services(namespace).
@@ -69,6 +73,7 @@ func ExpectService(c clientset.Interface, namespace, name string) {
6973

7074
// Deployments utils
7175

76+
// GetDeployment gets Deployment with specific name from the namespace
7277
func GetDeployment(c clientset.Interface, namespace, name string) *appsv1.Deployment {
7378
r, err := c.AppsV1().
7479
Deployments(namespace).
@@ -79,6 +84,7 @@ func GetDeployment(c clientset.Interface, namespace, name string) *appsv1.Deploy
7984

8085
// DaemonSets utils
8186

87+
// GetDaemonSet gets DaemonSet with specific name from the namespace
8288
func GetDaemonSet(c clientset.Interface, namespace, name string) *appsv1.DaemonSet {
8389
r, err := c.AppsV1().
8490
DaemonSets(namespace).
@@ -89,52 +95,58 @@ func GetDaemonSet(c clientset.Interface, namespace, name string) *appsv1.DaemonS
8995

9096
// RBAC utils
9197

98+
// ExpectRole expects to be able to get the Role with specific name from the namespace
9299
func ExpectRole(c clientset.Interface, namespace, name string) {
93100
_, err := c.RbacV1().
94101
Roles(namespace).
95102
Get(name, metav1.GetOptions{})
96103
framework.ExpectNoError(err, "error getting Role %q from namespace %q", name, namespace)
97104
}
98105

106+
// ExpectRoleBinding expects to be able to get the RoleBinding with specific name from the namespace
99107
func ExpectRoleBinding(c clientset.Interface, namespace, name string) {
100108
_, err := c.RbacV1().
101109
RoleBindings(namespace).
102110
Get(name, metav1.GetOptions{})
103111
framework.ExpectNoError(err, "error getting RoleBinding %q from namespace %q", name, namespace)
104112
}
105113

114+
// ExpectClusterRole expects to be able to get the ClusterRole with specific name
106115
func ExpectClusterRole(c clientset.Interface, name string) {
107116
_, err := c.RbacV1().
108117
ClusterRoles().
109118
Get(name, metav1.GetOptions{})
110119
framework.ExpectNoError(err, "error getting ClusterRole %q", name)
111120
}
112121

122+
// ExpectClusterRoleBinding expects to be able to get the ClusterRoleBinding with specific name
113123
func ExpectClusterRoleBinding(c clientset.Interface, name string) {
114124
_, err := c.RbacV1().
115125
ClusterRoleBindings().
116126
Get(name, metav1.GetOptions{})
117127
framework.ExpectNoError(err, "error getting ClusterRoleBindings %q", name)
118128
}
119129

130+
// ExpectClusterRoleBindingWithSubjectAndRole expects to be able to get the ClusterRoleBinding with specific name, subject and role
120131
func ExpectClusterRoleBindingWithSubjectAndRole(c clientset.Interface, name, subjectKind, subject, role string) {
121132
binding, err := c.RbacV1().
122133
ClusterRoleBindings().
123134
Get(name, metav1.GetOptions{})
124135
framework.ExpectNoError(err, "error getting ClusterRoleBindings %q", name)
125-
Expect(binding.Subjects).To(
126-
ContainElement(subjectMatcher(
136+
gomega.Expect(binding.Subjects).To(
137+
gomega.ContainElement(subjectMatcher(
127138
subject,
128139
subjectKind,
129140
)),
130141
"ClusterRole %q does not have %s %q as subject", name, subjectKind, subject,
131142
)
132-
Expect(binding.RoleRef.Name).To(
133-
Equal(role),
143+
gomega.Expect(binding.RoleRef.Name).To(
144+
gomega.Equal(role),
134145
"ClusterRole %q does not have %q as role", name, role,
135146
)
136147
}
137148

149+
// ExpectSubjectHasAccessToResource expects that the subject has access to the target resource
138150
func ExpectSubjectHasAccessToResource(c clientset.Interface, subjectKind, subject string, resource *authv1.ResourceAttributes) {
139151
var sar *authv1.SubjectAccessReview
140152
switch subjectKind {
@@ -161,14 +173,14 @@ func ExpectSubjectHasAccessToResource(c clientset.Interface, subjectKind, subjec
161173
s, err := c.AuthorizationV1().SubjectAccessReviews().Create(sar)
162174
framework.ExpectNoError(err, "error getting SubjectAccessReview for %s %s to resource %+v", subjectKind, subject, *sar.Spec.ResourceAttributes)
163175

164-
Expect(s.Status.Allowed).Should(BeTrue(), "%s %s has no access to resource %+v", subjectKind, subject, *sar.Spec.ResourceAttributes)
176+
gomega.Expect(s.Status.Allowed).Should(gomega.BeTrue(), "%s %s has no access to resource %+v", subjectKind, subject, *sar.Spec.ResourceAttributes)
165177
}
166178

167179
// matchers
168180

169-
func subjectMatcher(name, kind string) OmegaMatcher {
181+
func subjectMatcher(name, kind string) gomega.OmegaMatcher {
170182
return gstruct.MatchFields(gstruct.IgnoreExtras, gstruct.Fields{
171-
"Name": Equal(name),
172-
"Kind": Equal(kind),
183+
"Name": gomega.Equal(name),
184+
"Kind": gomega.Equal(kind),
173185
})
174186
}

0 commit comments

Comments
 (0)