Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
Charts
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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
魏国强
Charts
Commits
85cfcf9e
Commit
85cfcf9e
authored
Jan 29, 2021
by
Waqar Ahmed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Report result for helm dependency update
parent
23ed6248
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
4 deletions
+32
-4
update_dependencies
update_dependencies
+32
-4
No files found.
update_dependencies
View file @
85cfcf9e
...
...
@@ -4,6 +4,10 @@ import errno
import
os
import
subprocess
from
collections
import
defaultdict
ITEMS
=
defaultdict
(
lambda
:
{
'success'
:
[],
'error'
:
[]})
class
ValidationException
(
Exception
):
def
__init__
(
self
,
error_msg
,
error_no
=
errno
.
EFAULT
):
...
...
@@ -32,31 +36,55 @@ class CatalogItemNotFoundException(NotFoundException):
super
(
CatalogItemNotFoundException
,
self
).
__init__
(
f'Failed to find
{
path
!
r
}
catalog item'
)
def
report_result
():
print
(
'[
\033
[94mINFO
\x1B
[0m]
\t
Execution Complete'
)
for
index
,
item
in
enumerate
(
ITEMS
):
index
+=
1
data
=
ITEMS
[
item
]
print
(
f'
\n\n
[
\033
[94mINFO
\x1B
[0m]
\t
{
index
}
)
{
item
}
'
)
if
data
[
'success'
]:
print
(
f'[
\033
[92mOK
\x1B
[0m]
\t
- Successfully updated dependencies for
{
", "
.
join
(
data
[
"success"
])
}
versions'
)
for
i_v
,
version
in
enumerate
(
data
[
'error'
]):
v_name
,
error
=
version
print
(
f'[
\033
[91mFAILED
\x1B
[0m]
\t
(
{
i_v
+
1
}
) Failed to update dependencies for
{
v_name
!
r
}
version:
{
error
}
'
)
def
update_train_charts
(
train_path
):
# We will gather all charts in the train and then for each chart all it's versions will be updated
if
not
os
.
path
.
exists
(
train_path
):
raise
TrainNotFoundException
()
print
(
f'[
\033
[94mINFO
\x1B
[0m]
\t
Processing
{
train_path
!
r
}
train'
)
for
item
in
os
.
listdir
(
train_path
):
process_catalog_item
(
os
.
path
.
join
(
train_path
,
item
))
report_result
()
def
process_catalog_item
(
item_path
):
if
not
os
.
path
.
exists
(
item_path
):
raise
CatalogItemNotFoundException
(
item_path
)
item_name
=
item_path
.
rsplit
(
'/'
,
1
)[
-
1
]
print
(
f'[
\033
[94mINFO
\x1B
[0m]
\t
Processing
{
item_name
!
r
}
catalog item'
)
for
item_version
in
os
.
listdir
(
item_path
):
update_item_version
(
os
.
path
.
join
(
item_path
,
item_version
))
update_item_version
(
item_name
,
item_version
,
os
.
path
.
join
(
item_path
,
item_version
))
def
update_item_version
(
version_path
):
def
update_item_version
(
item_name
,
version
,
version_path
):
cp
=
subprocess
.
Popen
(
[
'helm'
,
'dependency'
,
'update'
,
version_path
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdout
,
stderr
=
cp
.
communicate
()
if
cp
.
returncode
:
# TODO: Let's keep a log of success and failure scenarios
pass
ITEMS
[
item_name
][
'error'
].
append
((
version
,
stderr
.
decode
()))
else
:
ITEMS
[
item_name
][
'success'
].
append
(
version
)
def
main
():
...
...
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