Skip to content

Commit

Permalink
Merge pull request #266 from opsmill/wvd-20250210-fix-node-artifact-m…
Browse files Browse the repository at this point in the history
…ethods

Update InfrahubNode artifact_fetch and artifact_generate methods to use artiface name instead of the defintion name
  • Loading branch information
wvandeun authored Feb 11, 2025
2 parents 7f1ebbb + 86024fc commit 0d491c0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog/+artifact_methods.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Changes InfrahubNode `artifact_fetch` and `artifact_generate` methods to use the name of the artifact instead of the name of the artifact definition
4 changes: 2 additions & 2 deletions infrahub_sdk/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1118,14 +1118,14 @@ async def generate(self, nodes: list[str] | None = None) -> None:
async def artifact_generate(self, name: str) -> None:
self._validate_artifact_support(ARTIFACT_GENERATE_FEATURE_NOT_SUPPORTED_MESSAGE)

artifact = await self._client.get(kind="CoreArtifact", definition__name__value=name, object__ids=[self.id])
artifact = await self._client.get(kind="CoreArtifact", name__value=name, object__ids=[self.id])
await artifact.definition.fetch() # type: ignore[attr-defined]
await artifact.definition.peer.generate([artifact.id]) # type: ignore[attr-defined]

async def artifact_fetch(self, name: str) -> str | dict[str, Any]:
self._validate_artifact_support(ARTIFACT_GENERATE_FEATURE_NOT_SUPPORTED_MESSAGE)

artifact = await self._client.get(kind="CoreArtifact", definition__name__value=name, object__ids=[self.id])
artifact = await self._client.get(kind="CoreArtifact", name__value=name, object__ids=[self.id])
content = await self._client.object_store.get(identifier=artifact.storage_id.value) # type: ignore[attr-defined]
return content

Expand Down

0 comments on commit 0d491c0

Please sign in to comment.