Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nmaas Janitor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nmaas
nmaas Janitor
Commits
7e3695c3
Commit
7e3695c3
authored
6 years ago
by
Michał Bień
Browse files
Options
Downloads
Patches
Plain Diff
Nonexistent namespace is now created when createorreplace called
parent
0c71d680
Branches
release/1.2.0
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/service/v1/config-service.go
+14
-4
14 additions, 4 deletions
pkg/service/v1/config-service.go
pkg/service/v1/config-service_test.go
+0
-12
0 additions, 12 deletions
pkg/service/v1/config-service_test.go
with
14 additions
and
16 deletions
pkg/service/v1/config-service.go
+
14
−
4
View file @
7e3695c3
...
...
@@ -194,8 +194,13 @@ func (s *configServiceServer) CreateOrReplace(ctx context.Context, req *v1.Insta
//check if given k8s namespace exists
_
,
err
=
s
.
kubeAPI
.
CoreV1
()
.
Namespaces
()
.
Get
(
depl
.
Namespace
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
prepareResponse
(
v1
.
Status_FAILED
,
namespaceNotFound
),
err
if
err
!=
nil
{
ns
:=
apiv1
.
Namespace
{}
ns
.
Name
=
depl
.
Namespace
_
,
err
=
s
.
kubeAPI
.
CoreV1
()
.
Namespaces
()
.
Create
(
&
ns
)
if
err
!=
nil
{
return
prepareResponse
(
v1
.
Status_FAILED
,
namespaceNotFound
),
err
}
}
//check if configmap already exists
...
...
@@ -318,8 +323,13 @@ func (s *basicAuthServiceServer) CreateOrReplace(ctx context.Context, req *v1.In
//check if given k8s namespace exists
_
,
err
:=
s
.
kubeAPI
.
CoreV1
()
.
Namespaces
()
.
Get
(
depl
.
Namespace
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
return
prepareResponse
(
v1
.
Status_FAILED
,
namespaceNotFound
),
err
if
err
!=
nil
{
ns
:=
apiv1
.
Namespace
{}
ns
.
Name
=
depl
.
Namespace
_
,
err
=
s
.
kubeAPI
.
CoreV1
()
.
Namespaces
()
.
Create
(
&
ns
)
if
err
!=
nil
{
return
prepareResponse
(
v1
.
Status_FAILED
,
namespaceNotFound
),
err
}
}
secretName
:=
getAuthSecretName
(
depl
.
Uid
)
...
...
This diff is collapsed.
Click to expand it.
pkg/service/v1/config-service_test.go
+
0
−
12
View file @
7e3695c3
...
...
@@ -170,18 +170,6 @@ func TestBasicAuthServiceServer_CreateOrReplace(t *testing.T) {
t
.
Fail
()
}
//Fail on namespace check
freq
:=
v1
.
InstanceCredentialsRequest
{
Api
:
apiVersion
,
Instance
:&
fake_ns_inst
,
Credentials
:
&
creds
}
res
,
err
=
server
.
CreateOrReplace
(
context
.
Background
(),
&
freq
)
if
err
==
nil
||
res
.
Status
!=
v1
.
Status_FAILED
{
t
.
Fail
()
}
//create mock namespace
ns
:=
corev1
.
Namespace
{}
ns
.
Name
=
"test-namespace"
_
,
_
=
client
.
CoreV1
()
.
Namespaces
()
.
Create
(
&
ns
)
//Should create new secret
req
:=
v1
.
InstanceCredentialsRequest
{
Api
:
apiVersion
,
Instance
:&
inst
,
Credentials
:
&
creds
}
res
,
err
=
server
.
CreateOrReplace
(
context
.
Background
(),
&
req
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment