mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 09:45:36 +08:00
feat(ql3): persist cluster secret transition receipts
This commit is contained in:
1 parent
c877147d0f
commit
5f93e0b5d2
26 files changed
+1127
-66
No files matched your search
@@ -104,6 +104,20 @@ function transition(assignments, overrides = {}) {
|
||||
});
|
||||
}
|
||||
|
||||
function postgresJsonbRoundTrip(value) {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(postgresJsonbRoundTrip);
|
||||
}
|
||||
if (value && typeof value === 'object') {
|
||||
return Object.fromEntries(
|
||||
Object.entries(value)
|
||||
.sort(([left], [right]) => left.localeCompare(right))
|
||||
.map(([key, entry]) => [key, postgresJsonbRoundTrip(entry)]),
|
||||
);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
test('derives an exact carry-forward for an unchanged next generation', () => {
|
||||
const value = transition([
|
||||
{ name: 'OPTIONAL_TOKEN', secretRef: null },
|
||||
@@ -136,6 +150,19 @@ test('derives an exact carry-forward for an unchanged next generation', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('normalizes a transition after PostgreSQL jsonb reorders object keys', () => {
|
||||
const value = transition([
|
||||
{ name: 'OPTIONAL_TOKEN', secretRef: null },
|
||||
{ name: 'TOKEN', secretRef: secret('runtime-token', 3) },
|
||||
]);
|
||||
assert.deepEqual(
|
||||
normalizePluginPackageSecretBindingTransitionPlan(
|
||||
postgresJsonbRoundTrip(value),
|
||||
),
|
||||
value,
|
||||
);
|
||||
});
|
||||
|
||||
test('distinguishes forward rotation from rebind and version rollback', () => {
|
||||
const rotated = transition([
|
||||
{ name: 'OPTIONAL_TOKEN', secretRef: null },
|
||||
|
||||
Reference in new issue
Block a user