Compare commits
10 Commits
test-scena
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06b54c97f1 | ||
| 9ffe1ba7b5 | |||
| 5f9da63fa0 | |||
|
|
6433452c9d | ||
|
|
2a3e033b56 | ||
|
|
bb7fc8dc16 | ||
| a93eebdf18 | |||
|
|
062e228902 | ||
|
|
ad8557d543 | ||
| 490ae09a3f |
@ -73,31 +73,67 @@ jobs:
|
|||||||
print(f"[{env}] Reconciler call failed: {e}")
|
print(f"[{env}] Reconciler call failed: {e}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Format as markdown grouped by action
|
# Format as markdown table
|
||||||
ops = data.get("operations", [])
|
ops = data.get("operations", [])
|
||||||
summary = data.get("summary", {})
|
summary = data.get("summary", {})
|
||||||
lines = [f"## Reconciliation Plan: `{env}`\n"]
|
lines = [f"## Reconciliation Plan: `{env}`\n"]
|
||||||
if not ops:
|
if not ops:
|
||||||
lines.append("No changes detected.\n")
|
lines.append("No changes detected.\n")
|
||||||
else:
|
else:
|
||||||
groups = {"Create": [], "Update": [], "Delete": []}
|
def fmt_val(v):
|
||||||
for op in ops:
|
if isinstance(v, bool):
|
||||||
t = op["type"]
|
return str(v).lower()
|
||||||
if t.startswith("create"): groups["Create"].append(op)
|
if isinstance(v, list):
|
||||||
elif t.startswith("delete"): groups["Delete"].append(op)
|
return ", ".join(str(x) for x in v) if v else "(empty)"
|
||||||
else: groups["Update"].append(op)
|
if v is None:
|
||||||
|
return "(none)"
|
||||||
|
return str(v)
|
||||||
|
|
||||||
for action, items in groups.items():
|
def get_action(op):
|
||||||
if not items:
|
"""Derive a human-readable action from the operation."""
|
||||||
continue
|
t = op["type"]
|
||||||
emoji = {"Create": "+", "Update": "~", "Delete": "-"}[action]
|
changes = op.get("changes", [])
|
||||||
lines.append(f"### {action} ({len(items)})\n")
|
# For updates, check if it's just an enable/disable toggle
|
||||||
lines.append("| Resource | Name |")
|
if not t.startswith("create") and not t.startswith("delete"):
|
||||||
lines.append("|----------|------|")
|
if len(changes) == 1 and changes[0]["field"] == "enabled":
|
||||||
for op in items:
|
return "disable" if changes[0]["to"] is False else "enable"
|
||||||
resource = op["type"].split("_", 1)[1] if "_" in op["type"] else op["type"]
|
return "update"
|
||||||
lines.append(f"| {resource} | {op['name']} |")
|
return t.split("_", 1)[0]
|
||||||
lines.append("")
|
|
||||||
|
def fmt_details(op, action):
|
||||||
|
"""Format details based on action type."""
|
||||||
|
if action == "delete":
|
||||||
|
return ""
|
||||||
|
if action in ("enable", "disable"):
|
||||||
|
return ""
|
||||||
|
changes = op.get("changes", [])
|
||||||
|
if changes:
|
||||||
|
parts = []
|
||||||
|
for c in changes:
|
||||||
|
parts.append(f"`{c['field']}`: {fmt_val(c['from'])} → {fmt_val(c['to'])}")
|
||||||
|
return "; ".join(parts)
|
||||||
|
d = op.get("details", {})
|
||||||
|
if not d:
|
||||||
|
return ""
|
||||||
|
parts = []
|
||||||
|
if "sources" in d and "destinations" in d:
|
||||||
|
parts.append(f"{fmt_val(d['sources'])} → {fmt_val(d['destinations'])}")
|
||||||
|
if "auto_groups" in d:
|
||||||
|
parts.append(f"groups: {fmt_val(d['auto_groups'])}")
|
||||||
|
if "type" in d and "address" in d:
|
||||||
|
parts.append(f"{d['type']}:{d['address']}")
|
||||||
|
if "peers" in d:
|
||||||
|
parts.append(f"peers: {fmt_val(d['peers'])}")
|
||||||
|
return "; ".join(parts) if parts else ""
|
||||||
|
|
||||||
|
lines.append("| Action | Resource | Name | Details |")
|
||||||
|
lines.append("|--------|----------|------|---------|")
|
||||||
|
for op in ops:
|
||||||
|
resource = op["type"].split("_", 1)[1] if "_" in op["type"] else op["type"]
|
||||||
|
action = get_action(op)
|
||||||
|
detail = fmt_details(op, action)
|
||||||
|
lines.append(f"| {action} | {resource} | {op['name']} | {detail} |")
|
||||||
|
lines.append("")
|
||||||
|
|
||||||
c, u, d = summary.get("created", 0), summary.get("updated", 0), summary.get("deleted", 0)
|
c, u, d = summary.get("created", 0), summary.get("updated", 0), summary.get("deleted", 0)
|
||||||
lines.append(f"**Total: {c} create, {u} update, {d} delete**")
|
lines.append(f"**Total: {c} create, {u} update, {d} delete**")
|
||||||
|
|||||||
@ -95,9 +95,32 @@ jobs:
|
|||||||
f"{summary.get('updated',0)} updated, "
|
f"{summary.get('updated',0)} updated, "
|
||||||
f"{summary.get('deleted',0)} deleted")
|
f"{summary.get('deleted',0)} deleted")
|
||||||
|
|
||||||
|
# Log each operation with details
|
||||||
|
for op in data.get("operations", []):
|
||||||
|
t = op["type"]
|
||||||
|
n = op["name"]
|
||||||
|
s = op.get("status", "?")
|
||||||
|
action = "CREATE" if t.startswith("create") else "DELETE" if t.startswith("delete") else "UPDATE"
|
||||||
|
resource = t.split("_", 1)[1] if "_" in t else t
|
||||||
|
prefix = f"[{env}] {action} {resource} '{n}' -> {s}"
|
||||||
|
|
||||||
|
changes = op.get("changes", [])
|
||||||
|
if changes:
|
||||||
|
def fmt(v):
|
||||||
|
if isinstance(v, bool): return str(v).lower()
|
||||||
|
if isinstance(v, list): return ", ".join(str(x) for x in v) if v else "(empty)"
|
||||||
|
if v is None: return "(none)"
|
||||||
|
return str(v)
|
||||||
|
parts = [f"{c['field']}: {fmt(c['from'])} -> {fmt(c['to'])}" for c in changes]
|
||||||
|
print(f" {prefix} [{'; '.join(parts)}]")
|
||||||
|
else:
|
||||||
|
print(f" {prefix}")
|
||||||
|
|
||||||
keys = data.get("created_keys", {})
|
keys = data.get("created_keys", {})
|
||||||
if keys:
|
if keys:
|
||||||
print(f"[{env}] Created setup keys: {list(keys.keys())}")
|
print(f"[{env}] Created setup keys:")
|
||||||
|
for name, value in keys.items():
|
||||||
|
print(f" {name}: {value}")
|
||||||
|
|
||||||
if failed:
|
if failed:
|
||||||
print(f"\nFailed environments: {failed}")
|
print(f"\nFailed environments: {failed}")
|
||||||
|
|||||||
@ -12,7 +12,7 @@ function makeEvent(overrides: Partial<NbEvent> = {}): NbEvent {
|
|||||||
initiator_id: "init-1",
|
initiator_id: "init-1",
|
||||||
initiator_name: "admin",
|
initiator_name: "admin",
|
||||||
target_id: "peer-1",
|
target_id: "peer-1",
|
||||||
meta: { setup_key: "drone-key", name: "drone-01" },
|
meta: { setup_key_name: "drone-key", name: "drone-01" },
|
||||||
...overrides,
|
...overrides,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ Deno.test("processEnrollmentEvents filters by lastTimestamp", () => {
|
|||||||
Deno.test("processEnrollmentEvents ignores unknown keys", () => {
|
Deno.test("processEnrollmentEvents ignores unknown keys", () => {
|
||||||
const events: NbEvent[] = [
|
const events: NbEvent[] = [
|
||||||
makeEvent({
|
makeEvent({
|
||||||
meta: { setup_key: "rogue-key", name: "rogue-host" },
|
meta: { setup_key_name: "rogue-key", name: "rogue-host" },
|
||||||
target_id: "peer-x",
|
target_id: "peer-x",
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|||||||
@ -21,10 +21,10 @@ export function processEnrollmentEvents(
|
|||||||
.filter((e) => {
|
.filter((e) => {
|
||||||
if (e.activity_code !== "peer.setupkey.add") return false;
|
if (e.activity_code !== "peer.setupkey.add") return false;
|
||||||
if (lastTimestamp && e.timestamp <= lastTimestamp) return false;
|
if (lastTimestamp && e.timestamp <= lastTimestamp) return false;
|
||||||
if (!knownKeyNames.has(e.meta.setup_key)) {
|
if (!knownKeyNames.has(e.meta.setup_key_name)) {
|
||||||
console.log(JSON.stringify({
|
console.log(JSON.stringify({
|
||||||
msg: "unknown_enrollment",
|
msg: "unknown_enrollment",
|
||||||
setup_key: e.meta.setup_key,
|
setup_key_name: e.meta.setup_key_name,
|
||||||
peer_id: e.target_id,
|
peer_id: e.target_id,
|
||||||
}));
|
}));
|
||||||
return false;
|
return false;
|
||||||
@ -32,7 +32,7 @@ export function processEnrollmentEvents(
|
|||||||
return true;
|
return true;
|
||||||
})
|
})
|
||||||
.map((e) => ({
|
.map((e) => ({
|
||||||
setupKeyName: e.meta.setup_key,
|
setupKeyName: e.meta.setup_key_name,
|
||||||
peerId: e.target_id,
|
peerId: e.target_id,
|
||||||
peerHostname: e.meta.name,
|
peerHostname: e.meta.name,
|
||||||
timestamp: e.timestamp,
|
timestamp: e.timestamp,
|
||||||
|
|||||||
@ -1,7 +1,11 @@
|
|||||||
import type { DesiredState } from "../state/schema.ts";
|
import type { DesiredState } from "../state/schema.ts";
|
||||||
import type { ActualState } from "../state/actual.ts";
|
import type { ActualState } from "../state/actual.ts";
|
||||||
import type { NbPolicyRule } from "../netbird/types.ts";
|
import type { NbPolicyRule } from "../netbird/types.ts";
|
||||||
import { EXECUTION_ORDER, type Operation } from "./operations.ts";
|
import {
|
||||||
|
EXECUTION_ORDER,
|
||||||
|
type FieldChange,
|
||||||
|
type Operation,
|
||||||
|
} from "./operations.ts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares desired state against actual state and returns an ordered list of
|
* Compares desired state against actual state and returns an ordered list of
|
||||||
@ -53,10 +57,14 @@ function diffPostureChecks(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
const pcChanges: FieldChange[] = [];
|
||||||
existing.description !== config.description ||
|
if (existing.description !== config.description) {
|
||||||
JSON.stringify(existing.checks) !== JSON.stringify(config.checks)
|
pcChanges.push({ field: "description", from: existing.description, to: config.description });
|
||||||
) {
|
}
|
||||||
|
if (JSON.stringify(existing.checks) !== JSON.stringify(config.checks)) {
|
||||||
|
pcChanges.push({ field: "checks", from: existing.checks, to: config.checks });
|
||||||
|
}
|
||||||
|
if (pcChanges.length > 0) {
|
||||||
ops.push({
|
ops.push({
|
||||||
type: "update_posture_check",
|
type: "update_posture_check",
|
||||||
name,
|
name,
|
||||||
@ -64,6 +72,7 @@ function diffPostureChecks(
|
|||||||
description: config.description,
|
description: config.description,
|
||||||
checks: config.checks,
|
checks: config.checks,
|
||||||
},
|
},
|
||||||
|
changes: pcChanges,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,6 +117,9 @@ function diffGroups(
|
|||||||
desired_peers: desiredPeerNames,
|
desired_peers: desiredPeerNames,
|
||||||
actual_peers: actualPeerNames,
|
actual_peers: actualPeerNames,
|
||||||
},
|
},
|
||||||
|
changes: [
|
||||||
|
{ field: "peers", from: actualPeerNames, to: desiredPeerNames },
|
||||||
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,6 +231,9 @@ function diffNetworks(
|
|||||||
type: "update_network",
|
type: "update_network",
|
||||||
name,
|
name,
|
||||||
details: { description: config.description },
|
details: { description: config.description },
|
||||||
|
changes: [
|
||||||
|
{ field: "description", from: existing.description, to: config.description },
|
||||||
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,13 +308,23 @@ function diffNetworkResources(
|
|||||||
const actualGroupNames = existing.groups.map((g) => g.name).sort();
|
const actualGroupNames = existing.groups.map((g) => g.name).sort();
|
||||||
const desiredGroupNames = [...res.groups].sort();
|
const desiredGroupNames = [...res.groups].sort();
|
||||||
|
|
||||||
if (
|
const resChanges: FieldChange[] = [];
|
||||||
existing.description !== res.description ||
|
if (existing.description !== res.description) {
|
||||||
existing.type !== res.type ||
|
resChanges.push({ field: "description", from: existing.description, to: res.description });
|
||||||
existing.address !== res.address ||
|
}
|
||||||
existing.enabled !== res.enabled ||
|
if (existing.type !== res.type) {
|
||||||
!arraysEqual(actualGroupNames, desiredGroupNames)
|
resChanges.push({ field: "type", from: existing.type, to: res.type });
|
||||||
) {
|
}
|
||||||
|
if (existing.address !== res.address) {
|
||||||
|
resChanges.push({ field: "address", from: existing.address, to: res.address });
|
||||||
|
}
|
||||||
|
if (existing.enabled !== res.enabled) {
|
||||||
|
resChanges.push({ field: "enabled", from: existing.enabled, to: res.enabled });
|
||||||
|
}
|
||||||
|
if (!arraysEqual(actualGroupNames, desiredGroupNames)) {
|
||||||
|
resChanges.push({ field: "groups", from: actualGroupNames, to: desiredGroupNames });
|
||||||
|
}
|
||||||
|
if (resChanges.length > 0) {
|
||||||
ops.push({
|
ops.push({
|
||||||
type: "update_network_resource",
|
type: "update_network_resource",
|
||||||
name: res.name,
|
name: res.name,
|
||||||
@ -312,6 +337,7 @@ function diffNetworkResources(
|
|||||||
enabled: res.enabled,
|
enabled: res.enabled,
|
||||||
groups: res.groups,
|
groups: res.groups,
|
||||||
},
|
},
|
||||||
|
changes: resChanges,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -362,11 +388,17 @@ function diffNetworkRouters(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compare mutable fields
|
// Compare mutable fields
|
||||||
if (
|
const routerChanges: FieldChange[] = [];
|
||||||
existing.metric !== router.metric ||
|
if (existing.metric !== router.metric) {
|
||||||
existing.masquerade !== router.masquerade ||
|
routerChanges.push({ field: "metric", from: existing.metric, to: router.metric });
|
||||||
existing.enabled !== router.enabled
|
}
|
||||||
) {
|
if (existing.masquerade !== router.masquerade) {
|
||||||
|
routerChanges.push({ field: "masquerade", from: existing.masquerade, to: router.masquerade });
|
||||||
|
}
|
||||||
|
if (existing.enabled !== router.enabled) {
|
||||||
|
routerChanges.push({ field: "enabled", from: existing.enabled, to: router.enabled });
|
||||||
|
}
|
||||||
|
if (routerChanges.length > 0) {
|
||||||
ops.push({
|
ops.push({
|
||||||
type: "update_network_router",
|
type: "update_network_router",
|
||||||
name: key,
|
name: key,
|
||||||
@ -379,6 +411,7 @@ function diffNetworkRouters(
|
|||||||
masquerade: router.masquerade,
|
masquerade: router.masquerade,
|
||||||
enabled: router.enabled,
|
enabled: router.enabled,
|
||||||
},
|
},
|
||||||
|
changes: routerChanges,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -441,7 +474,7 @@ function diffPeers(
|
|||||||
const existing = actual.peersByName.get(name);
|
const existing = actual.peersByName.get(name);
|
||||||
if (!existing) continue; // Never create or delete peers
|
if (!existing) continue; // Never create or delete peers
|
||||||
|
|
||||||
let changed = false;
|
const peerChanges: FieldChange[] = [];
|
||||||
|
|
||||||
// Compare groups (excluding "All"), resolve actual peer group names
|
// Compare groups (excluding "All"), resolve actual peer group names
|
||||||
const actualGroupNames = existing.groups
|
const actualGroupNames = existing.groups
|
||||||
@ -450,19 +483,20 @@ function diffPeers(
|
|||||||
.sort();
|
.sort();
|
||||||
const desiredGroupNames = [...config.groups].sort();
|
const desiredGroupNames = [...config.groups].sort();
|
||||||
if (!arraysEqual(actualGroupNames, desiredGroupNames)) {
|
if (!arraysEqual(actualGroupNames, desiredGroupNames)) {
|
||||||
changed = true;
|
peerChanges.push({ field: "groups", from: actualGroupNames, to: desiredGroupNames });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (existing.login_expiration_enabled !== config.login_expiration_enabled) {
|
||||||
existing.login_expiration_enabled !== config.login_expiration_enabled ||
|
peerChanges.push({ field: "login_expiration_enabled", from: existing.login_expiration_enabled, to: config.login_expiration_enabled });
|
||||||
existing.inactivity_expiration_enabled !==
|
}
|
||||||
config.inactivity_expiration_enabled ||
|
if (existing.inactivity_expiration_enabled !== config.inactivity_expiration_enabled) {
|
||||||
existing.ssh_enabled !== config.ssh_enabled
|
peerChanges.push({ field: "inactivity_expiration_enabled", from: existing.inactivity_expiration_enabled, to: config.inactivity_expiration_enabled });
|
||||||
) {
|
}
|
||||||
changed = true;
|
if (existing.ssh_enabled !== config.ssh_enabled) {
|
||||||
|
peerChanges.push({ field: "ssh_enabled", from: existing.ssh_enabled, to: config.ssh_enabled });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (peerChanges.length > 0) {
|
||||||
ops.push({
|
ops.push({
|
||||||
type: "update_peer",
|
type: "update_peer",
|
||||||
name,
|
name,
|
||||||
@ -472,6 +506,7 @@ function diffPeers(
|
|||||||
inactivity_expiration_enabled: config.inactivity_expiration_enabled,
|
inactivity_expiration_enabled: config.inactivity_expiration_enabled,
|
||||||
ssh_enabled: config.ssh_enabled,
|
ssh_enabled: config.ssh_enabled,
|
||||||
},
|
},
|
||||||
|
changes: peerChanges,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -511,10 +546,14 @@ function diffUsers(
|
|||||||
).sort();
|
).sort();
|
||||||
const desiredAutoGroupNames = [...config.auto_groups].sort();
|
const desiredAutoGroupNames = [...config.auto_groups].sort();
|
||||||
|
|
||||||
if (
|
const userChanges: FieldChange[] = [];
|
||||||
existing.role !== config.role ||
|
if (existing.role !== config.role) {
|
||||||
!arraysEqual(actualAutoGroupNames, desiredAutoGroupNames)
|
userChanges.push({ field: "role", from: existing.role, to: config.role });
|
||||||
) {
|
}
|
||||||
|
if (!arraysEqual(actualAutoGroupNames, desiredAutoGroupNames)) {
|
||||||
|
userChanges.push({ field: "auto_groups", from: actualAutoGroupNames, to: desiredAutoGroupNames });
|
||||||
|
}
|
||||||
|
if (userChanges.length > 0) {
|
||||||
ops.push({
|
ops.push({
|
||||||
type: "update_user",
|
type: "update_user",
|
||||||
name: email,
|
name: email,
|
||||||
@ -523,6 +562,7 @@ function diffUsers(
|
|||||||
role: config.role,
|
role: config.role,
|
||||||
auto_groups: config.auto_groups,
|
auto_groups: config.auto_groups,
|
||||||
},
|
},
|
||||||
|
changes: userChanges,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -609,12 +649,30 @@ function diffPolicies(
|
|||||||
desiredPostureChecks,
|
desiredPostureChecks,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (
|
const changes: FieldChange[] = [];
|
||||||
existing.enabled !== config.enabled ||
|
if (existing.enabled !== config.enabled) {
|
||||||
!arraysEqual(actualSources, desiredSources) ||
|
changes.push({ field: "enabled", from: existing.enabled, to: config.enabled });
|
||||||
destsChanged ||
|
}
|
||||||
postureChecksChanged
|
if (!arraysEqual(actualSources, desiredSources)) {
|
||||||
) {
|
changes.push({ field: "sources", from: actualSources, to: desiredSources });
|
||||||
|
}
|
||||||
|
if (destsChanged) {
|
||||||
|
if (config.destination_resource) {
|
||||||
|
const actualDestRes = existing.rules[0]?.destinationResource;
|
||||||
|
changes.push({ field: "destination_resource", from: actualDestRes ?? null, to: config.destination_resource });
|
||||||
|
} else {
|
||||||
|
const actualDests = extractGroupNames(
|
||||||
|
existing.rules.flatMap((r) => r.destinations ?? []),
|
||||||
|
actual,
|
||||||
|
).sort();
|
||||||
|
changes.push({ field: "destinations", from: actualDests, to: [...config.destinations].sort() });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (postureChecksChanged) {
|
||||||
|
changes.push({ field: "source_posture_checks", from: actualPostureChecks, to: desiredPostureChecks });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changes.length > 0) {
|
||||||
ops.push({
|
ops.push({
|
||||||
type: "update_policy",
|
type: "update_policy",
|
||||||
name,
|
name,
|
||||||
@ -625,6 +683,7 @@ function diffPolicies(
|
|||||||
destination_resource: config.destination_resource,
|
destination_resource: config.destination_resource,
|
||||||
source_posture_checks: config.source_posture_checks,
|
source_posture_checks: config.source_posture_checks,
|
||||||
},
|
},
|
||||||
|
changes,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -682,11 +741,17 @@ function diffRoutes(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
const routeChanges: FieldChange[] = [];
|
||||||
existing.enabled !== config.enabled ||
|
if (existing.enabled !== config.enabled) {
|
||||||
existing.description !== config.description ||
|
routeChanges.push({ field: "enabled", from: existing.enabled, to: config.enabled });
|
||||||
existing.network !== config.network
|
}
|
||||||
) {
|
if (existing.description !== config.description) {
|
||||||
|
routeChanges.push({ field: "description", from: existing.description, to: config.description });
|
||||||
|
}
|
||||||
|
if (existing.network !== config.network) {
|
||||||
|
routeChanges.push({ field: "network", from: existing.network, to: config.network });
|
||||||
|
}
|
||||||
|
if (routeChanges.length > 0) {
|
||||||
ops.push({
|
ops.push({
|
||||||
type: "update_route",
|
type: "update_route",
|
||||||
name: networkId,
|
name: networkId,
|
||||||
@ -695,6 +760,7 @@ function diffRoutes(
|
|||||||
description: config.description,
|
description: config.description,
|
||||||
network: config.network,
|
network: config.network,
|
||||||
},
|
},
|
||||||
|
changes: routeChanges,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -741,11 +807,17 @@ function diffDns(
|
|||||||
config.nameservers,
|
config.nameservers,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (
|
const dnsChanges: FieldChange[] = [];
|
||||||
existing.enabled !== config.enabled ||
|
if (existing.enabled !== config.enabled) {
|
||||||
existing.primary !== config.primary ||
|
dnsChanges.push({ field: "enabled", from: existing.enabled, to: config.enabled });
|
||||||
nsChanged
|
}
|
||||||
) {
|
if (existing.primary !== config.primary) {
|
||||||
|
dnsChanges.push({ field: "primary", from: existing.primary, to: config.primary });
|
||||||
|
}
|
||||||
|
if (nsChanged) {
|
||||||
|
dnsChanges.push({ field: "nameservers", from: existing.nameservers, to: config.nameservers });
|
||||||
|
}
|
||||||
|
if (dnsChanges.length > 0) {
|
||||||
ops.push({
|
ops.push({
|
||||||
type: "update_dns",
|
type: "update_dns",
|
||||||
name,
|
name,
|
||||||
@ -754,6 +826,7 @@ function diffDns(
|
|||||||
primary: config.primary,
|
primary: config.primary,
|
||||||
nameservers: config.nameservers,
|
nameservers: config.nameservers,
|
||||||
},
|
},
|
||||||
|
changes: dnsChanges,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,10 +33,17 @@ export type OperationType =
|
|||||||
| "update_user"
|
| "update_user"
|
||||||
| "delete_user";
|
| "delete_user";
|
||||||
|
|
||||||
|
export interface FieldChange {
|
||||||
|
field: string;
|
||||||
|
from: unknown;
|
||||||
|
to: unknown;
|
||||||
|
}
|
||||||
|
|
||||||
export interface Operation {
|
export interface Operation {
|
||||||
type: OperationType;
|
type: OperationType;
|
||||||
name: string;
|
name: string;
|
||||||
details?: Record<string, unknown>;
|
details?: Record<string, unknown>;
|
||||||
|
changes?: FieldChange[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OperationResult extends Operation {
|
export interface OperationResult extends Operation {
|
||||||
|
|||||||
@ -109,6 +109,8 @@ async function handleReconcile(
|
|||||||
operations: ops.map((op) => ({
|
operations: ops.map((op) => ({
|
||||||
type: op.type,
|
type: op.type,
|
||||||
name: op.name,
|
name: op.name,
|
||||||
|
...(op.details && { details: op.details }),
|
||||||
|
...(op.changes && { changes: op.changes }),
|
||||||
})),
|
})),
|
||||||
summary: summarize(ops),
|
summary: summarize(ops),
|
||||||
});
|
});
|
||||||
@ -141,6 +143,8 @@ async function handleReconcile(
|
|||||||
type: r.type,
|
type: r.type,
|
||||||
name: r.name,
|
name: r.name,
|
||||||
status: r.status,
|
status: r.status,
|
||||||
|
...(r.details && { details: r.details }),
|
||||||
|
...(r.changes && { changes: r.changes }),
|
||||||
})),
|
})),
|
||||||
created_keys: createdKeysObj,
|
created_keys: createdKeysObj,
|
||||||
summary: summarize(results),
|
summary: summarize(results),
|
||||||
|
|||||||
@ -15,30 +15,40 @@
|
|||||||
"type": "one-off",
|
"type": "one-off",
|
||||||
"expires_in": 604800,
|
"expires_in": 604800,
|
||||||
"usage_limit": 1,
|
"usage_limit": 1,
|
||||||
"auto_groups": ["ground-stations"],
|
"auto_groups": [
|
||||||
|
"ground-stations"
|
||||||
|
],
|
||||||
"enrolled": false
|
"enrolled": false
|
||||||
},
|
},
|
||||||
"Pilot-TestHawk-1": {
|
"Pilot-TestHawk-1": {
|
||||||
"type": "one-off",
|
"type": "one-off",
|
||||||
"expires_in": 604800,
|
"expires_in": 604800,
|
||||||
"usage_limit": 1,
|
"usage_limit": 1,
|
||||||
"auto_groups": ["pilots"],
|
"auto_groups": [
|
||||||
|
"pilots"
|
||||||
|
],
|
||||||
"enrolled": false
|
"enrolled": false
|
||||||
},
|
},
|
||||||
"Pilot-Vlad-2": {
|
"GS-Enroll-Test": {
|
||||||
"type": "one-off",
|
"type": "one-off",
|
||||||
"expires_in": 604800,
|
"expires_in": 604800,
|
||||||
"usage_limit": 1,
|
"usage_limit": 1,
|
||||||
"auto_groups": ["pilots"],
|
"auto_groups": [
|
||||||
"enrolled": false
|
"ground-stations"
|
||||||
|
],
|
||||||
|
"enrolled": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"policies": {
|
"policies": {
|
||||||
"pilots-to-gs": {
|
"pilots-to-gs": {
|
||||||
"description": "",
|
"description": "",
|
||||||
"enabled": false,
|
"enabled": false,
|
||||||
"sources": ["pilots"],
|
"sources": [
|
||||||
"destinations": ["ground-stations"],
|
"pilots"
|
||||||
|
],
|
||||||
|
"destinations": [
|
||||||
|
"ground-stations"
|
||||||
|
],
|
||||||
"bidirectional": true,
|
"bidirectional": true,
|
||||||
"protocol": "all",
|
"protocol": "all",
|
||||||
"action": "accept",
|
"action": "accept",
|
||||||
@ -47,14 +57,22 @@
|
|||||||
"observers-to-gs": {
|
"observers-to-gs": {
|
||||||
"description": "",
|
"description": "",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"sources": ["observers"],
|
"sources": [
|
||||||
"destinations": ["ground-stations"],
|
"observers"
|
||||||
|
],
|
||||||
|
"destinations": [
|
||||||
|
"ground-stations"
|
||||||
|
],
|
||||||
"bidirectional": false,
|
"bidirectional": false,
|
||||||
"protocol": "all",
|
"protocol": "all",
|
||||||
"action": "accept",
|
"action": "accept",
|
||||||
"source_posture_checks": []
|
"source_posture_checks": []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"routes": {},
|
||||||
|
"dns": {
|
||||||
|
"nameserver_groups": {}
|
||||||
|
},
|
||||||
"posture_checks": {},
|
"posture_checks": {},
|
||||||
"networks": {},
|
"networks": {},
|
||||||
"peers": {},
|
"peers": {},
|
||||||
@ -64,9 +82,5 @@
|
|||||||
"role": "owner",
|
"role": "owner",
|
||||||
"auto_groups": []
|
"auto_groups": []
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"routes": {},
|
|
||||||
"dns": {
|
|
||||||
"nameserver_groups": {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user