Skip to content

Commit

Permalink
Merge pull request #396 from stat-kwon/master
Browse files Browse the repository at this point in the history
Add metadata parameter when using plugin method
  • Loading branch information
stat-kwon authored Oct 17, 2024
2 parents 61846e2 + 4b14e2e commit 5fb268e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/spaceone/inventory/plugin/collector/lib/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ def convert_cloud_service_meta(
}


def convert_cloud_service_type_meta(metadata_path: str) -> dict:
yaml_path = _get_yaml_path(metadata_path)
old_metadata = load_yaml_from_file(yaml_path)
def convert_cloud_service_type_meta(metadata_path: str, metadata: dict = None) -> dict:
if not metadata:
yaml_path = _get_yaml_path(metadata_path)
old_metadata = load_yaml_from_file(yaml_path)
else:
old_metadata = metadata
return MetadataGenerator(old_metadata).generate_metadata()


Expand Down
10 changes: 8 additions & 2 deletions src/spaceone/inventory/plugin/collector/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ def make_cloud_service_type(
name,
group,
provider,
metadata_path,
metadata_path=None,
metadata=None,
is_primary=False,
is_major=False,
service_code=None,
tags=None,
labels=None,
) -> dict:
if not metadata and metadata_path is None:
raise ERROR_REQUIRED_PARAMETER(key="metadata or metadata_path")

if tags is None:
tags = {}
if labels is None:
Expand All @@ -38,7 +42,9 @@ def make_cloud_service_type(
name=name,
group=group,
provider=provider,
json_metadata=utils.dump_json(convert_cloud_service_type_meta(metadata_path)),
json_metadata=utils.dump_json(
convert_cloud_service_type_meta(metadata_path, metadata)
),
is_primary=is_primary,
is_major=is_major,
service_code=service_code,
Expand Down

0 comments on commit 5fb268e

Please sign in to comment.