-
Notifications
You must be signed in to change notification settings - Fork 0
/
eg-client.js
19 lines (17 loc) · 1.02 KB
/
eg-client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const axios = require('axios').default.create({ baseURL: 'http://localhost:9876' });
const debug = require('debug')('eg-ingress-controller:eg-client')
const createServiceEndpoint = (name, serviceName, servicePort) => {
debug(`Creating service endpoint ${name} on ${serviceName}:${servicePort}`)
return axios.put(`/service-endpoints/${encodeURIComponent(name)}`, { url: `http://${serviceName}:${servicePort}` });
}
const createApiEndpoint = (name, host, path) => {
debug(`Creating api endpoint ${name} for ${host} and ${path}`)
return axios.put(`/api-endpoints/${encodeURIComponent(name)}`, { host, path });
}
const createPipelineWithProxyPolicy = (uid, name, serviceEndpoint, apiEndpoint) => {
debug(`Creating pipeline ${name} from ${apiEndpoint} proxied to ${apiEndpoint}`)
return axios.put(`/pipelines/${encodeURIComponent(name)}`,
{ uid, apiEndpoints: [apiEndpoint], policies: [{ proxy: [{ action: { serviceEndpoint } }] }] }
);
}
module.exports = { createServiceEndpoint, createApiEndpoint, createPipelineWithProxyPolicy };