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
ba823dcc
Commit
ba823dcc
authored
Nov 28, 2022
by
harshavardhan.c
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dev: code optimization fixes
parent
29ed9a0f
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
120 additions
and
85 deletions
+120
-85
docker_automation/docker_automate_script.py
docker_automation/docker_automate_script.py
+33
-29
docker_automation/docker_register.py
docker_automation/docker_register.py
+9
-1
scripts/core/docker_handler.py
scripts/core/docker_handler.py
+69
-46
scripts/core/helm_handler.py
scripts/core/helm_handler.py
+8
-8
scripts/utils/common_utils.py
scripts/utils/common_utils.py
+1
-1
No files found.
docker_automation/docker_automate_script.py
View file @
ba823dcc
...
...
@@ -31,34 +31,38 @@ class DockerVersionUpgrade:
general_temp_path
=
f
"{int(time.time())}_tmp"
output_path
=
f
"{int(time.time())}_docker-compose"
try
:
_release_version
=
self
.
arguments
[
"release_version"
]
_client_name
=
self
.
arguments
[
'client_name'
]
_git_repos
=
self
.
arguments
[
"git_repos"
]
_module_names
=
self
.
arguments
[
"module_names"
]
_branch_name
=
self
.
arguments
[
'branch_name'
]
or
"master"
_ilens_version
=
self
.
arguments
[
"ilens_version"
]
if
not
_ilens_version
or
not
_release_version
or
not
_client_name
or
not
global_configmap
:
print
(
"global_configmap, client_name, ilens_version and release_version details "
"not found!!!!!"
)
sys
.
exit
()
variables_file
=
"variables.yml"
if
not
os
.
path
.
exists
(
docker_temp_path
):
os
.
makedirs
(
docker_temp_path
)
if
not
os
.
path
.
exists
(
output_path
):
os
.
makedirs
(
output_path
)
docker_compose_path
=
os
.
path
.
join
(
docker_temp_path
,
"docker-compose"
)
_branch
=
f
"{_client_name}_{_ilens_version}.{_release_version}"
if
not
self
.
git_handler_obj
.
clone_repository
(
repo_link
=
docker_repo
,
module_output_path
=
docker_compose_path
,
clone_branch
=
_client_name
):
logging
.
error
(
f
"Cannot clone docker repo with branch: {_client_name}"
)
sys
.
exit
()
self
.
docker_handler
.
process_compose_data_for_existing_files
(
destination_branch
=
_client_name
,
source_branch
=
_branch
,
variables_file
=
variables_file
,
arguments
=
self
.
arguments
,
tmp_path
=
general_temp_path
,
output_path
=
output_path
,
docker_compose_path
=
docker_compose_path
)
self
.
process_docker_automation
(
docker_temp_path
,
output_path
,
general_temp_path
)
except
Exception
as
e
:
logging
.
error
(
f
'Exception occurred while preparing the docker compose {e.args}'
)
def
process_docker_automation
(
self
,
docker_temp_path
,
output_path
,
general_temp_path
):
_release_version
=
self
.
arguments
[
"release_version"
]
_client_name
=
self
.
arguments
[
'client_name'
]
_git_repos
=
self
.
arguments
[
"git_repos"
]
_module_names
=
self
.
arguments
[
"module_names"
]
_branch_name
=
self
.
arguments
[
'branch_name'
]
or
"master"
_ilens_version
=
self
.
arguments
[
"ilens_version"
]
if
not
_ilens_version
or
not
_release_version
or
not
_client_name
or
not
global_configmap
:
print
(
"global_configmap, client_name, ilens_version and release_version details "
"not found!!!!!"
)
sys
.
exit
()
variables_file
=
"variables.yml"
if
not
os
.
path
.
exists
(
docker_temp_path
):
os
.
makedirs
(
docker_temp_path
)
if
not
os
.
path
.
exists
(
output_path
):
os
.
makedirs
(
output_path
)
docker_compose_path
=
os
.
path
.
join
(
docker_temp_path
,
"docker-compose"
)
_branch
=
f
"{_client_name}_{_ilens_version}.{_release_version}"
if
not
self
.
git_handler_obj
.
clone_repository
(
repo_link
=
docker_repo
,
module_output_path
=
docker_compose_path
,
clone_branch
=
_client_name
):
logging
.
error
(
f
"Cannot clone docker repo with branch: {_client_name}"
)
sys
.
exit
()
self
.
docker_handler
.
process_compose_data_for_existing_files
(
destination_branch
=
_client_name
,
source_branch
=
_branch
,
variables_file
=
variables_file
,
arguments
=
self
.
arguments
,
tmp_path
=
general_temp_path
,
output_path
=
output_path
,
docker_compose_path
=
docker_compose_path
)
docker_automation/docker_register.py
View file @
ba823dcc
import
json
from
scripts.config
import
EnvironmentVariables
if
__name__
==
"__main__"
:
from
dotenv
import
load_dotenv
...
...
@@ -69,6 +71,12 @@ class DockerRegistration:
arguments
=
self
.
arguments
,
compose_info
=
repo_info
,
tmp_path
=
general_temp_path
,
output_path
=
output_path
,
modules
=
_module_names
)
# self.git_handler_obj.push_deployments_to_git(repo_link=docker_repo,
# private_token=EnvironmentVariables.git_access_token,
# branch=_branch,
# folder_path=output_path, helm_deployment=False,
# base_path=docker_compose_path)
# self.git_handler_obj.create_merge_request(repo_link=docker_repo, source_branch=_branch,
# destination_branch=_client_name)
except
Exception
as
e
:
logging
.
exception
(
f
"Exception Occurred while generating the docker compose file {e.args}"
)
scripts/core/docker_handler.py
View file @
ba823dcc
This diff is collapsed.
Click to expand it.
scripts/core/helm_handler.py
View file @
ba823dcc
...
...
@@ -33,9 +33,9 @@ class HelmHandler:
existing_data
[
'deployment'
][
'imageName'
]
=
image_tag
or
existing_data
[
'deployment'
][
'imageName'
]
self
.
common_utils
.
convert_json_to_yaml
(
json_data
=
existing_data
,
output_file_path
=
template_file
)
self
.
common_utils
.
render_
helm
_chart
(
data_dict
=
global_config_vars
,
jinja_template_file
=
f
'{module_name}.yml'
,
outfile_path
=
helm_out_file_path
,
template_path
=
template_path
,
service_type
=
service_type
)
self
.
common_utils
.
render_
deployment
_chart
(
data_dict
=
global_config_vars
,
jinja_template_file
=
f
'{module_name}.yml'
,
outfile_path
=
helm_out_file_path
,
template_path
=
template_path
,
service_type
=
service_type
)
return
True
except
Exception
as
e
:
logging
.
exception
(
f
'Exception occurred while preparing the helm deployment file {e.args}'
)
...
...
@@ -61,11 +61,11 @@ class HelmHandler:
value_key
=
v
.
strip
(
"<{ }>"
)
global_config_vars
.
update
({
k
:
global_config_vars
.
get
(
value_key
,
v
)})
self
.
common_utils
.
render_
helm
_chart
(
data_dict
=
{},
jinja_template_file
=
f
'{module_name}.yml'
,
outfile_path
=
helm_out_file_path
,
template_path
=
"templates"
,
service_type
=
service_type
,
image_url
=
image_tag
,
variables
=
global_config_vars
,
module_port
=
module_port
,
node_port
=
node_port
)
self
.
common_utils
.
render_
deployment
_chart
(
data_dict
=
{},
jinja_template_file
=
f
'{module_name}.yml'
,
outfile_path
=
helm_out_file_path
,
template_path
=
"templates"
,
service_type
=
service_type
,
image_url
=
image_tag
,
variables
=
global_config_vars
,
module_port
=
module_port
,
node_port
=
node_port
)
return
True
except
Exception
as
e
:
logging
.
exception
(
f
'Exception occurred while preparing the helm deployment file {e.args}'
)
...
...
scripts/utils/common_utils.py
View file @
ba823dcc
...
...
@@ -35,7 +35,7 @@ class CommonUtils:
return
False
@
staticmethod
def
render_
helm
_chart
(
data_dict
,
jinja_template_file
,
template_path
,
outfile_path
,
**
kwargs
):
def
render_
deployment
_chart
(
data_dict
,
jinja_template_file
,
template_path
,
outfile_path
,
**
kwargs
):
try
:
environment
=
jinja2
.
Environment
(
loader
=
jinja2
.
FileSystemLoader
(
searchpath
=
template_path
),
...
...
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