-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitOps - replaced push switch blocks with immutable process constants
- Loading branch information
Showing
4 changed files
with
31 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,12 @@ import { processChanged } from './push-changed.js'; | |
import { processDeleted } from './push-deleted.js'; | ||
import { processNew } from './push-new.js'; | ||
|
||
const CHANGE_PROCESSES = Object.freeze({ | ||
NEW: processNew, | ||
CHANGED: processChanged, | ||
DELETED: processDeleted | ||
}); | ||
|
||
export const ADMIN_EMAIL = '[email protected]'; | ||
|
||
export async function pushChanges(domainId, environment, changes) { | ||
|
@@ -12,18 +18,8 @@ export async function pushChanges(domainId, environment, changes) { | |
|
||
let domain = await getDomainById(domainId); | ||
for (const change of changes) { | ||
switch (change.action) { | ||
case 'NEW': | ||
await processNew(domain, change, environment); | ||
break; | ||
case 'CHANGED': | ||
await processChanged(domain, change, environment); | ||
break; | ||
case 'DELETED': | ||
await processDeleted(domain, change, environment); | ||
break; | ||
} | ||
}; | ||
await CHANGE_PROCESSES[change.action](domain, change, environment); | ||
} | ||
|
||
domain = await updateDomainVersion(domainId); | ||
return { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters