Skip to content

Commit 1276341

Browse files
terc1997sanjayprab
andauthored
[minor] enable facilities application (#76)
Co-authored-by: Sanjay Prabhakar <[email protected]>
1 parent dd23cca commit 1276341

File tree

4 files changed

+116
-0
lines changed

4 files changed

+116
-0
lines changed

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def get_version(rel_path):
6161
'kubeconfig', # BSD License
6262
'jinja2', # BSD License
6363
'jinja2-base64-filters', # MIT License
64+
'semver', # BSD License
6465
'boto3' # Apache Software License
6566
],
6667
extras_require={

src/mas/devops/mas.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from openshift.dynamic import DynamicClient
1919
from openshift.dynamic.exceptions import NotFoundError, ResourceNotFoundError, UnauthorizedError
2020
from jinja2 import Environment, FileSystemLoader
21+
import semver
2122

2223
from .ocp import getStorageClasses
2324
from .olm import getSubscription
@@ -305,3 +306,41 @@ def patchPendingPVC(dynClient: DynamicClient, namespace: str, pvcName: str, stor
305306
except NotFoundError:
306307
logger.error(f"PVC {pvcName} does not exist")
307308
return False
309+
310+
311+
def isVersionBefore(_compare_to_version, _current_version):
312+
"""
313+
The method does a modified semantic version comparison,
314+
as we want to treat any pre-release as == to the real release
315+
but in strict semantic versioning it is <
316+
ie. '8.6.0-pre.m1dev86' is converted to '8.6.0'
317+
"""
318+
if _current_version is None:
319+
print("Version is not informed. Returning False")
320+
return False
321+
322+
strippedVersion = _current_version.split("-")[0]
323+
if '.x' in strippedVersion:
324+
strippedVersion = strippedVersion.replace('.x', '.0')
325+
current_version = semver.VersionInfo.parse(strippedVersion)
326+
compareToVersion = semver.VersionInfo.parse(_compare_to_version)
327+
return current_version.compare(compareToVersion) < 0
328+
329+
330+
def isVersionEqualOrAfter(_compare_to_version, _current_version):
331+
"""
332+
The method does a modified semantic version comparison,
333+
as we want to treat any pre-release as == to the real release
334+
but in strict semantic versioning it is <
335+
ie. '8.6.0-pre.m1dev86' is converted to '8.6.0'
336+
"""
337+
if _current_version is None:
338+
print("Version is not informed. Returning False")
339+
return False
340+
341+
strippedVersion = _current_version.split("-")[0]
342+
if '.x' in strippedVersion:
343+
strippedVersion = strippedVersion.replace('.x', '.0')
344+
current_version = semver.VersionInfo.parse(strippedVersion)
345+
compareToVersion = semver.VersionInfo.parse(_compare_to_version)
346+
return current_version.compare(compareToVersion) >= 0

src/mas/devops/templates/pipelinerun-install.yml.j2

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,68 @@ spec:
816816
value: "{{ mas_aibroker_db_secret_value }}"
817817
{%- endif %}
818818

819+
# TODO: Fix type for storage sizes and max conn pool size
820+
{%- if mas_app_channel_facilities is defined and mas_app_channel_facilities != "" %}
821+
822+
# Real Estate anda Facilities Application
823+
# -------------------------------------------------------------------------
824+
- name: mas_app_channel_facilities
825+
value: "{{ mas_app_channel_facilities }}"
826+
827+
{%- if mas_ws_facilities_size is defined and mas_ws_facilities_size != "" %}
828+
- name: mas_ws_facilities_size
829+
value: "{{ mas_ws_facilities_size }}"
830+
{%- endif %}
831+
{%- if mas_ws_facilities_routes_timeout is defined and mas_ws_facilities_routes_timeout != "" %}
832+
- name: mas_ws_facilities_routes_timeout
833+
value: "{{ mas_ws_facilities_routes_timeout }}"
834+
{%- endif %}
835+
{%- if mas_ws_facilities_liberty_extension_XML is defined and mas_ws_facilities_liberty_extension_XML != "" %}
836+
- name: mas_ws_facilities_liberty_extension_XML
837+
value: "{{ mas_ws_facilities_liberty_extension_XML }}"
838+
{%- endif %}
839+
{%- if mas_ws_facilities_vault_secret is defined and mas_ws_facilities_vault_secret != "" %}
840+
- name: mas_ws_facilities_vault_secret
841+
value: "{{ mas_ws_facilities_vault_secret }}"
842+
{%- endif %}
843+
{%- if mas_ws_facilities_pull_policy is defined and mas_ws_facilities_pull_policy != "" %}
844+
- name: mas_ws_facilities_pull_policy
845+
value: "{{ mas_ws_facilities_pull_policy }}"
846+
{%- endif %}
847+
- name: mas_ws_facilities_storage_log_class
848+
value: "{{ mas_ws_facilities_storage_log_class }}"
849+
{%- if mas_ws_facilities_storage_log_mode is defined and mas_ws_facilities_storage_log_mode != "" %}
850+
- name: mas_ws_facilities_storage_log_mode
851+
value: "{{ mas_ws_facilities_storage_log_mode }}"
852+
{%- endif %}
853+
# {%- if mas_ws_facilities_storage_log_size is defined and mas_ws_facilities_storage_log_size != "" %}
854+
# - name: mas_ws_facilities_storage_log_size
855+
# value: "{{ mas_ws_facilities_storage_log_size }}"
856+
# {%- endif %}
857+
- name: mas_ws_facilities_storage_userfiles_class
858+
value: "{{ mas_ws_facilities_storage_userfiles_class }}"
859+
{%- if mas_ws_facilities_storage_userfiles_mode is defined and mas_ws_facilities_storage_userfiles_mode != "" %}
860+
- name: mas_ws_facilities_storage_userfiles_mode
861+
value: "{{ mas_ws_facilities_storage_userfiles_mode }}"
862+
{%- endif %}
863+
# {%- if mas_ws_facilities_storage_userfiles_size is defined and mas_ws_facilities_storage_userfiles_size != "" %}
864+
# - name: mas_ws_facilities_storage_userfiles_size
865+
# value: "{{ mas_ws_facilities_storage_userfiles_size }}"
866+
# {%- endif %}
867+
{%- if mas_ws_facilities_dwfagents is defined and mas_ws_facilities_dwfagents != "" %}
868+
- name: mas_ws_facilities_dwfagents
869+
value: "{{ mas_ws_facilities_dwfagents }}"
870+
{%- endif %}
871+
# {%- if mas_ws_facilities_db_maxconnpoolsize is defined and mas_ws_facilities_db_maxconnpoolsize != "" %}
872+
# - name: mas_ws_facilities_db_maxconnpoolsize
873+
# value: "{{ mas_ws_facilities_db_maxconnpoolsize }}"
874+
# {%- endif %}
875+
876+
- name: db2_action_facilities
877+
value: "{{ db2_action_facilities}}"
878+
879+
{%- endif %}
880+
819881
workspaces:
820882
# The generated configuration files
821883
# -------------------------------------------------------------------------

test/src/test_mas.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,17 @@ def test_is_airgap_install():
6262
# The cluster we are using to test with does not have the MAS ICSP or IDMS installed
6363
assert mas.isAirgapInstall(dynClient) is False
6464
assert mas.isAirgapInstall(dynClient, checkICSP=False) is False
65+
66+
67+
def test_version_before():
68+
assert mas.isVersionBefore('9.1.0', '9.1.x-feature') is False
69+
assert mas.isVersionBefore('9.1.0', '9.0.0') is True
70+
assert mas.isVersionBefore('8.11.1', '9.1.0') is False
71+
assert mas.isVersionBefore('9.1.0', '9.1.x-stable') is False
72+
73+
74+
def test_version_equal_of_after():
75+
assert mas.isVersionEqualOrAfter('9.1.0', '9.2.x-feature') is True
76+
assert mas.isVersionEqualOrAfter('9.1.0', '9.0.0') is False
77+
assert mas.isVersionEqualOrAfter('8.11.1', '9.1.0') is True
78+
assert mas.isVersionEqualOrAfter('9.2.0', '9.1.x-stable') is False

0 commit comments

Comments
 (0)