Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
3dfe9072
Unverified
Commit
3dfe9072
authored
Mar 22, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Mar 22, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #75615 from oomichi/golint-e2e-framework
Fix golint failures of e2e/framework/[a-c].go
parents
9c53f240
63f44a0b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
19 deletions
+25
-19
authorizer_util.go
test/e2e/framework/authorizer_util.go
+2
-1
cleanup.go
test/e2e/framework/cleanup.go
+1
-0
create.go
test/e2e/framework/create.go
+22
-18
No files found.
test/e2e/framework/authorizer_util.go
View file @
3dfe9072
...
@@ -42,7 +42,7 @@ func WaitForAuthorizationUpdate(c v1beta1authorization.SubjectAccessReviewsGette
...
@@ -42,7 +42,7 @@ func WaitForAuthorizationUpdate(c v1beta1authorization.SubjectAccessReviewsGette
return
WaitForNamedAuthorizationUpdate
(
c
,
user
,
namespace
,
verb
,
""
,
resource
,
allowed
)
return
WaitForNamedAuthorizationUpdate
(
c
,
user
,
namespace
,
verb
,
""
,
resource
,
allowed
)
}
}
// WaitForAuthorizationUpdate checks if the given user can perform the named verb and action on the named resource.
// WaitFor
Named
AuthorizationUpdate checks if the given user can perform the named verb and action on the named resource.
// If policyCachePollTimeout is reached without the expected condition matching, an error is returned
// If policyCachePollTimeout is reached without the expected condition matching, an error is returned
func
WaitForNamedAuthorizationUpdate
(
c
v1beta1authorization
.
SubjectAccessReviewsGetter
,
user
,
namespace
,
verb
,
resourceName
string
,
resource
schema
.
GroupResource
,
allowed
bool
)
error
{
func
WaitForNamedAuthorizationUpdate
(
c
v1beta1authorization
.
SubjectAccessReviewsGetter
,
user
,
namespace
,
verb
,
resourceName
string
,
resource
schema
.
GroupResource
,
allowed
bool
)
error
{
review
:=
&
authorizationv1beta1
.
SubjectAccessReview
{
review
:=
&
authorizationv1beta1
.
SubjectAccessReview
{
...
@@ -133,6 +133,7 @@ var (
...
@@ -133,6 +133,7 @@ var (
isRBACEnabled
bool
isRBACEnabled
bool
)
)
// IsRBACEnabled returns true if RBAC is enabled. Otherwise false.
func
IsRBACEnabled
(
f
*
Framework
)
bool
{
func
IsRBACEnabled
(
f
*
Framework
)
bool
{
isRBACEnabledOnce
.
Do
(
func
()
{
isRBACEnabledOnce
.
Do
(
func
()
{
crs
,
err
:=
f
.
ClientSet
.
RbacV1
()
.
ClusterRoles
()
.
List
(
metav1
.
ListOptions
{})
crs
,
err
:=
f
.
ClientSet
.
RbacV1
()
.
ClusterRoles
()
.
List
(
metav1
.
ListOptions
{})
...
...
test/e2e/framework/cleanup.go
View file @
3dfe9072
...
@@ -18,6 +18,7 @@ package framework
...
@@ -18,6 +18,7 @@ package framework
import
"sync"
import
"sync"
// CleanupActionHandle is an integer pointer type for handling cleanup action
type
CleanupActionHandle
*
int
type
CleanupActionHandle
*
int
var
cleanupActionsLock
sync
.
Mutex
var
cleanupActionsLock
sync
.
Mutex
...
...
test/e2e/framework/create.go
View file @
3dfe9072
...
@@ -38,7 +38,7 @@ import (
...
@@ -38,7 +38,7 @@ import (
// LoadFromManifests loads .yaml or .json manifest files and returns
// LoadFromManifests loads .yaml or .json manifest files and returns
// all items that it finds in them. It supports all items for which
// all items that it finds in them. It supports all items for which
// there is a factory registered in
F
actories and .yaml files with
// there is a factory registered in
f
actories and .yaml files with
// multiple items separated by "---". Files are accessed via the
// multiple items separated by "---". Files are accessed via the
// "testfiles" package, which means they can come from a file system
// "testfiles" package, which means they can come from a file system
// or be built into the binary.
// or be built into the binary.
...
@@ -58,7 +58,7 @@ func (f *Framework) LoadFromManifests(files ...string) ([]interface{}, error) {
...
@@ -58,7 +58,7 @@ func (f *Framework) LoadFromManifests(files ...string) ([]interface{}, error) {
return
errors
.
Wrap
(
err
,
"decode TypeMeta"
)
return
errors
.
Wrap
(
err
,
"decode TypeMeta"
)
}
}
factory
:=
F
actories
[
what
]
factory
:=
f
actories
[
what
]
if
factory
==
nil
{
if
factory
==
nil
{
return
errors
.
Errorf
(
"item of type %+v not supported"
,
what
)
return
errors
.
Errorf
(
"item of type %+v not supported"
,
what
)
}
}
...
@@ -167,7 +167,7 @@ func (f *Framework) CreateItems(items ...interface{}) (func(), error) {
...
@@ -167,7 +167,7 @@ func (f *Framework) CreateItems(items ...interface{}) (func(), error) {
// Uncomment this line to get a full dump of the entire item.
// Uncomment this line to get a full dump of the entire item.
// description = fmt.Sprintf("%s:\n%s", description, PrettyPrint(item))
// description = fmt.Sprintf("%s:\n%s", description, PrettyPrint(item))
Logf
(
"creating %s"
,
description
)
Logf
(
"creating %s"
,
description
)
for
_
,
factory
:=
range
F
actories
{
for
_
,
factory
:=
range
f
actories
{
destructor
,
err
:=
factory
.
Create
(
f
,
item
)
destructor
,
err
:=
factory
.
Create
(
f
,
item
)
if
destructor
!=
nil
{
if
destructor
!=
nil
{
destructors
=
append
(
destructors
,
func
()
error
{
destructors
=
append
(
destructors
,
func
()
error
{
...
@@ -178,7 +178,7 @@ func (f *Framework) CreateItems(items ...interface{}) (func(), error) {
...
@@ -178,7 +178,7 @@ func (f *Framework) CreateItems(items ...interface{}) (func(), error) {
if
err
==
nil
{
if
err
==
nil
{
done
=
true
done
=
true
break
break
}
else
if
errors
.
Cause
(
err
)
!=
ItemNotSupported
{
}
else
if
errors
.
Cause
(
err
)
!=
error
ItemNotSupported
{
result
=
err
result
=
err
break
break
}
}
...
@@ -224,18 +224,22 @@ type What struct {
...
@@ -224,18 +224,22 @@ type What struct {
Kind
string
`json:"kind"`
Kind
string
`json:"kind"`
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new What.
func
(
in
*
What
)
DeepCopy
()
*
What
{
func
(
in
*
What
)
DeepCopy
()
*
What
{
return
&
What
{
Kind
:
in
.
Kind
}
return
&
What
{
Kind
:
in
.
Kind
}
}
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out.
func
(
in
*
What
)
DeepCopyInto
(
out
*
What
)
{
func
(
in
*
What
)
DeepCopyInto
(
out
*
What
)
{
out
.
Kind
=
in
.
Kind
out
.
Kind
=
in
.
Kind
}
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func
(
in
*
What
)
DeepCopyObject
()
runtime
.
Object
{
func
(
in
*
What
)
DeepCopyObject
()
runtime
.
Object
{
return
&
What
{
Kind
:
in
.
Kind
}
return
&
What
{
Kind
:
in
.
Kind
}
}
}
// GetObjectKind returns the ObjectKind schema
func
(
in
*
What
)
GetObjectKind
()
schema
.
ObjectKind
{
func
(
in
*
What
)
GetObjectKind
()
schema
.
ObjectKind
{
return
nil
return
nil
}
}
...
@@ -250,7 +254,7 @@ type ItemFactory interface {
...
@@ -250,7 +254,7 @@ type ItemFactory interface {
// Create is responsible for creating the item. It returns an
// Create is responsible for creating the item. It returns an
// error or a cleanup function for the created item.
// error or a cleanup function for the created item.
// If the item is of an unsupported type, it must return
// If the item is of an unsupported type, it must return
// an error that has ItemNotSupported as cause.
// an error that has
error
ItemNotSupported as cause.
Create
(
f
*
Framework
,
item
interface
{})
(
func
()
error
,
error
)
Create
(
f
*
Framework
,
item
interface
{})
(
func
()
error
,
error
)
}
}
...
@@ -266,11 +270,11 @@ func DescribeItem(item interface{}) string {
...
@@ -266,11 +270,11 @@ func DescribeItem(item interface{}) string {
return
fmt
.
Sprintf
(
"%T: %s"
,
item
,
item
)
return
fmt
.
Sprintf
(
"%T: %s"
,
item
,
item
)
}
}
// ItemNotSupported is the error that Create methods
//
error
ItemNotSupported is the error that Create methods
// must return or wrap when they don't support the given item.
// must return or wrap when they don't support the given item.
var
ItemNotSupported
=
errors
.
New
(
"not supported"
)
var
error
ItemNotSupported
=
errors
.
New
(
"not supported"
)
var
F
actories
=
map
[
What
]
ItemFactory
{
var
f
actories
=
map
[
What
]
ItemFactory
{
{
"ClusterRole"
}
:
&
clusterRoleFactory
{},
{
"ClusterRole"
}
:
&
clusterRoleFactory
{},
{
"ClusterRoleBinding"
}
:
&
clusterRoleBindingFactory
{},
{
"ClusterRoleBinding"
}
:
&
clusterRoleBindingFactory
{},
{
"DaemonSet"
}
:
&
daemonSetFactory
{},
{
"DaemonSet"
}
:
&
daemonSetFactory
{},
...
@@ -372,7 +376,7 @@ func (f *serviceAccountFactory) New() runtime.Object {
...
@@ -372,7 +376,7 @@ func (f *serviceAccountFactory) New() runtime.Object {
func
(
*
serviceAccountFactory
)
Create
(
f
*
Framework
,
i
interface
{})
(
func
()
error
,
error
)
{
func
(
*
serviceAccountFactory
)
Create
(
f
*
Framework
,
i
interface
{})
(
func
()
error
,
error
)
{
item
,
ok
:=
i
.
(
*
v1
.
ServiceAccount
)
item
,
ok
:=
i
.
(
*
v1
.
ServiceAccount
)
if
!
ok
{
if
!
ok
{
return
nil
,
ItemNotSupported
return
nil
,
error
ItemNotSupported
}
}
client
:=
f
.
ClientSet
.
CoreV1
()
.
ServiceAccounts
(
f
.
Namespace
.
GetName
())
client
:=
f
.
ClientSet
.
CoreV1
()
.
ServiceAccounts
(
f
.
Namespace
.
GetName
())
if
_
,
err
:=
client
.
Create
(
item
);
err
!=
nil
{
if
_
,
err
:=
client
.
Create
(
item
);
err
!=
nil
{
...
@@ -392,7 +396,7 @@ func (f *clusterRoleFactory) New() runtime.Object {
...
@@ -392,7 +396,7 @@ func (f *clusterRoleFactory) New() runtime.Object {
func
(
*
clusterRoleFactory
)
Create
(
f
*
Framework
,
i
interface
{})
(
func
()
error
,
error
)
{
func
(
*
clusterRoleFactory
)
Create
(
f
*
Framework
,
i
interface
{})
(
func
()
error
,
error
)
{
item
,
ok
:=
i
.
(
*
rbac
.
ClusterRole
)
item
,
ok
:=
i
.
(
*
rbac
.
ClusterRole
)
if
!
ok
{
if
!
ok
{
return
nil
,
ItemNotSupported
return
nil
,
error
ItemNotSupported
}
}
Logf
(
"Define cluster role %v"
,
item
.
GetName
())
Logf
(
"Define cluster role %v"
,
item
.
GetName
())
...
@@ -414,7 +418,7 @@ func (f *clusterRoleBindingFactory) New() runtime.Object {
...
@@ -414,7 +418,7 @@ func (f *clusterRoleBindingFactory) New() runtime.Object {
func
(
*
clusterRoleBindingFactory
)
Create
(
f
*
Framework
,
i
interface
{})
(
func
()
error
,
error
)
{
func
(
*
clusterRoleBindingFactory
)
Create
(
f
*
Framework
,
i
interface
{})
(
func
()
error
,
error
)
{
item
,
ok
:=
i
.
(
*
rbac
.
ClusterRoleBinding
)
item
,
ok
:=
i
.
(
*
rbac
.
ClusterRoleBinding
)
if
!
ok
{
if
!
ok
{
return
nil
,
ItemNotSupported
return
nil
,
error
ItemNotSupported
}
}
client
:=
f
.
ClientSet
.
RbacV1
()
.
ClusterRoleBindings
()
client
:=
f
.
ClientSet
.
RbacV1
()
.
ClusterRoleBindings
()
...
@@ -435,7 +439,7 @@ func (f *roleFactory) New() runtime.Object {
...
@@ -435,7 +439,7 @@ func (f *roleFactory) New() runtime.Object {
func
(
*
roleFactory
)
Create
(
f
*
Framework
,
i
interface
{})
(
func
()
error
,
error
)
{
func
(
*
roleFactory
)
Create
(
f
*
Framework
,
i
interface
{})
(
func
()
error
,
error
)
{
item
,
ok
:=
i
.
(
*
rbac
.
Role
)
item
,
ok
:=
i
.
(
*
rbac
.
Role
)
if
!
ok
{
if
!
ok
{
return
nil
,
ItemNotSupported
return
nil
,
error
ItemNotSupported
}
}
client
:=
f
.
ClientSet
.
RbacV1
()
.
Roles
(
f
.
Namespace
.
GetName
())
client
:=
f
.
ClientSet
.
RbacV1
()
.
Roles
(
f
.
Namespace
.
GetName
())
...
@@ -456,7 +460,7 @@ func (f *roleBindingFactory) New() runtime.Object {
...
@@ -456,7 +460,7 @@ func (f *roleBindingFactory) New() runtime.Object {
func
(
*
roleBindingFactory
)
Create
(
f
*
Framework
,
i
interface
{})
(
func
()
error
,
error
)
{
func
(
*
roleBindingFactory
)
Create
(
f
*
Framework
,
i
interface
{})
(
func
()
error
,
error
)
{
item
,
ok
:=
i
.
(
*
rbac
.
RoleBinding
)
item
,
ok
:=
i
.
(
*
rbac
.
RoleBinding
)
if
!
ok
{
if
!
ok
{
return
nil
,
ItemNotSupported
return
nil
,
error
ItemNotSupported
}
}
client
:=
f
.
ClientSet
.
RbacV1
()
.
RoleBindings
(
f
.
Namespace
.
GetName
())
client
:=
f
.
ClientSet
.
RbacV1
()
.
RoleBindings
(
f
.
Namespace
.
GetName
())
...
@@ -477,7 +481,7 @@ func (f *serviceFactory) New() runtime.Object {
...
@@ -477,7 +481,7 @@ func (f *serviceFactory) New() runtime.Object {
func
(
*
serviceFactory
)
Create
(
f
*
Framework
,
i
interface
{})
(
func
()
error
,
error
)
{
func
(
*
serviceFactory
)
Create
(
f
*
Framework
,
i
interface
{})
(
func
()
error
,
error
)
{
item
,
ok
:=
i
.
(
*
v1
.
Service
)
item
,
ok
:=
i
.
(
*
v1
.
Service
)
if
!
ok
{
if
!
ok
{
return
nil
,
ItemNotSupported
return
nil
,
error
ItemNotSupported
}
}
client
:=
f
.
ClientSet
.
CoreV1
()
.
Services
(
f
.
Namespace
.
GetName
())
client
:=
f
.
ClientSet
.
CoreV1
()
.
Services
(
f
.
Namespace
.
GetName
())
...
@@ -498,7 +502,7 @@ func (f *statefulSetFactory) New() runtime.Object {
...
@@ -498,7 +502,7 @@ func (f *statefulSetFactory) New() runtime.Object {
func
(
*
statefulSetFactory
)
Create
(
f
*
Framework
,
i
interface
{})
(
func
()
error
,
error
)
{
func
(
*
statefulSetFactory
)
Create
(
f
*
Framework
,
i
interface
{})
(
func
()
error
,
error
)
{
item
,
ok
:=
i
.
(
*
apps
.
StatefulSet
)
item
,
ok
:=
i
.
(
*
apps
.
StatefulSet
)
if
!
ok
{
if
!
ok
{
return
nil
,
ItemNotSupported
return
nil
,
error
ItemNotSupported
}
}
client
:=
f
.
ClientSet
.
AppsV1
()
.
StatefulSets
(
f
.
Namespace
.
GetName
())
client
:=
f
.
ClientSet
.
AppsV1
()
.
StatefulSets
(
f
.
Namespace
.
GetName
())
...
@@ -519,7 +523,7 @@ func (f *daemonSetFactory) New() runtime.Object {
...
@@ -519,7 +523,7 @@ func (f *daemonSetFactory) New() runtime.Object {
func
(
*
daemonSetFactory
)
Create
(
f
*
Framework
,
i
interface
{})
(
func
()
error
,
error
)
{
func
(
*
daemonSetFactory
)
Create
(
f
*
Framework
,
i
interface
{})
(
func
()
error
,
error
)
{
item
,
ok
:=
i
.
(
*
apps
.
DaemonSet
)
item
,
ok
:=
i
.
(
*
apps
.
DaemonSet
)
if
!
ok
{
if
!
ok
{
return
nil
,
ItemNotSupported
return
nil
,
error
ItemNotSupported
}
}
client
:=
f
.
ClientSet
.
AppsV1
()
.
DaemonSets
(
f
.
Namespace
.
GetName
())
client
:=
f
.
ClientSet
.
AppsV1
()
.
DaemonSets
(
f
.
Namespace
.
GetName
())
...
@@ -540,7 +544,7 @@ func (f *storageClassFactory) New() runtime.Object {
...
@@ -540,7 +544,7 @@ func (f *storageClassFactory) New() runtime.Object {
func
(
*
storageClassFactory
)
Create
(
f
*
Framework
,
i
interface
{})
(
func
()
error
,
error
)
{
func
(
*
storageClassFactory
)
Create
(
f
*
Framework
,
i
interface
{})
(
func
()
error
,
error
)
{
item
,
ok
:=
i
.
(
*
storage
.
StorageClass
)
item
,
ok
:=
i
.
(
*
storage
.
StorageClass
)
if
!
ok
{
if
!
ok
{
return
nil
,
ItemNotSupported
return
nil
,
error
ItemNotSupported
}
}
client
:=
f
.
ClientSet
.
StorageV1
()
.
StorageClasses
()
client
:=
f
.
ClientSet
.
StorageV1
()
.
StorageClasses
()
...
@@ -561,7 +565,7 @@ func (f *secretFactory) New() runtime.Object {
...
@@ -561,7 +565,7 @@ func (f *secretFactory) New() runtime.Object {
func
(
*
secretFactory
)
Create
(
f
*
Framework
,
i
interface
{})
(
func
()
error
,
error
)
{
func
(
*
secretFactory
)
Create
(
f
*
Framework
,
i
interface
{})
(
func
()
error
,
error
)
{
item
,
ok
:=
i
.
(
*
v1
.
Secret
)
item
,
ok
:=
i
.
(
*
v1
.
Secret
)
if
!
ok
{
if
!
ok
{
return
nil
,
ItemNotSupported
return
nil
,
error
ItemNotSupported
}
}
client
:=
f
.
ClientSet
.
CoreV1
()
.
Secrets
(
f
.
Namespace
.
GetName
())
client
:=
f
.
ClientSet
.
CoreV1
()
.
Secrets
(
f
.
Namespace
.
GetName
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment