Update openapi paths to v3

download new spec
remove some options from adding runtime server due to breaking dataplaneapi change
dev
Thomas Lynch 3 months ago
parent a025af0a31
commit 8be70b3fa3
  1. 4
      controllers/certs.js
  2. 4
      controllers/maps.js
  3. 10
      router.js
  4. 4
      specification_openapiv3.js
  5. 2
      stats/worker.js

@ -136,7 +136,7 @@ export async function addCert(req, res, next) {
console.log('Add cert request:', subject, altnames);
const { csr, key, cert, haproxyCert, date } = await acme.generate(subject, altnames, email, ['dns-01', 'http-01']);
const { message, description, file, storage_name: storageName } = await res.locals.postFileAll(
'/v2/services/haproxy/storage/ssl_certificates',
'/v3/services/haproxy/storage/ssl_certificates',
{
method: 'POST',
headers: { 'authorization': res.locals.dataPlane.defaults.headers.authorization },
@ -201,7 +201,7 @@ export async function uploadCert(req, res, next) {
try {
console.log('Upload cert:', existingCert.subject);
const { message } = await res.locals.postFileAll(
'/v2/services/haproxy/storage/ssl_certificates',
'/v3/services/haproxy/storage/ssl_certificates',
{
method: 'POST',
headers: { 'authorization': res.locals.dataPlane.defaults.headers.authorization },

@ -425,7 +425,9 @@ export async function patchMapForm(req, res, next) {
address,
port: parseInt(port),
name: `websrv${freeSlotId}`,
id: `${freeSlotId}`,
// id: `${freeSlotId}`,
// ssl_cafile: '/usr/local/share/ca-certificates/dev-priv-ca/ca-cert.pem',
// ssl_cafile: '@system-ca',
ssl: 'enabled',
verify: 'required',
});

@ -89,7 +89,7 @@ export default function router(server, app) {
`${firstClusterURL.username}:${firstClusterURL.password}`,
).toString('base64');
const api = new OpenAPIClientAxios.default({
//definition: `${firstClusterURL.origin}/v2/specification_openapiv3`,
//definition: `${firstClusterURL.origin}/v3/specification_openapiv3`,
definition,
axiosConfigDefaults: {
httpsAgent: agent,
@ -99,7 +99,7 @@ export default function router(server, app) {
},
});
const apiInstance = api.initSync();
apiInstance.defaults.baseURL = `${firstClusterURL.origin}/v2`;
apiInstance.defaults.baseURL = `${firstClusterURL.origin}/v3`;
res.locals.dataPlane = apiInstance;
async function dataPlaneRetry(operationId, ...args) {
let retryCnt = 0;
@ -119,7 +119,7 @@ export default function router(server, app) {
err,
);
console.trace();
apiInstance.defaults.baseURL = `${clusterUrls[retryCnt].origin}/v2`;
apiInstance.defaults.baseURL = `${clusterUrls[retryCnt].origin}/v3`;
if (retryCnt > clusterUrls.length - 1) {
console.error(
'Max retries exceeded in dataPlaneRetry',
@ -151,10 +151,10 @@ export default function router(server, app) {
},
});
const singleApiInstance = singleApi.initSync();
singleApiInstance.defaults.baseURL = `${clusterUrl.origin}/v2`;
singleApiInstance.defaults.baseURL = `${clusterUrl.origin}/v3`;
return singleApiInstance[operationId](parameters, data, {
...config,
baseUrl: `${clusterUrl.origin}/v2`,
baseUrl: `${clusterUrl.origin}/v3`,
});
}),
);

File diff suppressed because one or more lines are too long

@ -34,7 +34,7 @@ async function fetchStats(host, parameters) {
controller.abort();
}, 10000);
const clusterUrl = new URL(host);
const statsRes = await fetch(`https://${clusterUrl.host}/v2/services/haproxy/stats/native?${new URLSearchParams(parameters).toString()}`, {
const statsRes = await fetch(`https://${clusterUrl.host}/v3/services/haproxy/stats/native?${new URLSearchParams(parameters).toString()}`, {
agent,
headers: { 'authorization': `Basic ${base64Auth}` },
signal,

Loading…
Cancel
Save