Skip to content

Commit

Permalink
Use the ARN as identifier for all gcp and do resources
Browse files Browse the repository at this point in the history
  • Loading branch information
aquamatthias committed Oct 30, 2023
1 parent 3f6fbed commit cfd4e44
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 7 additions & 2 deletions plugins/digitalocean/resoto_plugin_digitalocean/resources.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from attrs import define
from typing import ClassVar, Dict, List, Optional
from typing import ClassVar, Dict, List, Optional, Tuple, Any

from resoto_plugin_digitalocean.client import StreamingWrapper
from resoto_plugin_digitalocean.client import get_team_credentials
Expand Down Expand Up @@ -46,6 +46,11 @@ class DigitalOceanResource(BaseResource):
kind: ClassVar[str] = "digitalocean_resource"
urn: str = ""

def _keys(self) -> Tuple[Any, ...]:
if self.urn:
return tuple(list(super()._keys()) + [self.urn])
return super()._keys()

def delete_uri_path(self) -> Optional[str]:
return None

Expand Down Expand Up @@ -75,7 +80,7 @@ def delete(self, graph: Graph) -> bool:
raise NotImplementedError

def to_json(self) -> Json:
return _to_json(self, strip_nulls=True, keep_untouched=set(["tags"]))
return _to_json(self, strip_nulls=True, keep_untouched={"tags"})


@define(eq=False, slots=False)
Expand Down
7 changes: 6 additions & 1 deletion plugins/gcp/resoto_plugin_gcp/resources/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from concurrent.futures import Future
from threading import Lock
from types import TracebackType
from typing import Callable, List, ClassVar, Optional, TypeVar, Type, Any, Dict, Set
from typing import Callable, List, ClassVar, Optional, TypeVar, Type, Any, Dict, Set, Tuple

from attr import define, field
from google.auth.credentials import Credentials as GoogleAuthCredentials
Expand Down Expand Up @@ -267,6 +267,11 @@ class GcpResource(BaseResource):
link: Optional[str] = None
label_fingerprint: Optional[str] = None

def _keys(self) -> Tuple[Any, ...]:
if self.link is not None:
return tuple(list(super()._keys()) + [self.link])
return super()._keys()

def delete(self, graph: Graph) -> bool:
if not self.api_spec:
return False
Expand Down

0 comments on commit cfd4e44

Please sign in to comment.