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
afc35f18
Commit
afc35f18
authored
Oct 19, 2022
by
harshavardhan.c
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: code fixes while registering new helm_template.
parent
6373f195
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
11 deletions
+17
-11
helm_register.py
helm_register.py
+12
-8
scripts/core/helm_handler.py
scripts/core/helm_handler.py
+5
-3
No files found.
helm_register.py
View file @
afc35f18
from
copy
import
deepcopy
from
copy
import
deepcopy
from
scripts.db.psql.databases
import
get_db_for_func
import
shortuuid
from
scripts.schemas
import
GetRequest
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
from
dotenv
import
load_dotenv
from
dotenv
import
load_dotenv
load_dotenv
()
load_dotenv
()
from
scripts.db.psql.databases
import
get_db_for_func
from
scripts.schemas
import
GetRequest
import
argparse
import
argparse
import
logging
import
logging
import
os
import
os
...
@@ -132,6 +134,7 @@ if __name__ == '__main__':
...
@@ -132,6 +134,7 @@ if __name__ == '__main__':
# global_config_data = common_util.convert_yaml_to_json("ilens-global-configmap.yml")
# global_config_data = common_util.convert_yaml_to_json("ilens-global-configmap.yml")
if
repo_info
:
if
repo_info
:
global_config_data
.
update
(
repo_info
)
global_config_data
.
update
(
repo_info
)
shortuuid
.
uuid
()
variables_file
=
"variables.yml"
variables_file
=
"variables.yml"
template_path
=
os
.
path
.
join
(
GENERAL_TEMP_PATH
,
"templates"
)
template_path
=
os
.
path
.
join
(
GENERAL_TEMP_PATH
,
"templates"
)
if
not
os
.
path
.
exists
(
template_path
):
if
not
os
.
path
.
exists
(
template_path
):
...
@@ -177,12 +180,13 @@ if __name__ == '__main__':
...
@@ -177,12 +180,13 @@ if __name__ == '__main__':
module_env_variables
=
module_env_variables
,
module_env_variables
=
module_env_variables
,
helm_out_file_path
=
helm_out_file_path
,
helm_out_file_path
=
helm_out_file_path
,
global_config_data
=
global_config_data
,
module_name
=
new_module
)
global_config_data
=
global_config_data
,
module_name
=
new_module
)
else
:
helm_handler
.
create_existing_helm_deployment_file
(
template_yml_path
=
existing_yml_path
,
image_tag
=
image_url
,
helm_handler
.
create_existing_helm_deployment_file
(
template_yml_path
=
existing_yml_path
,
image_tag
=
image_url
,
module_env_variables
=
module_env_variables
,
module_env_variables
=
module_env_variables
,
helm_out_file_path
=
helm_out_file_path
,
helm_out_file_path
=
helm_out_file_path
,
global_config_data
=
global_config_data
,
global_config_data
=
global_config_data
,
module_name
=
new_module
,
template_file
=
template_file
,
module_name
=
new_module
,
template_file
=
template_file
,
template_path
=
template_path
)
template_path
=
template_path
)
if
os
.
path
.
exists
(
base_helm_directory_path
):
if
os
.
path
.
exists
(
base_helm_directory_path
):
files_info
=
os
.
listdir
(
base_helm_directory_path
)
files_info
=
os
.
listdir
(
base_helm_directory_path
)
sorted_files
=
list
(
filter
(
lambda
f
:
f
.
startswith
(
_module
),
files_info
))
sorted_files
=
list
(
filter
(
lambda
f
:
f
.
startswith
(
_module
),
files_info
))
...
...
scripts/core/helm_handler.py
View file @
afc35f18
...
@@ -25,10 +25,12 @@ class HelmHandler:
...
@@ -25,10 +25,12 @@ class HelmHandler:
existing_env_variables
=
{
_v
[
'name'
]:
_v
for
_v
in
existing_env_variables
=
{
_v
[
'name'
]:
_v
for
_v
in
existing_data
.
get
(
'deployment'
,
{})
.
get
(
'environmentVar'
,
[])}
existing_data
.
get
(
'deployment'
,
{})
.
get
(
'environmentVar'
,
[])}
diff_keys
=
list
(
set
(
existing_env_variables
.
keys
())
.
symmetric_difference
(
set
(
module_env_variables
.
keys
())))
diff_keys
=
list
(
set
(
existing_env_variables
.
keys
())
.
symmetric_difference
(
set
(
module_env_variables
.
keys
())))
module_port
=
''
for
_each
in
diff_keys
:
for
_each
in
diff_keys
:
if
_each
.
lower
()
in
{
'port'
,
'service_port'
,
'module_port'
}
and
module_env_variables
.
get
(
_each
)
and
\
if
_each
.
lower
()
in
{
'port'
,
'service_port'
,
'module_port'
,
'node_port'
}
and
module_env_variables
.
get
(
_each
)
and
\
module_env_variables
[
_each
]
.
get
(
"value"
):
module_env_variables
[
_each
]
.
get
(
"value"
):
global_config_vars
[
"SERVICE_PORT"
]
=
module_env_variables
[
_each
][
"value"
]
module_port
=
module_env_variables
[
_each
][
"value"
]
continue
continue
if
module_env_variables
.
get
(
_each
):
if
module_env_variables
.
get
(
_each
):
existing_data
[
'deployment'
][
'environmentVar'
]
.
append
(
module_env_variables
[
_each
])
existing_data
[
'deployment'
][
'environmentVar'
]
.
append
(
module_env_variables
[
_each
])
...
@@ -37,7 +39,7 @@ class HelmHandler:
...
@@ -37,7 +39,7 @@ class HelmHandler:
self
.
common_utils
.
convert_json_to_yaml
(
json_data
=
existing_data
,
output_file_path
=
template_file
)
self
.
common_utils
.
convert_json_to_yaml
(
json_data
=
existing_data
,
output_file_path
=
template_file
)
self
.
render_helm_chart
(
data_dict
=
global_config_vars
,
helm_template_file
=
f
'{module_name}.yml'
,
self
.
render_helm_chart
(
data_dict
=
global_config_vars
,
helm_template_file
=
f
'{module_name}.yml'
,
outfile_path
=
helm_out_file_path
,
template_path
=
template_path
,
outfile_path
=
helm_out_file_path
,
template_path
=
template_path
,
service_type
=
service_type
)
service_type
=
service_type
,
module_port
=
module_port
)
return
True
return
True
except
Exception
as
e
:
except
Exception
as
e
:
logging
.
exception
(
f
'Exception occurred while preparing the helm deployment file {e.args}'
)
logging
.
exception
(
f
'Exception occurred while preparing the helm deployment file {e.args}'
)
...
...
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