Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
workspaces
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ssa
workspaces
Commits
17d08f61
Commit
17d08f61
authored
2 years ago
by
Charlotte Hausman
Browse files
Options
Downloads
Patches
Plain Diff
add error catching for empty/whitespace-only strings, ensure valid annihilation path
parent
41a731e4
No related branches found
No related tags found
1 merge request
!866
add error catching for empty/whitespace-only strings, ensure valid annihilation path
Pipeline
#4724
passed
2 years ago
Stage: cache-build
Stage: build
Stage: unit-test
Stage: test-coverage
Stage: push
Stage: deploy-coverage-page
Stage: generate-yaml
Stage: trigger
Stage: deploy
Stage: e2e-test
Stage: .post
Pipeline: workspaces
#4725
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/cli/executables/pexable/ws_annihilator/ws_annihilator/annihilator.py
+35
-9
35 additions, 9 deletions
...bles/pexable/ws_annihilator/ws_annihilator/annihilator.py
with
35 additions
and
9 deletions
apps/cli/executables/pexable/ws_annihilator/ws_annihilator/annihilator.py
+
35
−
9
View file @
17d08f61
...
...
@@ -117,6 +117,22 @@ class Annihilator:
"""
return
self
.
_settings
.
get
(
area_to_clean
.
lower
())
@staticmethod
def
path_valid
(
constructed_path
:
str
,
base_path
:
str
)
->
bool
:
"""
Check if the constructed path is valid for annihilation
:param constructed_path: path to verify
:param base_path: base path which directory should be annihilated from
:return: True if path is valid for annihilation
"""
return
(
constructed_path
!=
base_path
and
constructed_path
!=
base_path
+
"
/
"
and
len
(
constructed_path
)
>
len
(
base_path
)
)
def
get_days_to_keep
(
self
,
area_to_clean
:
str
)
->
str
:
"""
Return the number of days to keep directories in a specified area from capo settings
...
...
@@ -150,7 +166,9 @@ class Annihilator:
# catch empty string response
if
dir_list
:
for
stale
in
dir_list
.
split
(
"
,
"
):
name_list
.
append
(
pathlib
.
Path
(
str
(
stale
)).
stem
)
# catch empty string directory or whitespace only directory
if
stale
and
not
stale
.
isspace
():
name_list
.
append
(
pathlib
.
Path
(
str
(
stale
)).
stem
)
return
name_list
...
...
@@ -168,7 +186,9 @@ class Annihilator:
# After annihilation set cleaned flag...
if
area
==
Areas
.
SPOOL
.
value
:
logger
.
info
(
f
"
Annihilation complete for
{
directory
}
, setting
'
cleaned
'
flag on workflow request...
"
)
self
.
set_cleaned
(
directory
)
path
=
self
.
determine_path
(
area
)
clean_me
=
path
+
"
/
"
+
directory
self
.
set_cleaned
(
clean_me
)
else
:
logger
.
info
(
f
"
Annihilation complete for
{
directory
}
in
{
area
}
.
"
)
...
...
@@ -201,15 +221,21 @@ class Annihilator:
for
directory
in
stale
:
dir_path
=
path
+
"
/
"
+
directory
if
not
pathlib
.
Path
(
dir_path
).
exists
():
if
area_to_clean
==
Areas
.
SPOOL
.
value
:
logger
.
info
(
f
"
directory
{
dir_path
}
not found, setting
'
cleaned
'
flag on workflow request...
"
)
self
.
set_cleaned
(
dir_path
)
if
self
.
path_valid
(
dir_path
,
path
):
if
not
pathlib
.
Path
(
dir_path
).
exists
():
if
area_to_clean
==
Areas
.
SPOOL
.
value
:
logger
.
info
(
f
"
directory
{
dir_path
}
not found, setting
'
cleaned
'
flag on workflow request...
"
)
self
.
set_cleaned
(
dir_path
)
else
:
logger
.
info
(
f
"
directory
{
dir_path
}
not found in
{
area_to_clean
}
, skipping...
"
)
else
:
logger
.
info
(
f
"
directory
{
dir_path
}
not found in
{
area_to_clean
}
, skipping...
"
)
logger
.
info
(
f
"
found directory
{
directory
}
, annihilating...
"
)
self
.
annihilate_directory
(
area_to_clean
,
directory
)
else
:
logger
.
info
(
f
"
foun
d directory
{
dir
ectory
}
, annihilating..
.
"
)
self
.
annihilate_directory
(
area_to_clean
,
directory
)
logger
.
error
(
f
"
Error: Received invali
d directory
'
{
dir
_path
}
'
as input for annihilation. Aborting
.
"
)
exit
(
1
)
def
run
(
self
):
if
self
.
_args
.
all
:
...
...
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