Skip to content

Commit

Permalink
updated mapping for bool values
Browse files Browse the repository at this point in the history
  • Loading branch information
1101-1 committed Nov 11, 2024
1 parent f277dce commit 7bba82e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
8 changes: 3 additions & 5 deletions plugins/azure/fix_plugin_azure/resource/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
ModelReference,
PhantomBaseResource,
)
from fixlib.json_bender import Bender, S, ForallBend, Bend
from fixlib.json_bender import Bender, S, ForallBend, Bend, AsBool
from fixlib.types import Json

log = logging.getLogger("fix.plugins.azure")
Expand Down Expand Up @@ -165,6 +165,8 @@ class AzureStorageBlobContainer(MicrosoftResource, BaseBucket):
"public_access": S("properties", "publicAccess"),
"remaining_retention_days": S("properties", "remainingRetentionDays"),
"version": S("properties", "version"),
"encryption_enabled": S("properties", "defaultEncryptionScope") >> AsBool(),
"versioning_enabled": S("properties", "immutableStorageWithVersioning") >> AsBool(),
}
type: Optional[str] = field(default=None, metadata={'description': 'The type of the resource. E.g. Microsoft.Compute/virtualMachines or Microsoft.Storage/storageAccounts '}) # fmt: skip
default_encryption_scope: Optional[str] = field(default=None, metadata={'description': 'Default the container to use specified encryption scope for all writes.'}) # fmt: skip
Expand All @@ -187,10 +189,6 @@ class AzureStorageBlobContainer(MicrosoftResource, BaseBucket):
remaining_retention_days: Optional[int] = field(default=None, metadata={'description': 'Remaining retention days for soft deleted blob container.'}) # fmt: skip
version: Optional[str] = field(default=None, metadata={'description': 'The version of the deleted blob container.'}) # fmt: skip

def post_process(self, graph_builder: GraphBuilder, source: Json) -> None:
self.encryption_enabled = bool(self.default_encryption_scope)
self.versioning_enabled = bool(self.blob_immutable_storage_with_versioning)


@define(eq=False, slots=False)
class AzureStorageAccountDeleted(MicrosoftResource, PhantomBaseResource):
Expand Down
9 changes: 3 additions & 6 deletions plugins/gcp/fix_plugin_gcp/resources/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
from attr import define, field

from fix_plugin_gcp.gcp_client import GcpApiSpec
from fix_plugin_gcp.resources.base import GcpResource, GraphBuilder, GcpDeprecationStatus, get_client
from fix_plugin_gcp.resources.base import GcpResource, GcpDeprecationStatus, get_client
from fixlib.baseresources import BaseBucket
from fixlib.graph import Graph
from fixlib.types import Json
from fixlib.json_bender import Bender, S, Bend, ForallBend
from fixlib.json_bender import Bender, S, Bend, ForallBend, AsBool

service_name = "storage"

Expand Down Expand Up @@ -392,6 +391,7 @@ class GcpBucket(GcpResource, BaseBucket):
"updated": S("updated"),
"versioning_enabled": S("versioning", "enabled"),
"bucket_website": S("website", default={}) >> Bend(GcpWebsite.mapping),
"encryption_enabled": S("encryption", "defaultKmsKeyName") >> AsBool(),
}
acl: Optional[List[GcpBucketAccessControl]] = field(default=None)
autoclass: Optional[GcpAutoclass] = field(default=None)
Expand All @@ -418,9 +418,6 @@ class GcpBucket(GcpResource, BaseBucket):
requester_pays: Optional[bool] = field(default=None)
lifecycle_rule: List[GcpRule] = field(factory=list)

def post_process(self, graph_builder: GraphBuilder, source: Json) -> None:
self.encryption_enabled = bool(self.encryption_default_kms_key_name)

def pre_delete(self, graph: Graph) -> bool:
client = get_client(self)
objects = client.list(GcpObject.api_spec, bucket=self.name)
Expand Down

0 comments on commit 7bba82e

Please sign in to comment.