Skip to content

Commit

Permalink
Merge pull request #127 from stat-kwon/master
Browse files Browse the repository at this point in the history
Remove method for generating memory size in cloud functions
  • Loading branch information
stat-kwon authored May 14, 2024
2 parents 3862b17 + de8a510 commit cce3d57
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ def collect_cloud_service(self, params):
"memory_allocated": self._make_memory_allocated(
function["availableMemoryMb"]
),
"memory_size": float(function["availableMemoryMb"]),
"ingress_settings": self._make_ingress_setting_readable(
function["ingressSettings"]
function.get("ingressSettings")
),
"vpc_connector_egress_settings": self._make_vpc_egress_readable(
function.get("vpc_connector_egress_settings")
Expand Down Expand Up @@ -229,8 +228,11 @@ def _make_vpc_egress_readable(egress_settings):

@staticmethod
def _make_ingress_setting_readable(ingress_settings):
ingress_settings = ingress_settings.replace("_", " ").lower()
return ingress_settings[0].upper() + ingress_settings[1:]
if ingress_settings:
ingress_settings = ingress_settings.replace("_", " ").lower()
return ingress_settings[0].upper() + ingress_settings[1:]
else:
return ""

@staticmethod
def _make_storage_object(function_id):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,6 @@ def collect_cloud_service(self, params):
"vpc_connector_egress_settings": self._make_vpc_egress_readable(
function["serviceConfig"].get("vpcConnectorEgressSettings")
),
"memory_size": float(
self._make_memory_size(
function["serviceConfig"]["availableMemory"]
)
),
}
)

Expand Down Expand Up @@ -296,19 +291,6 @@ def _make_memory_allocated(memory):
number, *unit = memory.split("Gi")
return f"{number} GiB"

@staticmethod
def _make_memory_size(memory):
try:
number, *unit = memory.split("Mi")
return number
except ValueError:
number, *unit = memory.split("M")
return number
except Exception:
number, *unit = memory.split("Gi")
number = float(number * 1024)
return number

@staticmethod
def _make_vpc_egress_readable(egress_settings):
if egress_settings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ def get_location(self, bucket):
location_display = f"{location} {map_str}"

else:
_LOGGER.debug(f"[DEBUG] location : {location}")
region = self.match_region_info(location)
region_name = region.get("name", "")
location_display = f"{location} | {region_name}"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class FunctionDisplay(Model):
build_environment_variables = ListType(
ModelType(Variable), serialize_when_none=False
)
memory_size = FloatType(serialize_when_none=False)


class FunctionGen1(BaseResource):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class FunctionDisplay(Model):
build_environment_variables = ListType(
ModelType(Variable), serialize_when_none=False
)
memory_size = FloatType(serialize_when_none=False)


class FunctionGen2(BaseResource):
Expand Down
2 changes: 1 addition & 1 deletion test/api/test_cloudservice_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_collect(self):
"""
options = {
# "cloud_service_types": ["CloudFunctions"],
"cloud_service_types": ["BigQuery"],
"cloud_service_types": ["CloudStorage"],
# "custom_asset_url": 'http://xxxxx.spaceone.dev/icon/google'
}
filter = {}
Expand Down

0 comments on commit cce3d57

Please sign in to comment.