Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/mas/devops/mas.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@
logger = logging.getLogger(__name__)


def isAirgapInstall(dynClient: DynamicClient) -> bool:
try:
ICSPApi = dynClient.resources.get(api_version="operator.openshift.io/v1alpha1", kind="ImageContentSourcePolicy")
ICSPApi.get(name="ibm-mas-and-dependencies")
return True
except NotFoundError:
return False
def isAirgapInstall(dynClient: DynamicClient, checkICSP: bool = False) -> bool:
if checkICSP:
try:
ICSPApi = dynClient.resources.get(api_version="operator.openshift.io/v1alpha1", kind="ImageContentSourcePolicy")
ICSPApi.get(name="ibm-mas-and-dependencies")
return True
except NotFoundError:
return False
else:
IDMSApi = dynClient.resources.get(api_version="config.openshift.io/v1", kind="ImageDigestMirrorSet")
masIDMS = IDMSApi.get(label_selector="mas.ibm.com/idmsContent=ibm")
return len(masIDMS.items) > 0


def getDefaultStorageClasses(dynClient: DynamicClient) -> dict:
Expand Down
6 changes: 6 additions & 0 deletions test/src/test_mas.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,9 @@ def test_entitlement_alt_name():
def test_get_channel():
channel = mas.getMasChannel(dynClient, "doesnotexist")
assert channel is None


def test_is_airgap_install():
# The cluster we are using to test with does not have the MAS ICSP or IDMS installed
assert mas.isAirgapInstall(dynClient) is False
assert mas.isAirgapInstall(dynClient, checkICSP=False) is False
Loading