Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fb/reg update skip unchanged #39

Merged
merged 4 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ commands:
* --registry-offboard-skip TENANT_ID SKIP_APPS offboard tenant subscription skipping apps
... [TENANT] filter list for tenant id or subdomain
... --time list includes timestamps
... --skip-unchanged skip update for unchanged dependencies

=== cap multitenancy (cds) ===
~ cdsl --cds-list [TENANT] list all cds-mtx tenant names
Expand Down
1 change: 1 addition & 0 deletions docs/tenant-registry/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Commands for this area are:
* --registry-offboard-skip TENANT_ID SKIP_APPS offboard tenant subscription skipping apps
... [TENANT] filter list for tenant id or subdomain
... --time list includes timestamps
... --skip-unchanged skip update for unchanged dependencies

~ are read-only commands
* are potentially _dangerous_ commands
Expand Down
1 change: 1 addition & 0 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ commands:
* --registry-offboard-skip TENANT_ID SKIP_APPS offboard tenant subscription skipping apps
... [TENANT] filter list for tenant id or subdomain
... --time list includes timestamps
... --skip-unchanged skip update for unchanged dependencies

=== cap multitenancy (cds) ===
~ cdsl --cds-list [TENANT] list all cds-mtx tenant names
Expand Down
3 changes: 3 additions & 0 deletions src/cliOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const FLAG_ARG = Object.freeze({
REVEAL: "--reveal",
TIMESTAMPS: "--time",
AUTO_UNDEPLOY: "--auto-undeploy",
SKIP_UNCHANGED: "--skip-unchanged",
});

module.exports = {
Expand Down Expand Up @@ -104,10 +105,12 @@ module.exports = {
REGISTRY_UPDATE_DEPENDENCIES: {
commandVariants: ["--registry-update"],
requiredPassArgs: [PASS_ARG.TENANT_ID],
optionalFlagArgs: [FLAG_ARG.SKIP_UNCHANGED],
callback: reg.registryUpdateDependencies,
},
REGISTRY_UPDATE_ALL_DEPENDENCIES: {
commandVariants: ["--registry-update-all"],
optionalFlagArgs: [FLAG_ARG.SKIP_UNCHANGED],
callback: reg.registryUpdateAllDependencies,
},
REGISTRY_UPDATE_APPURL: {
Expand Down
15 changes: 12 additions & 3 deletions src/submodules/tenantRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,13 @@ const _registryCallForTenant = async (
context,
tenantId,
method,
{ noCallbacksAppNames, updateApplicationURL, skipUpdatingDependencies, doJobPoll = true } = {}
{
noCallbacksAppNames,
updateApplicationURL,
skipUnchangedDependencies,
skipUpdatingDependencies,
doJobPoll = true,
} = {}
) => {
assert(isUUID(tenantId), "TENANT_ID is not a uuid", tenantId);
const {
Expand All @@ -143,6 +149,7 @@ const _registryCallForTenant = async (
const query = {
...(noCallbacksAppNames && { noCallbacksAppNames }),
...(updateApplicationURL && { updateApplicationURL }),
...(skipUnchangedDependencies && { skipUnchangedDependencies }),
...(skipUpdatingDependencies && { skipUpdatingDependencies }),
};
const response = await request({
Expand Down Expand Up @@ -176,9 +183,11 @@ const _registryCallForTenants = async (context, method, options = {}) => {
return result;
};

const registryUpdateDependencies = async (context, [tenantId]) => _registryCallForTenant(context, tenantId, "PATCH");
const registryUpdateDependencies = async (context, [tenantId], [doSkipUnchanged]) =>
_registryCallForTenant(context, tenantId, "PATCH", { skipUnchangedDependencies: doSkipUnchanged });

const registryUpdateAllDependencies = async (context) => _registryCallForTenants(context, "PATCH");
const registryUpdateAllDependencies = async (context, _, [doSkipUnchanged]) =>
_registryCallForTenants(context, "PATCH", { skipUnchangedDependencies: doSkipUnchanged });

const registryUpdateApplicationURL = async (context, [tenantId]) =>
tenantId
Expand Down
4 changes: 2 additions & 2 deletions test/tenantRegistry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ describe("reg tests", () => {
test("reg update tenant", async () => {
const { nockDone } = await nockBack("reg-update-tenant.json", { afterRecord: anonymizeNock });

expect(await reg.registryUpdateDependencies(await freshContext(), [testTenantId])).toMatchInlineSnapshot(`
expect(await reg.registryUpdateDependencies(await freshContext(), [testTenantId], [false])).toMatchInlineSnapshot(`
"{
"id": "3b2e7059-86e9-4599-a017-60154745b4fb",
"state": "SUCCEEDED"
Expand All @@ -186,7 +186,7 @@ describe("reg tests", () => {
test("reg update tenant all", async () => {
const { nockDone } = await nockBack("reg-update-tenant-all.json", { afterRecord: anonymizeNock });

expect(await reg.registryUpdateAllDependencies(await freshContext())).toMatchInlineSnapshot(`
expect(await reg.registryUpdateAllDependencies(await freshContext(), undefined, [false])).toMatchInlineSnapshot(`
[
"{
"id": "77a3bd87-7fff-4f33-bf98-c1d1300cab34",
Expand Down