Skip to content

Commit

Permalink
feat: modify register datasource
Browse files Browse the repository at this point in the history
  • Loading branch information
ImMin5 committed Dec 20, 2023
1 parent 1e35f94 commit bf68905
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
19 changes: 12 additions & 7 deletions src/spaceone/cost_analysis/manager/repository_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,25 @@


class RepositoryManager(BaseManager):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.repo_connector: SpaceConnector = self.locator.get_connector('SpaceConnector', service='repository')
self.repo_connector: SpaceConnector = self.locator.get_connector(
"SpaceConnector", service="repository"
)

def get_plugin(self, plugin_id, domain_id):
return self.repo_connector.dispatch('Plugin.get', {'plugin_id': plugin_id, 'domain_id': domain_id})
def get_plugin(self, plugin_id: str):
return self.repo_connector.dispatch("Plugin.get", {"plugin_id": plugin_id})

def check_plugin_version(self, plugin_id, version, domain_id):
response = self.repo_connector.dispatch('Plugin.get_versions', {'plugin_id': plugin_id, 'domain_id': domain_id})
versions = response.get('results', [])
response = self.repo_connector.dispatch(
"Plugin.get_versions", {"plugin_id": plugin_id, "domain_id": domain_id}
)
versions = response.get("results", [])

if version not in versions:
raise ERROR_INVALID_PLUGIN_VERSION(plugin_id=plugin_id, version=version)

def list_schemas(self, query, domain_id):
return self.repo_connector.dispatch('Schema.list', {'query': query, 'domain_id': domain_id})
return self.repo_connector.dispatch(
"Schema.list", {"query": query, "domain_id": domain_id}
)
6 changes: 3 additions & 3 deletions src/spaceone/cost_analysis/service/data_source_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def register(self, params):
raise ERROR_REQUIRED_PARAMETER(key="provider")

self._validate_plugin_info(plugin_info, secret_type)
self._check_plugin(plugin_info["plugin_id"], domain_id)
self._check_plugin(plugin_info["plugin_id"])

if "secret_filter" in params:
self.validate_secret_filter(
Expand Down Expand Up @@ -543,9 +543,9 @@ def validate_secret_filter(self, secret_filter, domain_id):
key="secret_filter.schema", reason="Schema not found"
)

def _check_plugin(self, plugin_id, domain_id):
def _check_plugin(self, plugin_id):
repo_mgr: RepositoryManager = self.locator.get_manager("RepositoryManager")
repo_mgr.get_plugin(plugin_id, domain_id)
repo_mgr.get_plugin(plugin_id)

def _init_plugin(self, endpoint, options, domain_id):
self.ds_plugin_mgr.initialize(endpoint)
Expand Down

0 comments on commit bf68905

Please sign in to comment.