Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7eb64c40
Commit
7eb64c40
authored
Nov 13, 2019
by
Mahendra Bagul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed test cases and rubycops issues
parent
a1b45eb2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
12 deletions
+34
-12
app/services/clusters/kubernetes/create_or_update_service_account_service.rb
...rs/kubernetes/create_or_update_service_account_service.rb
+12
-12
spec/services/clusters/kubernetes/create_or_update_namespace_service_spec.rb
...ers/kubernetes/create_or_update_namespace_service_spec.rb
+2
-0
spec/services/clusters/kubernetes/create_or_update_service_account_service_spec.rb
...bernetes/create_or_update_service_account_service_spec.rb
+20
-0
No files found.
app/services/clusters/kubernetes/create_or_update_service_account_service.rb
View file @
7eb64c40
...
...
@@ -147,23 +147,23 @@ module Clusters
def
crossplane_database_role_resource
Gitlab
::
Kubernetes
::
Role
.
new
(
name:
Clusters
::
Kubernetes
::
GITLAB_CROSSPLANE_DATABASE_ROLE_NAME
,
namespace:
service_account_namespace
,
rules:
[{
apiGroups:
%w(database.crossplane.io)
,
resources:
%w(postgresqlinstances)
,
verbs:
%w(get list create watch)
}]
name:
Clusters
::
Kubernetes
::
GITLAB_CROSSPLANE_DATABASE_ROLE_NAME
,
namespace:
service_account_namespace
,
rules:
[{
apiGroups:
%w(database.crossplane.io)
,
resources:
%w(postgresqlinstances)
,
verbs:
%w(get list create watch)
}]
).
generate
end
def
crossplane_database_role_binding_resource
Gitlab
::
Kubernetes
::
RoleBinding
.
new
(
name:
Clusters
::
Kubernetes
::
GITLAB_CROSSPLANE_DATABASE_ROLE_BINDING_NAME
,
role_name:
Clusters
::
Kubernetes
::
GITLAB_CROSSPLANE_DATABASE_ROLE_NAME
,
role_kind: :Role
,
namespace:
service_account_namespace
,
service_account_name:
service_account_name
name:
Clusters
::
Kubernetes
::
GITLAB_CROSSPLANE_DATABASE_ROLE_BINDING_NAME
,
role_name:
Clusters
::
Kubernetes
::
GITLAB_CROSSPLANE_DATABASE_ROLE_NAME
,
role_kind: :Role
,
namespace:
service_account_namespace
,
service_account_name:
service_account_name
).
generate
end
end
...
...
spec/services/clusters/kubernetes/create_or_update_namespace_service_spec.rb
View file @
7eb64c40
...
...
@@ -37,6 +37,8 @@ describe Clusters::Kubernetes::CreateOrUpdateNamespaceService, '#execute' do
stub_kubeclient_put_secret
(
api_url
,
"
#{
namespace
}
-token"
,
namespace:
namespace
)
stub_kubeclient_put_role
(
api_url
,
Clusters
::
Kubernetes
::
GITLAB_KNATIVE_SERVING_ROLE_NAME
,
namespace:
namespace
)
stub_kubeclient_put_role_binding
(
api_url
,
Clusters
::
Kubernetes
::
GITLAB_KNATIVE_SERVING_ROLE_BINDING_NAME
,
namespace:
namespace
)
stub_kubeclient_put_role
(
api_url
,
Clusters
::
Kubernetes
::
GITLAB_CROSSPLANE_DATABASE_ROLE_NAME
,
namespace:
namespace
)
stub_kubeclient_put_role_binding
(
api_url
,
Clusters
::
Kubernetes
::
GITLAB_CROSSPLANE_DATABASE_ROLE_BINDING_NAME
,
namespace:
namespace
)
stub_kubeclient_get_secret
(
api_url
,
...
...
spec/services/clusters/kubernetes/create_or_update_service_account_service_spec.rb
View file @
7eb64c40
...
...
@@ -145,6 +145,8 @@ describe Clusters::Kubernetes::CreateOrUpdateServiceAccountService do
stub_kubeclient_create_role_binding
(
api_url
,
namespace:
namespace
)
stub_kubeclient_put_role
(
api_url
,
Clusters
::
Kubernetes
::
GITLAB_KNATIVE_SERVING_ROLE_NAME
,
namespace:
namespace
)
stub_kubeclient_put_role_binding
(
api_url
,
Clusters
::
Kubernetes
::
GITLAB_KNATIVE_SERVING_ROLE_BINDING_NAME
,
namespace:
namespace
)
stub_kubeclient_put_role
(
api_url
,
Clusters
::
Kubernetes
::
GITLAB_CROSSPLANE_DATABASE_ROLE_NAME
,
namespace:
namespace
)
stub_kubeclient_put_role_binding
(
api_url
,
Clusters
::
Kubernetes
::
GITLAB_CROSSPLANE_DATABASE_ROLE_BINDING_NAME
,
namespace:
namespace
)
end
it_behaves_like
'creates service account and token'
...
...
@@ -189,6 +191,24 @@ describe Clusters::Kubernetes::CreateOrUpdateServiceAccountService do
)
)
end
it
'creates a role and role binding granting crossplane database permissions to the service account'
do
subject
expect
(
WebMock
).
to
have_requested
(
:put
,
api_url
+
"/apis/rbac.authorization.k8s.io/v1/namespaces/
#{
namespace
}
/roles/
#{
Clusters
::
Kubernetes
::
GITLAB_CROSSPLANE_DATABASE_ROLE_NAME
}
"
).
with
(
body:
hash_including
(
metadata:
{
name:
Clusters
::
Kubernetes
::
GITLAB_CROSSPLANE_DATABASE_ROLE_NAME
,
namespace:
namespace
},
rules:
[{
apiGroups:
%w(database.crossplane.io)
,
resources:
%w(postgresqlinstances)
,
verbs:
%w(get list create watch)
}]
)
)
end
end
end
end
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