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
23ed6248
Commit
23ed6248
authored
Jan 29, 2021
by
Waqar Ahmed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a helper tool to updte chart dependencies
parent
fe8069a2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
0 deletions
+77
-0
update_dependencies
update_dependencies
+77
-0
No files found.
update_dependencies
0 → 100755
View file @
23ed6248
#!/usr/bin/env python
import
argparse
import
errno
import
os
import
subprocess
class
ValidationException
(
Exception
):
def
__init__
(
self
,
error_msg
,
error_no
=
errno
.
EFAULT
):
self
.
errmsg
=
error_msg
self
.
errno
=
error_no
def
get_error_name
(
self
):
return
errno
.
errorcode
.
get
(
self
.
errno
)
or
'EUNKNOWN'
def
__str__
(
self
):
return
f'[
{
self
.
get_error_name
()
}
]
{
self
.
errmsg
}
'
class
NotFoundException
(
ValidationException
):
def
__init__
(
self
,
error
):
super
().
__init__
(
error
,
errno
.
ENOENT
)
class
TrainNotFoundException
(
NotFoundException
):
def
__init__
(
self
):
super
(
TrainNotFoundException
,
self
).
__init__
(
'Failed to find train'
)
class
CatalogItemNotFoundException
(
NotFoundException
):
def
__init__
(
self
,
path
):
super
(
CatalogItemNotFoundException
,
self
).
__init__
(
f'Failed to find
{
path
!
r
}
catalog item'
)
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
()
for
item
in
os
.
listdir
(
train_path
):
process_catalog_item
(
os
.
path
.
join
(
train_path
,
item
))
def
process_catalog_item
(
item_path
):
if
not
os
.
path
.
exists
(
item_path
):
raise
CatalogItemNotFoundException
(
item_path
)
for
item_version
in
os
.
listdir
(
item_path
):
update_item_version
(
os
.
path
.
join
(
item_path
,
item_version
))
def
update_item_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
def
main
():
parser
=
argparse
.
ArgumentParser
()
subparsers
=
parser
.
add_subparsers
(
help
=
'sub-command help'
,
dest
=
'action'
)
parser_setup
=
subparsers
.
add_parser
(
'update'
,
help
=
'Update dependencies for specified train'
)
parser_setup
.
add_argument
(
'--train'
,
help
=
'Specify train path to update dependencies'
,
required
=
True
)
args
=
parser
.
parse_args
()
if
args
.
action
==
'update'
:
update_train_charts
(
args
.
train
)
else
:
parser
.
print_help
()
if
__name__
==
'__main__'
:
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