Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
Helm-Automation-Script
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
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
harshavardhan.c
Helm-Automation-Script
Commits
8a30c4d9
Commit
8a30c4d9
authored
Sep 30, 2022
by
sangeetha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated script generation logic.
parent
144753c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
29 deletions
+25
-29
helm_automate_script.py
helm_automate_script.py
+25
-29
No files found.
helm_automate_script.py
View file @
8a30c4d9
...
@@ -36,7 +36,7 @@ def render_helm_chart(helm_name, data_dict, variables_list, helm_template_file):
...
@@ -36,7 +36,7 @@ def render_helm_chart(helm_name, data_dict, variables_list, helm_template_file):
output_path
=
"helm-charts"
output_path
=
"helm-charts"
if
not
os
.
path
.
exists
(
output_path
):
if
not
os
.
path
.
exists
(
output_path
):
os
.
makedirs
(
output_path
)
os
.
makedirs
(
output_path
)
helm_path
=
os
.
path
.
join
(
output_path
,
f
'{helm_name}.y
a
ml'
)
helm_path
=
os
.
path
.
join
(
output_path
,
f
'{helm_name}.yml'
)
environment
=
jinja2
.
Environment
(
environment
=
jinja2
.
Environment
(
loader
=
jinja2
.
FileSystemLoader
(
searchpath
=
'./templates'
),
loader
=
jinja2
.
FileSystemLoader
(
searchpath
=
'./templates'
),
...
@@ -61,6 +61,17 @@ def clone_repository(repo_link, module_output_path, clone_branch):
...
@@ -61,6 +61,17 @@ def clone_repository(repo_link, module_output_path, clone_branch):
except
Exception
as
e
:
except
Exception
as
e
:
logging
.
exception
(
f
"Exception occurred while cloning the git repo - {repo_link} - {e.args}"
)
logging
.
exception
(
f
"Exception occurred while cloning the git repo - {repo_link} - {e.args}"
)
return
False
return
False
def
get_module_names_from_files
():
try
:
module_names
=
set
()
dir_list
=
os
.
listdir
(
f
'{REPO_CLONE_PATH}{HELM_PATH}'
)
for
file
in
dir_list
:
if
file
.
endswith
(
".yml"
):
module_names
.
add
(
file
.
removesuffix
(
".yml"
))
return
list
(
module_names
)
except
Exception
as
e
:
logging
.
exception
(
f
"Exception occurred while fetching module names from files: {e.args}"
)
def
clone_repository_with_defined_file
(
repo_link
:
str
,
file_output_path
,
clone_branch
,
private_token
,
clone_file_path
):
def
clone_repository_with_defined_file
(
repo_link
:
str
,
file_output_path
,
clone_branch
,
private_token
,
clone_file_path
):
...
@@ -148,30 +159,13 @@ if __name__ == '__main__':
...
@@ -148,30 +159,13 @@ if __name__ == '__main__':
default
=
None
,
default
=
None
,
help
=
"Client Name Tag"
help
=
"Client Name Tag"
)
)
ap
.
add_argument
(
"--module_details"
,
"-md"
,
required
=
False
,
default
=
None
,
type
=
json
.
loads
,
help
=
"Module details to be added in helm"
,
)
ap
.
add_argument
(
"--exclude_files"
,
"-ef"
,
required
=
False
,
default
=
[],
help
=
"Files to be excluded from deleting from repo"
,
nargs
=
"+"
)
arguments
=
vars
(
ap
.
parse_args
())
arguments
=
vars
(
ap
.
parse_args
())
_ilens_version
=
arguments
[
"ilens_version"
]
_ilens_version
=
arguments
[
"ilens_version"
]
_release_version
=
arguments
[
"release_version"
]
_release_version
=
arguments
[
"release_version"
]
_client_name
=
arguments
[
'client_name'
]
_client_name
=
arguments
[
'client_name'
]
_module_details
=
arguments
[
'module_details'
]
if
not
_ilens_version
or
not
_release_version
or
not
_client_name
or
not
global_configmap
:
_exclude_files
=
arguments
[
"exclude_files"
]
print
(
"global_configmap, client_name, ilens_version and release_version details not found!!!!!"
)
if
not
_ilens_version
or
not
_release_version
or
not
_client_name
or
not
_module_details
or
not
global_configmap
:
print
(
"global_configmap, module_details, client_name, ilens_version and release_version details not found!!!!!"
)
sys
.
exit
()
sys
.
exit
()
_branch
=
f
"{_client_name}_{_ilens_version}.{_release_version}"
_branch
=
f
"{_client_name}_{_ilens_version}.{_release_version}"
try
:
try
:
...
@@ -180,11 +174,9 @@ if __name__ == '__main__':
...
@@ -180,11 +174,9 @@ if __name__ == '__main__':
sys
.
exit
()
sys
.
exit
()
with
open
(
"config.json"
,
"r"
)
as
f
:
with
open
(
"config.json"
,
"r"
)
as
f
:
data
=
json
.
load
(
f
)
data
=
json
.
load
(
f
)
_git_repos
=
[
x
[
'git_link'
]
for
x
in
_module_details
if
x
.
get
(
'git_link'
)]
_module_names
=
list
(
set
(
get_module_names_from_files
())
.
difference
(
list
(
global_configmap
.
removesuffix
(
".yml"
))))
_module_names
=
[
x
[
'module_name'
]
for
x
in
_module_details
if
x
.
get
(
'module_name'
)]
data
[
'git_modules'
]
=
[
x
for
x
in
data
[
'git_modules'
]
if
(
x
[
'module_name'
]
in
_module_names
)]
data
[
'git_modules'
]
=
[
x
for
x
in
data
[
'git_modules'
]
if
(
x
[
'module_name'
]
in
_module_names
)
or
(
x
[
'git_link'
]
in
_git_repos
)]
global_config_data
=
convert_yaml_to_json
(
global_configmap
)
global_config_data
=
convert_yaml_to_json
(
global_configmap
)
remove_all_files_from_repo
(
exclude_file
=
_exclude_files
)
for
_data
in
data
.
get
(
'git_modules'
):
for
_data
in
data
.
get
(
'git_modules'
):
_ilens_version
=
_data
.
get
(
"ilens_version"
,
_ilens_version
)
_ilens_version
=
_data
.
get
(
"ilens_version"
,
_ilens_version
)
_release_version
=
_data
.
get
(
"ilens_version"
,
_release_version
)
_release_version
=
_data
.
get
(
"ilens_version"
,
_release_version
)
...
@@ -223,7 +215,11 @@ if __name__ == '__main__':
...
@@ -223,7 +215,11 @@ if __name__ == '__main__':
except
Exception
as
e
:
except
Exception
as
e
:
logging
.
exception
(
f
'Unable to update helms: {e.args}'
)
logging
.
exception
(
f
'Unable to update helms: {e.args}'
)
finally
:
finally
:
shutil
.
rmtree
(
REPO_CLONE_PATH
)
if
os
.
path
.
exists
(
REPO_CLONE_PATH
):
shutil
.
rmtree
(
"./tmp"
)
shutil
.
rmtree
(
REPO_CLONE_PATH
)
shutil
.
rmtree
(
HELM_STORE_PATH
)
if
os
.
path
.
exists
(
"./tmp"
):
os
.
remove
(
f
"./{global_configmap}"
)
shutil
.
rmtree
(
"./tmp"
)
\ No newline at end of file
if
os
.
path
.
exists
(
HELM_STORE_PATH
):
shutil
.
rmtree
(
HELM_STORE_PATH
)
if
os
.
path
.
isfile
(
f
"./{global_configmap}"
):
os
.
remove
(
f
"./{global_configmap}"
)
\ No newline at end of file
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