@revoengine/cli 1.0.18 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -3
- package/dist/src/client.d.ts +31 -6
- package/dist/src/client.js +1 -1
- package/dist/src/commands/component.js +25 -0
- package/dist/src/component-lock.d.ts +3 -0
- package/dist/src/component-lock.js +7 -5
- package/dist/src/metadata-backfill.js +9 -0
- package/dist/src/migration.js +1 -0
- package/dist/src/project.js +1 -1
- package/dist/src/resource-syncs/account-principal.d.ts +19 -1
- package/dist/src/resource-syncs/account-principal.js +94 -4
- package/dist/src/resource-syncs/endpoint-sync.d.ts +3 -0
- package/dist/src/resource-syncs/endpoint-sync.js +27 -1
- package/dist/src/resource-syncs/group-sync.d.ts +4 -1
- package/dist/src/resource-syncs/group-sync.js +32 -17
- package/dist/src/resource-syncs/identity-migration.d.ts +1 -1
- package/dist/src/resource-syncs/identity-migration.js +20 -1
- package/dist/src/resource-syncs/job-template-sync.d.ts +2 -1
- package/dist/src/resource-syncs/job-template-sync.js +38 -32
- package/dist/src/resource-syncs/service-account-sync.js +53 -11
- package/dist/src/types.d.ts +27 -0
- package/dist/src/ui.js +1 -1
- package/dist/src/workspace-prune.js +32 -4
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ import { hashStable, readComponentLock, removeComponentLockBaseline, writeCompon
|
|
|
4
4
|
import { readProjectStableKeyName } from "./project.js";
|
|
5
5
|
import { readResourceInventory, resourceIdOf } from "./resource-inventory.js";
|
|
6
6
|
import { normalizeStableKeyValue, readConfiguredResourceMetadataStableKey } from "./resource-metadata.js";
|
|
7
|
+
import { isBuiltinSystemAccount } from "./resource-syncs/account-principal.js";
|
|
7
8
|
import { findManifestFiles, isRecord, requireProjectLayout } from "./resource-syncs/util.js";
|
|
8
9
|
const manifests = {
|
|
9
10
|
component: ['Components', 'component.json'],
|
|
@@ -91,13 +92,15 @@ function localReferences(resource, manifest) {
|
|
|
91
92
|
}
|
|
92
93
|
if (isRecord(manifest.executionPrincipal))
|
|
93
94
|
add('service-account', manifest.executionPrincipal.stableKey);
|
|
95
|
+
if (isRecord(manifest.executionPolicy) && isRecord(manifest.executionPolicy.serviceAccount) && manifest.executionPolicy.serviceAccount.kind === 'service-account')
|
|
96
|
+
add('service-account', manifest.executionPolicy.serviceAccount.stableKey);
|
|
94
97
|
return refs;
|
|
95
98
|
}
|
|
96
99
|
function remoteReferences(resource, record, tables) {
|
|
97
100
|
const refs = [];
|
|
98
|
-
const add = (family, value) => {
|
|
101
|
+
const add = (family, value, targetLocal = false) => {
|
|
99
102
|
if (typeof value === 'string' && value)
|
|
100
|
-
refs.push({ resource: family, identity: value });
|
|
103
|
+
refs.push({ resource: family, identity: value, targetLocal });
|
|
101
104
|
};
|
|
102
105
|
if (resource === 'job-template' || resource === 'endpoint')
|
|
103
106
|
add('component', record.componentId);
|
|
@@ -105,6 +108,8 @@ function remoteReferences(resource, record, tables) {
|
|
|
105
108
|
add('component', record.options.componentSchemaId);
|
|
106
109
|
if (resource === 'job-template')
|
|
107
110
|
add('service-account', record.triggerUser);
|
|
111
|
+
if ((resource === 'job-template' || resource === 'endpoint') && isRecord(record.executionPolicy) && record.executionPolicy.mode === 'SERVICE_ACCOUNT')
|
|
112
|
+
add('service-account', record.executionPolicy.serviceAccountUserId);
|
|
108
113
|
if (resource === 'schedule' || resource === 'event') {
|
|
109
114
|
add(record.targetType === 'JOB_TEMPLATE' ? 'job-template' : 'database-view', record.targetId);
|
|
110
115
|
}
|
|
@@ -125,6 +130,26 @@ function remoteReferences(resource, record, tables) {
|
|
|
125
130
|
add('database-table', resourceIdOf(table));
|
|
126
131
|
}
|
|
127
132
|
}
|
|
133
|
+
if (resource === 'service-account') {
|
|
134
|
+
if (isRecord(record.access)) {
|
|
135
|
+
const users = Array.isArray(record.access.users) ? record.access.users.filter(user => isRecord(user) && user.userId !== record.userId) : [];
|
|
136
|
+
const groups = Array.isArray(record.access.groups) ? record.access.groups : [];
|
|
137
|
+
const targetLocal = record.access.restricted !== true || users.length + groups.length !== 1;
|
|
138
|
+
for (const user of users)
|
|
139
|
+
if (isRecord(user))
|
|
140
|
+
add('service-account', user.userId, targetLocal);
|
|
141
|
+
for (const group of groups)
|
|
142
|
+
if (isRecord(group))
|
|
143
|
+
add('group', group.groupId, targetLocal);
|
|
144
|
+
}
|
|
145
|
+
if (isRecord(record.memberships)) {
|
|
146
|
+
for (const [family, values] of [['group', record.memberships.groups], ['role-group', record.memberships.roleGroups]]) {
|
|
147
|
+
if (Array.isArray(values))
|
|
148
|
+
for (const value of values)
|
|
149
|
+
add(family, value, true);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
128
153
|
if (record.ownerType === 'GROUP')
|
|
129
154
|
add('group', record.ownerId);
|
|
130
155
|
if (record.ownerType === 'USER')
|
|
@@ -154,7 +179,7 @@ export function planWorkspacePrune(input) {
|
|
|
154
179
|
throw new Error(`Repeated ${resource} target ID "${id}".`);
|
|
155
180
|
const stableKey = readConfiguredResourceMetadataStableKey(record, input.stableKeyName);
|
|
156
181
|
byId.set(key(resource, id), { resource, record, stableKey });
|
|
157
|
-
if (!stableKey)
|
|
182
|
+
if (!stableKey || isBuiltinSystemAccount(record))
|
|
158
183
|
continue;
|
|
159
184
|
const identity = normalizeStableKeyValue(stableKey);
|
|
160
185
|
if (keys.has(identity))
|
|
@@ -210,7 +235,10 @@ export function planWorkspacePrune(input) {
|
|
|
210
235
|
const removed = candidates.get(referenced);
|
|
211
236
|
// A managed retained consumer can release the old reference during upsert.
|
|
212
237
|
// An unmanaged or out-of-scope consumer must never be removed implicitly.
|
|
213
|
-
const preservesReference = desired && (
|
|
238
|
+
const preservesReference = desired && (reference.targetLocal
|
|
239
|
+
||
|
|
240
|
+
((target.resource === 'group' || target.resource === 'service-account')
|
|
241
|
+
&& (!isRecord(desired.owner) || !['group', 'service-account'].includes(String(desired.owner.type))))
|
|
214
242
|
|| (target.resource === 'job-template' && removed.resource === 'service-account' && !isRecord(desired.executionPrincipal)));
|
|
215
243
|
if (!desired || preservesReference || localReferences(target.resource, desired).some((ref) => key(ref.resource, ref.identity) === key(removed.resource, removed.stableKey))) {
|
|
216
244
|
blockers.push(`${removed.resource} "${removed.stableKey}" is still referenced by retained ${target.resource} "${target.stableKey || resourceIdOf(target.record)}".`);
|