Skip to content

Commit

Permalink
Merge pull request #3789 from uselagoon/storage-calculator-permission
Browse files Browse the repository at this point in the history
refactor: platform-owner storage-calculator field
  • Loading branch information
tobybellwood authored Aug 6, 2024
2 parents bbcd984 + 58c5567 commit 24acd1a
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions services/api/src/resources/project/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,14 @@ export const addProject = async (
const openshiftProjectPattern =
input.kubernetesNamespacePattern || input.openshiftProjectPattern;

// check if a user has permission to disable deployments of a project or not
let deploymentsDisabled = 0;
if (input.deploymentsDisabled) {
if (adminScopes.platformOwner) {
deploymentsDisabled = input.deploymentsDisabled
}
if (input.deploymentsDisabled && !adminScopes.platformOwner) {
// only platform owner can set this, it won't return an error, just ignores the value
delete input.deploymentsDisabled
}

if (input.storageCalc && !adminScopes.platformOwner) {
// only platform owner can set this, it won't return an error, just ignores the value
delete input.storageCalc
}

let buildImage = null;
Expand Down Expand Up @@ -651,6 +653,13 @@ export const updateProject: ResolverFn = async (
}
}

// only platform owner can modify storage calculator
if (storageCalc) {
if (!adminScopes.platformOwner) {
throw new Error('Disabling storage calculator is only available to administrators.');
}
}

if(typeof sharedBaasBucket == "boolean") {
if (!adminScopes.platformOwner) {
throw new Error('Setting shared baas bucket is only available to administrators.');
Expand Down

0 comments on commit 24acd1a

Please sign in to comment.