Skip to content
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
6 changes: 3 additions & 3 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 \"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}",
"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}",
"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 \"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}",
"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}",
"options": {
"raw": {
"language": "json"
Expand Down Expand Up @@ -6032,7 +6032,7 @@
"body": {
"mode": "graphql",
"graphql": {
"query": "query Domain(\r\n $_id: String, \r\n $name: String, \r\n $activated: Boolean, \r\n $environment: String, \r\n $_component: String) {\r\n domain(\r\n _id: $_id, \r\n name: $name, \r\n activated: $activated, \r\n environment: $environment,\r\n _component: $_component\r\n ) {\r\n _id\r\n name\r\n version\r\n description\r\n statusByEnv {\r\n env\r\n value\r\n }\r\n activated\r\n group {\r\n _id\r\n name\r\n description\r\n activated\r\n statusByEnv {\r\n env\r\n value\r\n }\r\n config {\r\n _id\r\n key\r\n description\r\n activated\r\n statusByEnv {\r\n env\r\n value\r\n }\r\n strategies {\r\n _id\r\n strategy\r\n activated\r\n statusByEnv {\r\n env\r\n value\r\n }\r\n operation\r\n values\r\n }\r\n relay {\r\n relay_type\r\n relay_method\r\n relay_endpoint\r\n description\r\n activated\r\n statusByEnv {\r\n env\r\n value\r\n }\r\n }\r\n components\r\n }\r\n }\r\n }\r\n}",
"query": "query Domain(\r\n $_id: String, \r\n $name: String, \r\n $activated: Boolean, \r\n $environment: String, \r\n $_component: String) {\r\n domain(\r\n _id: $_id, \r\n name: $name, \r\n activated: $activated, \r\n environment: $environment,\r\n _component: $_component\r\n ) {\r\n _id\r\n name\r\n version\r\n description\r\n statusByEnv {\r\n env\r\n value\r\n }\r\n activated\r\n group {\r\n _id\r\n name\r\n description\r\n activated\r\n statusByEnv {\r\n env\r\n value\r\n }\r\n config {\r\n _id\r\n key\r\n description\r\n activated\r\n statusByEnv {\r\n env\r\n value\r\n }\r\n strategies {\r\n _id\r\n strategy\r\n activated\r\n statusByEnv {\r\n env\r\n value\r\n }\r\n operation\r\n values\r\n }\r\n relay {\r\n type\r\n method\r\n endpoint\r\n description\r\n activated\r\n statusByEnv {\r\n env\r\n value\r\n }\r\n }\r\n components\r\n }\r\n }\r\n }\r\n}",
"variables": "{\r\n \"_id\": \"5e44eb76916dd10048d72542\",\r\n \"activated\": true,\r\n \"environment\": \"\",\r\n \"_component\": \"\"\r\n}"
}
},
Expand Down
12 changes: 5 additions & 7 deletions src/client/configuration-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,13 @@ export const strategyType = new GraphQLObjectType({
export const relayType = new GraphQLObjectType({
name: 'Relay',
fields: {
relay_type: {
type: GraphQLString,
resolve: (source) => source.type
type: {
type: GraphQLString
},
relay_method: {
type: GraphQLString,
resolve: (source) => source.method
method: {
type: GraphQLString
},
relay_endpoint: {
endpoint: {
type: GraphQLString,
resolve: (source, _args, { environment }) => {
return source.endpoint[`${environment}`] === undefined ?
Expand Down
2 changes: 1 addition & 1 deletion src/services/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ export async function verifyRelay(id, env, admin) {
export function isRelayValid(relay) {
const bypass = process.env.RELAY_BYPASS_HTTPS === 'true' || false;

if (bypass || !relay.endpoint) {
if (bypass || !relay?.endpoint) {
return;
}

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

if (content.relay) {
await updateConfigRelay(config._id, processRelay({
type: content.relay.relay_type,
method: content.relay.relay_method,
endpoint: content.relay.relay_endpoint,
type: content.relay.type,
method: content.relay.method,
endpoint: content.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.relay_type,
method: content.relay.relay_method,
type: content.relay.type,
method: content.relay.method,
endpoint: {
[environment]: content.relay.relay_endpoint
[environment]: content.relay.endpoint
},
description: content.relay.description,
activated: {
Expand Down
14 changes: 7 additions & 7 deletions tests/gitops.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ describe('GitOps - Push New', () => {
key: 'NEW_SWITCHER_RELAY',
activated: true,
relay: {
relay_type: RelayTypes.NOTIFICATION,
relay_method: RelayMethods.POST,
relay_endpoint: 'https://localhost:3000',
type: RelayTypes.NOTIFICATION,
method: RelayMethods.POST,
endpoint: 'https://localhost:3000',
description: 'New Relay',
activated: true
}
Expand Down Expand Up @@ -475,9 +475,9 @@ describe('GitOps - Push Changed', () => {
path: ['Group Test', 'TEST_CONFIG_KEY_PRD_QA'],
content: {
relay: {
relay_type: RelayTypes.NOTIFICATION,
relay_method: RelayMethods.POST,
relay_endpoint: 'https://localhost:3000',
type: RelayTypes.NOTIFICATION,
method: RelayMethods.POST,
endpoint: 'https://localhost:3000',
description: 'New Relay',
activated: true
}
Expand Down Expand Up @@ -523,7 +523,7 @@ describe('GitOps - Push Changed', () => {
path: ['Group Test', 'TEST_CONFIG_KEY'],
content: {
relay: {
relay_endpoint: 'http://localhost:3001',
endpoint: 'http://localhost:3001',
activated: false
}
}
Expand Down
12 changes: 6 additions & 6 deletions tests/graphql-utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ export const domainQuery = (where, group, config, strategy) => {
strategy activated operation values statusByEnv { env value }
}
relay {
relay_type
relay_method
relay_endpoint
type
method
endpoint
description
activated
statusByEnv {
Expand Down Expand Up @@ -185,9 +185,9 @@ export const expected102 = `
]
}],
"relay": {
"relay_type": "NOTIFICATION",
"relay_method": "POST",
"relay_endpoint": "http://localhost:3000",
"type": "NOTIFICATION",
"method": "POST",
"endpoint": "http://localhost:3000",
"description": "Test Relay",
"activated": true
}
Expand Down