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
8c24d3e4
Commit
8c24d3e4
authored
Feb 04, 2021
by
Rémy Coutable
Committed by
Albert Salim
Feb 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a dedicated project token for the 'review-cleanup' job
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
aa83c04b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
7 deletions
+6
-7
scripts/review_apps/automated_cleanup.rb
scripts/review_apps/automated_cleanup.rb
+2
-1
spec/tooling/lib/tooling/kubernetes_client_spec.rb
spec/tooling/lib/tooling/kubernetes_client_spec.rb
+4
-4
tooling/lib/tooling/kubernetes_client.rb
tooling/lib/tooling/kubernetes_client.rb
+0
-2
No files found.
scripts/review_apps/automated_cleanup.rb
View file @
8c24d3e4
...
@@ -22,7 +22,8 @@ class AutomatedCleanup
...
@@ -22,7 +22,8 @@ class AutomatedCleanup
%w[gitlab gitlab-ee]
.
include?
(
ENV
[
'CI_PROJECT_NAME'
])
%w[gitlab gitlab-ee]
.
include?
(
ENV
[
'CI_PROJECT_NAME'
])
end
end
def
initialize
(
project_path:
ENV
[
'CI_PROJECT_PATH'
],
gitlab_token:
ENV
[
'GITLAB_BOT_REVIEW_APPS_CLEANUP_TOKEN'
])
# $GITLAB_PROJECT_REVIEW_APP_CLEANUP_API_TOKEN => `Automated Review App Cleanup` project token
def
initialize
(
project_path:
ENV
[
'CI_PROJECT_PATH'
],
gitlab_token:
ENV
[
'GITLAB_PROJECT_REVIEW_APP_CLEANUP_API_TOKEN'
])
@project_path
=
project_path
@project_path
=
project_path
@gitlab_token
=
gitlab_token
@gitlab_token
=
gitlab_token
end
end
...
...
spec/tooling/lib/tooling/kubernetes_client_spec.rb
View file @
8c24d3e4
...
@@ -29,7 +29,7 @@ RSpec.describe Tooling::KubernetesClient do
...
@@ -29,7 +29,7 @@ RSpec.describe Tooling::KubernetesClient do
specify
do
specify
do
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen_with_detail
)
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen_with_detail
)
.
with
([
"kubectl delete
#{
described_class
::
RESOURCE_LIST
}
"
+
.
with
([
"kubectl delete
#{
described_class
::
RESOURCE_LIST
}
"
+
%(--namespace "#{namespace}" --now --ignore-not-found --
include-uninitialized --
wait=#{wait} #{release_names_in_command})
])
%(--namespace "#{namespace}" --now --ignore-not-found --wait=#{wait} #{release_names_in_command})
])
.
and_return
(
Gitlab
::
Popen
::
Result
.
new
([],
''
,
''
,
double
(
success?:
true
)))
.
and_return
(
Gitlab
::
Popen
::
Result
.
new
([],
''
,
''
,
double
(
success?:
true
)))
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen_with_detail
)
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen_with_detail
)
...
@@ -44,7 +44,7 @@ RSpec.describe Tooling::KubernetesClient do
...
@@ -44,7 +44,7 @@ RSpec.describe Tooling::KubernetesClient do
it
'raises an error if the Kubernetes command fails'
do
it
'raises an error if the Kubernetes command fails'
do
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen_with_detail
)
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen_with_detail
)
.
with
([
"kubectl delete
#{
described_class
::
RESOURCE_LIST
}
"
+
.
with
([
"kubectl delete
#{
described_class
::
RESOURCE_LIST
}
"
+
%(--namespace "#{namespace}" --now --ignore-not-found --
include-uninitialized --
wait=true -l release="#{release_name}")
])
%(--namespace "#{namespace}" --now --ignore-not-found --wait=true -l release="#{release_name}")
])
.
and_return
(
Gitlab
::
Popen
::
Result
.
new
([],
''
,
''
,
double
(
success?:
false
)))
.
and_return
(
Gitlab
::
Popen
::
Result
.
new
([],
''
,
''
,
double
(
success?:
false
)))
expect
{
subject
.
cleanup_by_release
(
release_name:
release_name
)
}.
to
raise_error
(
described_class
::
CommandFailedError
)
expect
{
subject
.
cleanup_by_release
(
release_name:
release_name
)
}.
to
raise_error
(
described_class
::
CommandFailedError
)
...
@@ -81,7 +81,7 @@ RSpec.describe Tooling::KubernetesClient do
...
@@ -81,7 +81,7 @@ RSpec.describe Tooling::KubernetesClient do
specify
do
specify
do
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen_with_detail
)
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen_with_detail
)
.
with
([
"kubectl delete
#{
resource_type
}
"
.
squeeze
(
' '
)
+
.
with
([
"kubectl delete
#{
resource_type
}
"
.
squeeze
(
' '
)
+
%(--namespace "#{namespace}" --now --ignore-not-found --
include-uninitialized --
wait=#{wait} #{release_names_in_command})
])
%(--namespace "#{namespace}" --now --ignore-not-found --wait=#{wait} #{release_names_in_command})
])
.
and_return
(
Gitlab
::
Popen
::
Result
.
new
([],
''
,
''
,
double
(
success?:
true
)))
.
and_return
(
Gitlab
::
Popen
::
Result
.
new
([],
''
,
''
,
double
(
success?:
true
)))
# We're not verifying the output here, just silencing it
# We're not verifying the output here, just silencing it
...
@@ -92,7 +92,7 @@ RSpec.describe Tooling::KubernetesClient do
...
@@ -92,7 +92,7 @@ RSpec.describe Tooling::KubernetesClient do
it
'raises an error if the Kubernetes command fails'
do
it
'raises an error if the Kubernetes command fails'
do
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen_with_detail
)
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen_with_detail
)
.
with
([
"kubectl delete
#{
resource_type
}
"
+
.
with
([
"kubectl delete
#{
resource_type
}
"
+
%(--namespace "#{namespace}" --now --ignore-not-found --
include-uninitialized --
wait=true #{pod_for_release})
])
%(--namespace "#{namespace}" --now --ignore-not-found --wait=true #{pod_for_release})
])
.
and_return
(
Gitlab
::
Popen
::
Result
.
new
([],
''
,
''
,
double
(
success?:
false
)))
.
and_return
(
Gitlab
::
Popen
::
Result
.
new
([],
''
,
''
,
double
(
success?:
false
)))
expect
{
subject
.
cleanup_by_created_at
(
resource_type:
resource_type
,
created_before:
two_days_ago
)
}.
to
raise_error
(
described_class
::
CommandFailedError
)
expect
{
subject
.
cleanup_by_created_at
(
resource_type:
resource_type
,
created_before:
two_days_ago
)
}.
to
raise_error
(
described_class
::
CommandFailedError
)
...
...
tooling/lib/tooling/kubernetes_client.rb
View file @
8c24d3e4
...
@@ -43,7 +43,6 @@ module Tooling
...
@@ -43,7 +43,6 @@ module Tooling
%(--namespace "#{namespace}")
,
%(--namespace "#{namespace}")
,
'--now'
,
'--now'
,
'--ignore-not-found'
,
'--ignore-not-found'
,
'--include-uninitialized'
,
%(--wait=#{wait})
,
%(--wait=#{wait})
,
selector
selector
]
]
...
@@ -58,7 +57,6 @@ module Tooling
...
@@ -58,7 +57,6 @@ module Tooling
%(--namespace "#{namespace}")
,
%(--namespace "#{namespace}")
,
'--now'
,
'--now'
,
'--ignore-not-found'
,
'--ignore-not-found'
,
'--include-uninitialized'
,
%(--wait=#{wait})
,
%(--wait=#{wait})
,
resource_names
.
join
(
' '
)
resource_names
.
join
(
' '
)
]
]
...
...
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