-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
254 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
41 changes: 41 additions & 0 deletions
41
cloud_governance/common/clouds/ibm/containers/conatiner_registry_operations.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from ibm_container_registry.container_registry_v1 import ContainerRegistryV1 | ||
|
||
from cloud_governance.common.clouds.ibm.account.ibm_authenticator import IBMAuthenticator | ||
from cloud_governance.common.clouds.ibm.vpc.vpc_infra_operations import VpcInfraOperations | ||
|
||
|
||
class ContainerRegistryOperations(IBMAuthenticator): | ||
|
||
def __init__(self, vpc_infra_operations: VpcInfraOperations = None): | ||
super().__init__() | ||
self.__vpc_infra_operations = vpc_infra_operations | ||
self.__client = ContainerRegistryV1(authenticator=self.iam_authenticator, | ||
account=self.account_id) | ||
|
||
def get_all_namespaces(self): | ||
""" | ||
This method returns a list of all namespaces. | ||
:return: | ||
""" | ||
response_list = {} | ||
regions_list = self.__vpc_infra_operations.get_regions() | ||
for region in regions_list: | ||
region_name = region['name'] | ||
if region['status'] == 'available' and region_name in self.__client.REGIONAL_ENDPOINTS: | ||
self.__client.set_service_url(self.__client.REGIONAL_ENDPOINTS[region_name]) | ||
result = self.__client.list_namespaces().get_result() | ||
if result: | ||
response_list[region_name] = result | ||
return response_list | ||
|
||
def get_all_registries(self): | ||
""" | ||
This method returns all container registries | ||
:return: | ||
""" | ||
region_namespaces = self.get_all_namespaces() | ||
response_list = {} | ||
for _, namespaces in region_namespaces.items(): | ||
for namespace in namespaces: | ||
response_list[namespace] = self.__client.list_images(namespace=namespace).get_result() | ||
return response_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.