Extract shared adapter validation helpers

This commit is contained in:
Lyncoln
2026-09-20 18:47:21 -04:00
parent d4ceb7e1df
commit 832928159d
6 changed files with 232 additions and 28 deletions
+14 -10
View File
@@ -13,6 +13,11 @@ from ...adapters import (
PlanOperation,
RetireRequest,
)
from ...adapter_support import (
require_action_endpoint,
require_desired,
require_endpoint_plugin,
)
from ...certificates.material import CertificateMaterial
from ...npm_client import NpmClient
from ...object_normalizer import normalize_discovered_object
@@ -67,6 +72,7 @@ class Plugin:
)
def __init__(self, config, endpoint):
require_endpoint_plugin(endpoint, self.name)
self.config = config
self.endpoint = endpoint
self.client = NpmClient(config, endpoint)
@@ -593,17 +599,15 @@ class Plugin:
self,
action: PlanAction,
) -> ApplyResult | None:
desired = action.desired
desired = require_desired(
action,
context="NPM apply",
)
if desired is None:
raise RuntimeError(
"NPM apply requires desired state"
)
if action.endpoint_id != self.endpoint.identity:
raise RuntimeError(
"NPM apply action endpoint does not match adapter"
)
require_action_endpoint(
action,
self.endpoint,
)
if (
desired.object_type == CERTIFICATES