Skip to content

Commit

Permalink
Merge pull request #2430 from jda258/fix-apply
Browse files Browse the repository at this point in the history
frontend: allow apply with update permissions
  • Loading branch information
joaquimrocha authored Oct 18, 2024
2 parents afdf861 + f4be477 commit 812de80
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions frontend/src/lib/k8s/api/v1/apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ export async function apply<T extends KubeObjectInterface>(
delete bodyToApply.metadata.resourceVersion;
return await apiEndpoint.post(bodyToApply, {}, cluster!);
} catch (err) {
// Check to see if failed because the record already exists.
// If the failure isn't a 409 (i.e. Confilct), just rethrow.
if ((err as ApiError).status !== 409) throw err;
// We had a conflict or cannot create. Try a PUT in case the resource already exists.
const errorCode = (err as ApiError).status;
if (errorCode !== 409 && errorCode !== 403) throw err;

// Preserve the resourceVersion if its an update request
bodyToApply.metadata.resourceVersion = resourceVersion;
Expand Down

0 comments on commit 812de80

Please sign in to comment.