diff --git a/node-packages/commons/src/api.ts b/node-packages/commons/src/api.ts index f271fb12ac..ac1526fde6 100644 --- a/node-packages/commons/src/api.ts +++ b/node-packages/commons/src/api.ts @@ -854,11 +854,12 @@ export async function getActiveSystemForProject( export async function getEnvironmentByName( name: string, - projectId: number + projectId: number, + includeDeleted: boolean = true ): Promise { const result = await graphqlapi.query(` { - environmentByName(name: "${name}", project:${projectId}) { + environmentByName(name: "${name}", project:${projectId}, includeDeleted:${includeDeleted}) { id, name, route, @@ -1143,6 +1144,13 @@ export const getOpenShiftInfoForEnvironment = (environment: number): Promise { + let baasBucketName = result.environment.project.envVariables.find(obj => { return obj.name === "LAGOON_BAAS_BUCKET_NAME" }) if (baasBucketName) { @@ -918,25 +918,25 @@ export const createMiscTask = async function(taskData: any) { } // Handle custom backup configurations - let lagoonBaasCustomBackupEndpoint = result.project.envVariables.find(obj => { + let lagoonBaasCustomBackupEndpoint = result.environment.project.envVariables.find(obj => { return obj.name === "LAGOON_BAAS_CUSTOM_BACKUP_ENDPOINT" }) if (lagoonBaasCustomBackupEndpoint) { lagoonBaasCustomBackupEndpoint = lagoonBaasCustomBackupEndpoint.value } - let lagoonBaasCustomBackupBucket = result.project.envVariables.find(obj => { + let lagoonBaasCustomBackupBucket = result.environment.project.envVariables.find(obj => { return obj.name === "LAGOON_BAAS_CUSTOM_BACKUP_BUCKET" }) if (lagoonBaasCustomBackupBucket) { lagoonBaasCustomBackupBucket = lagoonBaasCustomBackupBucket.value } - let lagoonBaasCustomBackupAccessKey = result.project.envVariables.find(obj => { + let lagoonBaasCustomBackupAccessKey = result.environment.project.envVariables.find(obj => { return obj.name === "LAGOON_BAAS_CUSTOM_BACKUP_ACCESS_KEY" }) if (lagoonBaasCustomBackupAccessKey) { lagoonBaasCustomBackupAccessKey = lagoonBaasCustomBackupAccessKey.value } - let lagoonBaasCustomBackupSecretKey = result.project.envVariables.find(obj => { + let lagoonBaasCustomBackupSecretKey = result.environment.project.envVariables.find(obj => { return obj.name === "LAGOON_BAAS_CUSTOM_BACKUP_SECRET_KEY" }) if (lagoonBaasCustomBackupSecretKey) { @@ -960,25 +960,25 @@ export const createMiscTask = async function(taskData: any) { } // Handle custom restore configurations - let lagoonBaasCustomRestoreEndpoint = result.project.envVariables.find(obj => { + let lagoonBaasCustomRestoreEndpoint = result.environment.project.envVariables.find(obj => { return obj.name === "LAGOON_BAAS_CUSTOM_RESTORE_ENDPOINT" }) if (lagoonBaasCustomRestoreEndpoint) { lagoonBaasCustomRestoreEndpoint = lagoonBaasCustomRestoreEndpoint.value } - let lagoonBaasCustomRestoreBucket = result.project.envVariables.find(obj => { + let lagoonBaasCustomRestoreBucket = result.environment.project.envVariables.find(obj => { return obj.name === "LAGOON_BAAS_CUSTOM_RESTORE_BUCKET" }) if (lagoonBaasCustomRestoreBucket) { lagoonBaasCustomRestoreBucket = lagoonBaasCustomRestoreBucket.value } - let lagoonBaasCustomRestoreAccessKey = result.project.envVariables.find(obj => { + let lagoonBaasCustomRestoreAccessKey = result.environment.project.envVariables.find(obj => { return obj.name === "LAGOON_BAAS_CUSTOM_RESTORE_ACCESS_KEY" }) if (lagoonBaasCustomRestoreAccessKey) { lagoonBaasCustomRestoreAccessKey = lagoonBaasCustomRestoreAccessKey.value } - let lagoonBaasCustomRestoreSecretKey = result.project.envVariables.find(obj => { + let lagoonBaasCustomRestoreSecretKey = result.environment.project.envVariables.find(obj => { return obj.name === "LAGOON_BAAS_CUSTOM_RESTORE_SECRET_KEY" }) if (lagoonBaasCustomRestoreSecretKey) { diff --git a/services/api/src/resources/environment/resolvers.ts b/services/api/src/resources/environment/resolvers.ts index ab85c23fdd..a38b4ad2c4 100644 --- a/services/api/src/resources/environment/resolvers.ts +++ b/services/api/src/resources/environment/resolvers.ts @@ -17,13 +17,18 @@ export const getEnvironmentByName: ResolverFn = async ( args, { sqlClientPool, hasPermission } ) => { + + if (args.includeDeleted == undefined) { + args.includeDeleted = true + } const rows = await query( sqlClientPool, `SELECT * FROM environment WHERE name = :name AND - project = :project`, - args + project = :project + ${args.includeDeleted ? '' : 'AND deleted = "0000-00-00 00:00:00"'}`, + args, ); const withK8s = Helpers(sqlClientPool).aliasOpenshiftToK8s(rows); const environment = withK8s[0]; diff --git a/services/api/src/typeDefs.js b/services/api/src/typeDefs.js index aa7b049072..fa2645a72b 100644 --- a/services/api/src/typeDefs.js +++ b/services/api/src/typeDefs.js @@ -1010,7 +1010,7 @@ const typeDefs = gql` Returns Project Object by a given gitUrl (only the first one if there are multiple) """ projectByGitUrl(gitUrl: String!): Project - environmentByName(name: String!, project: Int!): Environment + environmentByName(name: String!, project: Int!, includeDeleted: Boolean): Environment environmentById(id: Int!): Environment """ Returns Environment Object by a given openshiftProjectName