Skip to content

Commit

Permalink
GitOps: standardized API to consumes same payload schema as GraphQL A…
Browse files Browse the repository at this point in the history
…PI (#546)
  • Loading branch information
petruki authored Nov 11, 2024
1 parent 64053de commit af01009
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 163 deletions.
172 changes: 26 additions & 146 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"mongodb": "^6.10.0",
"mongoose": "^8.8.1",
"pino": "^9.5.0",
"pino-pretty": "^11.3.0",
"pino-pretty": "^13.0.0",
"swagger-ui-express": "^5.0.1",
"switcher-client": "^4.1.1",
"validator": "^13.12.0"
Expand All @@ -64,7 +64,7 @@
"jest-sonar-reporter": "^2.0.0",
"node-notifier": "^10.0.1",
"nodemon": "^3.1.7",
"sinon": "^18.0.1",
"sinon": "^19.0.2",
"supertest": "^7.0.0"
},
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions requests/Switcher API.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -5271,7 +5271,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\r\n \"environment\": \"default\",\r\n \"changes\": [\r\n {\r\n \"action\": \"CHANGED\",\r\n \"diff\": \"CONFIG\",\r\n \"path\": [\r\n \"Group Test\",\r\n \"NEW_SWITCHER_2\"\r\n ],\r\n \"content\": {\r\n \"relay\": {\r\n \"type\": \"NOTIFICATION\",\r\n \"method\": \"POST\",\r\n \"endpoint\": \"https://localhost:3000\",\r\n \"description\": \"Push message to log\",\r\n \"activated\": true\r\n }\r\n }\r\n }\r\n ]\r\n}",
"raw": "{\r\n \"environment\": \"default\",\r\n \"changes\": [\r\n {\r\n \"action\": \"CHANGED\",\r\n \"diff\": \"CONFIG\",\r\n \"path\": [\r\n \"Group Test\",\r\n \"NEW_SWITCHER_2\"\r\n ],\r\n \"content\": {\r\n \"relay\": {\r\n \"relay_type\": \"NOTIFICATION\",\r\n \"relay_method\": \"POST\",\r\n \"relay_endpoint\": \"https://localhost:3000\",\r\n \"description\": \"Push message to log\",\r\n \"activated\": true\r\n }\r\n }\r\n }\r\n ]\r\n}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -5461,7 +5461,7 @@
"header": [],
"body": {
"mode": "raw",
"raw": "{\r\n \"environment\": \"default\",\r\n \"changes\": [\r\n {\r\n \"action\": \"NEW\",\r\n \"diff\": \"CONFIG\",\r\n \"path\": [\r\n \"New Group\"\r\n ],\r\n \"content\": {\r\n \"key\": \"NEW_SWITCHER_RELAY\",\r\n \"description\": \"New Switcher Relay\",\r\n \"activated\": true,\r\n \"components\": [\r\n \"switcher-playground\"\r\n ],\r\n \"relay\": {\r\n \"type\": \"NOTIFICATION\",\r\n \"method\": \"POST\",\r\n \"endpoint\": \"https://localhost:3000\",\r\n \"description\": \"Push message to log\",\r\n \"activated\": true\r\n }\r\n }\r\n }\r\n ]\r\n}",
"raw": "{\r\n \"environment\": \"default\",\r\n \"changes\": [\r\n {\r\n \"action\": \"NEW\",\r\n \"diff\": \"CONFIG\",\r\n \"path\": [\r\n \"New Group\"\r\n ],\r\n \"content\": {\r\n \"key\": \"NEW_SWITCHER_RELAY\",\r\n \"description\": \"New Switcher Relay\",\r\n \"activated\": true,\r\n \"components\": [\r\n \"switcher-playground\"\r\n ],\r\n \"relay\": {\r\n \"relay_type\": \"NOTIFICATION\",\r\n \"relay_method\": \"POST\",\r\n \"relay_endpoint\": \"https://localhost:3000\",\r\n \"description\": \"Push message to log\",\r\n \"activated\": true\r\n }\r\n }\r\n }\r\n ]\r\n}",
"options": {
"raw": {
"language": "json"
Expand Down
8 changes: 7 additions & 1 deletion src/services/gitops/push-changed.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ async function processChangedConfig(domain, change, environment) {
}, admin);

if (content.relay) {
await updateConfigRelay(config._id, processRelay(content.relay, config.relay, environment), admin);
await updateConfigRelay(config._id, processRelay({
type: content.relay.relay_type,
method: content.relay.relay_method,
endpoint: content.relay.relay_endpoint,
description: content.relay.description,
activated: content.relay.activated
}, config.relay, environment), admin);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/services/gitops/push-new.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ async function processNewConfig(domain, change, environment) {

if (content.relay) {
newConfig.relay = {
type: content.relay.type,
method: content.relay.method,
type: content.relay.relay_type,
method: content.relay.relay_method,
endpoint: {
[environment]: content.relay.endpoint
[environment]: content.relay.relay_endpoint
},
description: content.relay.description,
activated: {
Expand Down
Loading

0 comments on commit af01009

Please sign in to comment.