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
7e9281fc
Commit
7e9281fc
authored
May 14, 2015
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow ServiceAccountsController to manage multiple named service accounts
parent
fce749b0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
137 additions
and
70 deletions
+137
-70
controllermanager.go
cmd/kube-controller-manager/app/controllermanager.go
+1
-1
serviceaccounts_controller.go
pkg/serviceaccount/serviceaccounts_controller.go
+45
-24
serviceaccounts_controller_test.go
pkg/serviceaccount/serviceaccounts_controller_test.go
+90
-44
service_account_test.go
test/integration/service_account_test.go
+1
-1
No files found.
cmd/kube-controller-manager/app/controllermanager.go
View file @
7e9281fc
...
@@ -263,7 +263,7 @@ func (s *CMServer) Run(_ []string) error {
...
@@ -263,7 +263,7 @@ func (s *CMServer) Run(_ []string) error {
serviceaccount
.
NewServiceAccountsController
(
serviceaccount
.
NewServiceAccountsController
(
kubeClient
,
kubeClient
,
serviceaccount
.
DefaultServiceAccountControllerOptions
(),
serviceaccount
.
DefaultServiceAccount
s
ControllerOptions
(),
)
.
Run
()
)
.
Run
()
select
{}
select
{}
...
...
pkg/serviceaccount/serviceaccounts_controller.go
View file @
7e9281fc
...
@@ -28,6 +28,7 @@ import (
...
@@ -28,6 +28,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
"github.com/golang/glog"
"github.com/golang/glog"
)
)
...
@@ -41,24 +42,38 @@ func nameIndexFunc(obj interface{}) (string, error) {
...
@@ -41,24 +42,38 @@ func nameIndexFunc(obj interface{}) (string, error) {
return
meta
.
Name
(),
nil
return
meta
.
Name
(),
nil
}
}
type
ServiceAccountControllerOptions
struct
{
// ServiceAccountsControllerOptions contains options for running a ServiceAccountsController
Name
string
type
ServiceAccountsControllerOptions
struct
{
// Names is the set of service account names to ensure exist in every namespace
Names
util
.
StringSet
// ServiceAccountResync is the interval between full resyncs of ServiceAccounts.
// If non-zero, all service accounts will be re-listed this often.
// Otherwise, re-list will be delayed as long as possible (until the watch is closed or times out).
ServiceAccountResync
time
.
Duration
ServiceAccountResync
time
.
Duration
NamespaceResync
time
.
Duration
// NamespaceResync is the interval between full resyncs of Namespaces.
// If non-zero, all namespaces will be re-listed this often.
// Otherwise, re-list will be delayed as long as possible (until the watch is closed or times out).
NamespaceResync
time
.
Duration
}
}
func
DefaultServiceAccount
ControllerOptions
()
ServiceAccount
ControllerOptions
{
func
DefaultServiceAccount
sControllerOptions
()
ServiceAccounts
ControllerOptions
{
return
ServiceAccount
ControllerOptions
{
Name
:
"default"
}
return
ServiceAccount
sControllerOptions
{
Names
:
util
.
NewStringSet
(
"default"
)
}
}
}
// NewServiceAccountsController returns a new *ServiceAccountsController.
// NewServiceAccountsController returns a new *ServiceAccountsController.
func
NewServiceAccountsController
(
cl
*
client
.
Client
,
options
ServiceAccount
ControllerOptions
)
*
ServiceAccountsController
{
func
NewServiceAccountsController
(
cl
client
.
Interface
,
options
ServiceAccounts
ControllerOptions
)
*
ServiceAccountsController
{
e
:=
&
ServiceAccountsController
{
e
:=
&
ServiceAccountsController
{
client
:
cl
,
client
:
cl
,
name
:
options
.
Name
,
name
s
:
options
.
Names
,
}
}
accountSelector
:=
fields
.
SelectorFromSet
(
map
[
string
]
string
{
client
.
ObjectNameField
:
options
.
Name
})
accountSelector
:=
fields
.
Everything
()
if
len
(
options
.
Names
)
==
1
{
// If we're maintaining a single account, we can scope the accounts we watch to just that name
accountSelector
=
fields
.
SelectorFromSet
(
map
[
string
]
string
{
client
.
ObjectNameField
:
options
.
Names
.
List
()[
0
]})
}
e
.
serviceAccounts
,
e
.
serviceAccountController
=
framework
.
NewIndexerInformer
(
e
.
serviceAccounts
,
e
.
serviceAccountController
=
framework
.
NewIndexerInformer
(
&
cache
.
ListWatch
{
&
cache
.
ListWatch
{
ListFunc
:
func
()
(
runtime
.
Object
,
error
)
{
ListFunc
:
func
()
(
runtime
.
Object
,
error
)
{
...
@@ -101,8 +116,8 @@ func NewServiceAccountsController(cl *client.Client, options ServiceAccountContr
...
@@ -101,8 +116,8 @@ func NewServiceAccountsController(cl *client.Client, options ServiceAccountContr
type
ServiceAccountsController
struct
{
type
ServiceAccountsController
struct
{
stopChan
chan
struct
{}
stopChan
chan
struct
{}
client
*
client
.
Client
client
client
.
Interface
name
string
name
s
util
.
StringSet
serviceAccounts
cache
.
Indexer
serviceAccounts
cache
.
Indexer
namespaces
cache
.
Indexer
namespaces
cache
.
Indexer
...
@@ -137,27 +152,34 @@ func (e *ServiceAccountsController) serviceAccountDeleted(obj interface{}) {
...
@@ -137,27 +152,34 @@ func (e *ServiceAccountsController) serviceAccountDeleted(obj interface{}) {
// corresponding secrets will be cleaned up during the Secret re-list
// corresponding secrets will be cleaned up during the Secret re-list
return
return
}
}
e
.
createDefaultServiceAccountIfNeeded
(
serviceAccount
.
Namespace
)
// If the deleted service account is one we're maintaining, recreate it
if
e
.
names
.
Has
(
serviceAccount
.
Name
)
{
e
.
createServiceAccountIfNeeded
(
serviceAccount
.
Name
,
serviceAccount
.
Namespace
)
}
}
}
// namespaceAdded reacts to a Namespace creation by creating a default ServiceAccount object
// namespaceAdded reacts to a Namespace creation by creating a default ServiceAccount object
func
(
e
*
ServiceAccountsController
)
namespaceAdded
(
obj
interface
{})
{
func
(
e
*
ServiceAccountsController
)
namespaceAdded
(
obj
interface
{})
{
namespace
:=
obj
.
(
*
api
.
Namespace
)
namespace
:=
obj
.
(
*
api
.
Namespace
)
e
.
createDefaultServiceAccountIfNeeded
(
namespace
.
Name
)
for
_
,
name
:=
range
e
.
names
.
List
()
{
e
.
createServiceAccountIfNeeded
(
name
,
namespace
.
Name
)
}
}
}
// namespaceUpdated reacts to a Namespace update (or re-list) by creating a default ServiceAccount in the namespace if needed
// namespaceUpdated reacts to a Namespace update (or re-list) by creating a default ServiceAccount in the namespace if needed
func
(
e
*
ServiceAccountsController
)
namespaceUpdated
(
oldObj
interface
{},
newObj
interface
{})
{
func
(
e
*
ServiceAccountsController
)
namespaceUpdated
(
oldObj
interface
{},
newObj
interface
{})
{
newNamespace
:=
newObj
.
(
*
api
.
Namespace
)
newNamespace
:=
newObj
.
(
*
api
.
Namespace
)
e
.
createDefaultServiceAccountIfNeeded
(
newNamespace
.
Name
)
for
_
,
name
:=
range
e
.
names
.
List
()
{
e
.
createServiceAccountIfNeeded
(
name
,
newNamespace
.
Name
)
}
}
}
// create
DefaultServiceAccountIfNeeded creates a default ServiceAccount
in the given namespace if:
// create
ServiceAccountIfNeeded creates a ServiceAccount with the given name
in the given namespace if:
// *
it default
ServiceAccount does not already exist
// *
the named
ServiceAccount does not already exist
// * the specified namespace exists
// * the specified namespace exists
// * the specified namespace is in the ACTIVE phase
// * the specified namespace is in the ACTIVE phase
func
(
e
*
ServiceAccountsController
)
create
DefaultServiceAccountIfNeeded
(
namespace
string
)
{
func
(
e
*
ServiceAccountsController
)
create
ServiceAccountIfNeeded
(
name
,
namespace
string
)
{
serviceAccount
,
err
:=
e
.
get
DefaultServiceAccount
(
namespace
)
serviceAccount
,
err
:=
e
.
get
ServiceAccount
(
name
,
namespace
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Error
(
err
)
glog
.
Error
(
err
)
return
return
...
@@ -181,22 +203,21 @@ func (e *ServiceAccountsController) createDefaultServiceAccountIfNeeded(namespac
...
@@ -181,22 +203,21 @@ func (e *ServiceAccountsController) createDefaultServiceAccountIfNeeded(namespac
return
return
}
}
e
.
create
DefaultServiceAccount
(
namespace
)
e
.
create
ServiceAccount
(
name
,
namespace
)
}
}
// createDefaultServiceAccount creates a default ServiceAccount in the specified namespace
// createDefaultServiceAccount creates a default ServiceAccount in the specified namespace
func
(
e
*
ServiceAccountsController
)
create
DefaultServiceAccount
(
namespace
string
)
{
func
(
e
*
ServiceAccountsController
)
create
ServiceAccount
(
name
,
namespace
string
)
{
serviceAccount
:=
&
api
.
ServiceAccount
{}
serviceAccount
:=
&
api
.
ServiceAccount
{}
serviceAccount
.
Name
=
e
.
name
serviceAccount
.
Name
=
name
serviceAccount
.
Namespace
=
namespace
serviceAccount
.
Namespace
=
namespace
if
_
,
err
:=
e
.
client
.
ServiceAccounts
(
namespace
)
.
Create
(
serviceAccount
);
err
!=
nil
{
if
_
,
err
:=
e
.
client
.
ServiceAccounts
(
namespace
)
.
Create
(
serviceAccount
);
err
!=
nil
{
glog
.
Error
(
err
)
glog
.
Error
(
err
)
}
}
}
}
// getDefaultServiceAccount returns the default ServiceAccount for the given namespace
// getDefaultServiceAccount returns the ServiceAccount with the given name for the given namespace
func
(
e
*
ServiceAccountsController
)
getDefaultServiceAccount
(
namespace
string
)
(
*
api
.
ServiceAccount
,
error
)
{
func
(
e
*
ServiceAccountsController
)
getServiceAccount
(
name
,
namespace
string
)
(
*
api
.
ServiceAccount
,
error
)
{
key
:=
&
api
.
ServiceAccount
{
ObjectMeta
:
api
.
ObjectMeta
{
Namespace
:
namespace
}}
key
:=
&
api
.
ServiceAccount
{
ObjectMeta
:
api
.
ObjectMeta
{
Namespace
:
namespace
}}
accounts
,
err
:=
e
.
serviceAccounts
.
Index
(
"namespace"
,
key
)
accounts
,
err
:=
e
.
serviceAccounts
.
Index
(
"namespace"
,
key
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -205,7 +226,7 @@ func (e *ServiceAccountsController) getDefaultServiceAccount(namespace string) (
...
@@ -205,7 +226,7 @@ func (e *ServiceAccountsController) getDefaultServiceAccount(namespace string) (
for
_
,
obj
:=
range
accounts
{
for
_
,
obj
:=
range
accounts
{
serviceAccount
:=
obj
.
(
*
api
.
ServiceAccount
)
serviceAccount
:=
obj
.
(
*
api
.
ServiceAccount
)
if
e
.
name
==
serviceAccount
.
Name
{
if
name
==
serviceAccount
.
Name
{
return
serviceAccount
,
nil
return
serviceAccount
,
nil
}
}
}
}
...
...
pkg/serviceaccount/serviceaccounts_controller_test.go
View file @
7e9281fc
...
@@ -23,7 +23,7 @@ import (
...
@@ -23,7 +23,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/testapi"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client
/testclient
"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
)
)
...
@@ -51,6 +51,9 @@ func makeTestServer(t *testing.T, namespace string, serviceAccountResponse serve
...
@@ -51,6 +51,9 @@ func makeTestServer(t *testing.T, namespace string, serviceAccountResponse serve
func
TestServiceAccountCreation
(
t
*
testing
.
T
)
{
func
TestServiceAccountCreation
(
t
*
testing
.
T
)
{
ns
:=
api
.
NamespaceDefault
ns
:=
api
.
NamespaceDefault
defaultName
:=
"default"
managedName
:=
"managed"
activeNS
:=
&
api
.
Namespace
{
activeNS
:=
&
api
.
Namespace
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
ns
},
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
ns
},
Status
:
api
.
NamespaceStatus
{
Status
:
api
.
NamespaceStatus
{
...
@@ -63,79 +66,118 @@ func TestServiceAccountCreation(t *testing.T) {
...
@@ -63,79 +66,118 @@ func TestServiceAccountCreation(t *testing.T) {
Phase
:
api
.
NamespaceTerminating
,
Phase
:
api
.
NamespaceTerminating
,
},
},
}
}
serviceAccount
:=
&
api
.
ServiceAccount
{
defaultServiceAccount
:=
&
api
.
ServiceAccount
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
defaultName
,
Namespace
:
ns
,
ResourceVersion
:
"1"
,
},
}
managedServiceAccount
:=
&
api
.
ServiceAccount
{
ObjectMeta
:
api
.
ObjectMeta
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"default"
,
Name
:
managedName
,
Namespace
:
ns
,
ResourceVersion
:
"1"
,
},
}
unmanagedServiceAccount
:=
&
api
.
ServiceAccount
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"other-unmanaged"
,
Namespace
:
ns
,
Namespace
:
ns
,
ResourceVersion
:
"1"
,
ResourceVersion
:
"1"
,
},
},
}
}
testcases
:=
map
[
string
]
struct
{
testcases
:=
map
[
string
]
struct
{
ExistingNamespace
*
api
.
Namespace
ExistingNamespace
*
api
.
Namespace
ExistingServiceAccount
*
api
.
ServiceAccount
ExistingServiceAccount
s
[]
*
api
.
ServiceAccount
AddedNamespace
*
api
.
Namespace
AddedNamespace
*
api
.
Namespace
UpdatedNamespace
*
api
.
Namespace
UpdatedNamespace
*
api
.
Namespace
DeletedServiceAccount
*
api
.
ServiceAccount
DeletedServiceAccount
*
api
.
ServiceAccount
ExpectCreatedServiceAccount
bool
ExpectCreatedServiceAccount
s
[]
string
}{
}{
"new active namespace missing serviceaccounts"
:
{
ExistingServiceAccounts
:
[]
*
api
.
ServiceAccount
{},
AddedNamespace
:
activeNS
,
ExpectCreatedServiceAccounts
:
util
.
NewStringSet
(
defaultName
,
managedName
)
.
List
(),
},
"new active namespace missing serviceaccount"
:
{
"new active namespace missing serviceaccount"
:
{
AddedNamespace
:
activeNS
,
ExistingServiceAccounts
:
[]
*
api
.
ServiceAccount
{
managedServiceAccount
},
ExpectCreatedServiceAccount
:
true
,
AddedNamespace
:
activeNS
,
ExpectCreatedServiceAccounts
:
[]
string
{
defaultName
},
},
},
"new active namespace with serviceaccount"
:
{
"new active namespace with serviceaccount
s
"
:
{
ExistingServiceAccount
:
serviceAccount
,
ExistingServiceAccount
s
:
[]
*
api
.
ServiceAccount
{
defaultServiceAccount
,
managedServiceAccount
}
,
AddedNamespace
:
activeNS
,
AddedNamespace
:
activeNS
,
ExpectCreatedServiceAccount
:
false
,
ExpectCreatedServiceAccount
s
:
[]
string
{}
,
},
},
"new terminating namespace"
:
{
"new terminating namespace"
:
{
AddedNamespace
:
terminatingNS
,
ExistingServiceAccounts
:
[]
*
api
.
ServiceAccount
{},
ExpectCreatedServiceAccount
:
false
,
AddedNamespace
:
terminatingNS
,
ExpectCreatedServiceAccounts
:
[]
string
{},
},
},
"updated active namespace missing serviceaccounts"
:
{
ExistingServiceAccounts
:
[]
*
api
.
ServiceAccount
{},
UpdatedNamespace
:
activeNS
,
ExpectCreatedServiceAccounts
:
util
.
NewStringSet
(
defaultName
,
managedName
)
.
List
(),
},
"updated active namespace missing serviceaccount"
:
{
"updated active namespace missing serviceaccount"
:
{
UpdatedNamespace
:
activeNS
,
ExistingServiceAccounts
:
[]
*
api
.
ServiceAccount
{
defaultServiceAccount
},
ExpectCreatedServiceAccount
:
true
,
UpdatedNamespace
:
activeNS
,
ExpectCreatedServiceAccounts
:
[]
string
{
managedName
},
},
},
"updated active namespace with serviceaccount"
:
{
"updated active namespace with serviceaccount
s
"
:
{
ExistingServiceAccount
:
serviceAccount
,
ExistingServiceAccount
s
:
[]
*
api
.
ServiceAccount
{
defaultServiceAccount
,
managedServiceAccount
}
,
UpdatedNamespace
:
activeNS
,
UpdatedNamespace
:
activeNS
,
ExpectCreatedServiceAccount
:
false
,
ExpectCreatedServiceAccount
s
:
[]
string
{}
,
},
},
"updated terminating namespace"
:
{
"updated terminating namespace"
:
{
UpdatedNamespace
:
terminatingNS
,
ExistingServiceAccounts
:
[]
*
api
.
ServiceAccount
{},
ExpectCreatedServiceAccount
:
false
,
UpdatedNamespace
:
terminatingNS
,
ExpectCreatedServiceAccounts
:
[]
string
{},
},
},
"deleted serviceaccount without namespace"
:
{
"deleted serviceaccount without namespace"
:
{
DeletedServiceAccount
:
s
erviceAccount
,
DeletedServiceAccount
:
defaultS
erviceAccount
,
ExpectCreatedServiceAccount
:
false
,
ExpectCreatedServiceAccount
s
:
[]
string
{}
,
},
},
"deleted serviceaccount with active namespace"
:
{
"deleted serviceaccount with active namespace"
:
{
ExistingNamespace
:
activeNS
,
ExistingNamespace
:
activeNS
,
DeletedServiceAccount
:
s
erviceAccount
,
DeletedServiceAccount
:
defaultS
erviceAccount
,
ExpectCreatedServiceAccount
:
true
,
ExpectCreatedServiceAccount
s
:
[]
string
{
defaultName
}
,
},
},
"deleted serviceaccount with terminating namespace"
:
{
"deleted serviceaccount with terminating namespace"
:
{
ExistingNamespace
:
terminatingNS
,
ExistingNamespace
:
terminatingNS
,
DeletedServiceAccount
:
serviceAccount
,
DeletedServiceAccount
:
defaultServiceAccount
,
ExpectCreatedServiceAccount
:
false
,
ExpectCreatedServiceAccounts
:
[]
string
{},
},
"deleted unmanaged serviceaccount with active namespace"
:
{
ExistingNamespace
:
activeNS
,
DeletedServiceAccount
:
unmanagedServiceAccount
,
ExpectCreatedServiceAccounts
:
[]
string
{},
},
"deleted unmanaged serviceaccount with terminating namespace"
:
{
ExistingNamespace
:
terminatingNS
,
DeletedServiceAccount
:
unmanagedServiceAccount
,
ExpectCreatedServiceAccounts
:
[]
string
{},
},
},
}
}
for
k
,
tc
:=
range
testcases
{
for
k
,
tc
:=
range
testcases
{
client
:=
testclient
.
NewSimpleFake
(
defaultServiceAccount
,
managedServiceAccount
)
testServer
,
handler
:=
makeTestServer
(
t
,
ns
,
serverResponse
{
http
.
StatusOK
,
serviceAccount
}
)
options
:=
DefaultServiceAccountsControllerOptions
(
)
client
:=
client
.
NewOrDie
(
&
client
.
Config
{
Host
:
testServer
.
URL
,
Version
:
testapi
.
Version
()}
)
options
.
Names
=
util
.
NewStringSet
(
defaultName
,
managedName
)
controller
:=
NewServiceAccountsController
(
client
,
DefaultServiceAccountControllerOptions
()
)
controller
:=
NewServiceAccountsController
(
client
,
options
)
if
tc
.
ExistingNamespace
!=
nil
{
if
tc
.
ExistingNamespace
!=
nil
{
controller
.
namespaces
.
Add
(
tc
.
ExistingNamespace
)
controller
.
namespaces
.
Add
(
tc
.
ExistingNamespace
)
}
}
if
tc
.
ExistingServiceAccount
!=
nil
{
for
_
,
s
:=
range
tc
.
ExistingServiceAccounts
{
controller
.
serviceAccounts
.
Add
(
tc
.
ExistingServiceAccount
)
controller
.
serviceAccounts
.
Add
(
s
)
}
}
if
tc
.
AddedNamespace
!=
nil
{
if
tc
.
AddedNamespace
!=
nil
{
...
@@ -150,16 +192,20 @@ func TestServiceAccountCreation(t *testing.T) {
...
@@ -150,16 +192,20 @@ func TestServiceAccountCreation(t *testing.T) {
controller
.
serviceAccountDeleted
(
tc
.
DeletedServiceAccount
)
controller
.
serviceAccountDeleted
(
tc
.
DeletedServiceAccount
)
}
}
if
tc
.
ExpectCreatedServiceAccount
{
if
len
(
tc
.
ExpectCreatedServiceAccounts
)
!=
len
(
client
.
Actions
)
{
if
!
handler
.
ValidateRequestCount
(
t
,
1
)
{
t
.
Errorf
(
"%s: Expected to create accounts %#v. Actual actions were: %#v"
,
k
,
tc
.
ExpectCreatedServiceAccounts
,
client
.
Actions
)
t
.
Errorf
(
"%s: Expected a single creation call"
,
k
)
continue
}
for
i
,
expectedName
:=
range
tc
.
ExpectCreatedServiceAccounts
{
action
:=
client
.
Actions
[
i
]
if
action
.
Action
!=
"create-serviceaccount"
{
t
.
Errorf
(
"%s: Unexpected action %s"
,
k
,
action
.
Action
)
break
}
}
}
else
{
createdAccount
:=
action
.
Value
.
(
*
api
.
ServiceAccount
)
if
!
handler
.
ValidateRequestCount
(
t
,
0
)
{
if
createdAccount
.
Name
!=
expectedName
{
t
.
Errorf
(
"%s: Expected
no creation calls"
,
k
)
t
.
Errorf
(
"%s: Expected
%s to be created, got %s"
,
k
,
expectedName
,
createdAccount
.
Name
)
}
}
}
}
testServer
.
Close
()
}
}
}
}
test/integration/service_account_test.go
View file @
7e9281fc
...
@@ -423,7 +423,7 @@ func startServiceAccountTestServer(t *testing.T) (*client.Client, client.Config,
...
@@ -423,7 +423,7 @@ func startServiceAccountTestServer(t *testing.T) (*client.Client, client.Config,
// Start the service account and service account token controllers
// Start the service account and service account token controllers
tokenController
:=
serviceaccount
.
NewTokensController
(
rootClient
,
serviceaccount
.
DefaultTokenControllerOptions
(
serviceaccount
.
JWTTokenGenerator
(
serviceAccountKey
)))
tokenController
:=
serviceaccount
.
NewTokensController
(
rootClient
,
serviceaccount
.
DefaultTokenControllerOptions
(
serviceaccount
.
JWTTokenGenerator
(
serviceAccountKey
)))
tokenController
.
Run
()
tokenController
.
Run
()
serviceAccountController
:=
serviceaccount
.
NewServiceAccountsController
(
rootClient
,
serviceaccount
.
DefaultServiceAccountControllerOptions
())
serviceAccountController
:=
serviceaccount
.
NewServiceAccountsController
(
rootClient
,
serviceaccount
.
DefaultServiceAccount
s
ControllerOptions
())
serviceAccountController
.
Run
()
serviceAccountController
.
Run
()
// Start the admission plugin reflectors
// Start the admission plugin reflectors
serviceAccountAdmission
.
Run
()
serviceAccountAdmission
.
Run
()
...
...
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