Skip to content

Commit

Permalink
Fix qlkube schema generation
Browse files Browse the repository at this point in the history
Remove underscores from schema
  • Loading branch information
QcFe committed May 30, 2024
1 parent 5f8d88b commit 0ba489e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions qlkube/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ main().catch(e =>
logger.error({ error: e.stack }, 'failed to start qlkube server')
);

async function main() {
async function main () {
const inCluster = process.env.IN_CLUSTER !== 'false';
logger.info({ inCluster }, 'cluster mode configured');
const kubeApiUrl = inCluster
? 'https://kubernetes.default.svc'
: 'http://localhost:8001';
const inClusterToken = inCluster
? await fs.readFile(
'/var/run/secrets/kubernetes.io/serviceaccount/token',
'utf8'
)
'/var/run/secrets/kubernetes.io/serviceaccount/token',
'utf8'
)
: '';
const oas = await getOpenApiSpec(kubeApiUrl, inClusterToken);
const targetOas = decorateOpenapi(oas);
Expand All @@ -57,7 +57,7 @@ async function main() {
let msg = JSON.parse(msgs[2]);
try {
msg = JSON.parse(msg);
} catch (_) {}
} catch (_) { }
return {
...error,
message: msg.message,
Expand Down Expand Up @@ -100,7 +100,12 @@ async function main() {
app.use(compression());
app.get('/schema', (req, res) => {
res.setHeader('content-type', 'text/plain');
res.send(printSchema(schema));
res.send(
printSchema(schema)
.split('\n')
.filter(l => l.trim() != '_') // remove empty values from enums
.join('\n')
);
});
app.get('/healthz', (req, res) => {
res.sendStatus(200);
Expand Down

0 comments on commit 0ba489e

Please sign in to comment.