Skip to content

Commit

Permalink
Merge pull request #3546 from uselagoon/org-unlimited-quotas-support
Browse files Browse the repository at this point in the history
refactor: support unlimited quota setting
  • Loading branch information
tobybellwood authored Sep 17, 2023
2 parents 42f9242 + fee5c2f commit 32779e3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion services/api/src/resources/environment/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export const addOrUpdateEnvironment: ResolverFn = async (
// check the environment quota, this prevents environments being added directly via the api
const curEnvs = await organizationHelpers(sqlClientPool).getEnvironmentsByOrganizationId(projectOpenshift.organization)
const curOrg = await organizationHelpers(sqlClientPool).getOrganizationById(projectOpenshift.organization)
if (curEnvs.length >= curOrg.quotaEnvironment) {
if (curEnvs.length >= curOrg.quotaEnvironment && curOrg.quotaEnvironment != -1) {
throw new Error(
`Environment would exceed organization environment quota: ${curEnvs.length}/${curOrg.quotaEnvironment}`
);
Expand Down
2 changes: 1 addition & 1 deletion services/api/src/resources/group/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ export const addGroup: ResolverFn = async (
}
}

if (groupCount >= organizationData.quotaGroup) {
if (groupCount >= organizationData.quotaGroup && organizationData.quotaGroup != -1) {
throw new Error(
`This would exceed this organizations group quota; ${groupCount}/${organizationData.quotaGroup}`
);
Expand Down
2 changes: 1 addition & 1 deletion services/api/src/resources/notification/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const checkOrgNotificationPermission = async (hasPermission, input) => {
});

const orgNotifications = await organizationHelpers(sqlClientPool).getNotificationsForOrganizationId(input.organization);
if (orgNotifications.length >= organizationData.quotaNotification) {
if (orgNotifications.length >= organizationData.quotaNotification && organizationData.quotaNotification != -1) {
throw new Error(
`This would exceed this organizations notification quota; ${orgNotifications.length}/${organizationData.quotaNotification}`
);
Expand Down
2 changes: 1 addition & 1 deletion services/api/src/resources/project/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export const addProject = async (
// check the project quota before adding the project
const organization = await organizationHelpers(sqlClientPool).getOrganizationById(input.organization);
const projects = await organizationHelpers(sqlClientPool).getProjectsByOrganizationId(input.organization);
if (projects.length >= organization.quotaProject) {
if (projects.length >= organization.quotaProject && organization.quotaProject != -1) {
throw new Error(
`This would exceed this organizations project quota; ${projects.length}/${organization.quotaProject}`
);
Expand Down

0 comments on commit 32779e3

Please sign in to comment.