From 0b0715f42bafa9f91dd42d9a2c0a0545501ae3cc Mon Sep 17 00:00:00 2001 From: shreddedbacon Date: Thu, 9 Nov 2023 08:12:16 +1100 Subject: [PATCH] feat: add buildimage boolean to allopenshift/k8s query --- services/api/src/resources/openshift/resolvers.ts | 12 +++++++++--- services/api/src/typeDefs.js | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/services/api/src/resources/openshift/resolvers.ts b/services/api/src/resources/openshift/resolvers.ts index a982c11f52..da690b6205 100644 --- a/services/api/src/resources/openshift/resolvers.ts +++ b/services/api/src/resources/openshift/resolvers.ts @@ -111,15 +111,21 @@ export const deleteOpenshift: ResolverFn = async ( export const getAllOpenshifts: ResolverFn = async ( root, - { disabled }, + { disabled, buildImage }, { sqlClientPool, hasPermission } ) => { await hasPermission('openshift', 'viewAll'); + let queryBuilder = knex('openshift'); + if (buildImage) { + queryBuilder = queryBuilder.and.whereNot('build_image', ''); + } + if (disabled != null) { - return query(sqlClientPool, knex('openshift').where('disabled', disabled).toString()); + queryBuilder = queryBuilder.where('disabled', disabled); } - return query(sqlClientPool, knex('openshift').toString()); + + return query(sqlClientPool, queryBuilder.toString()); }; export const getOpenshiftByProjectId: ResolverFn = async ( diff --git a/services/api/src/typeDefs.js b/services/api/src/typeDefs.js index 46d1a93ea2..1a1ed0922e 100644 --- a/services/api/src/typeDefs.js +++ b/services/api/src/typeDefs.js @@ -1339,11 +1339,11 @@ const typeDefs = gql` """ Returns all OpenShift Objects """ - allOpenshifts(disabled: Boolean): [Openshift] + allOpenshifts(disabled: Boolean, buildImage: Boolean): [Openshift] """ Returns all Kubernetes Objects """ - allKubernetes(disabled: Boolean): [Kubernetes] + allKubernetes(disabled: Boolean, buildImage: Boolean): [Kubernetes] """ Returns all Environments matching given filter (all if no filter defined) """