Extract shared adapter validation helpers
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user