Skip to content

Specify schema for resource permissions - #2674

Merged
kanterov merged 1 commit into
mainfrom
all-permission
Apr 9, 2025
Merged

Specify schema for resource permissions#2674
kanterov merged 1 commit into
mainfrom
all-permission

Conversation

@kanterov

@kanterovkanterov commented Apr 8, 2025

Copy link
Copy Markdown
Collaborator

Changes

Specify JSON schema for resource permissions.

We replace a string with an enum for the level field. Each resource supports different permission-level values and has its own enum.

Bundle root permissions remain as-is, and there is already a translation code that, for example, changes CAN_RUN into CAN_MANAGE_RUN for jobs. However, when CAN_RUN is specified directly on a job, it doesn't get translated, which makes sense. With the correct schema, we are going to avoid the mistake of accidentally specifying CAN_RUN, assuming that it works.

Why

resources.Permission schema allows arbitrary strings while different resources support different permission levels.

Tests

Manually by inspecting JSON schema

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 29 out of 29 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

bundle/config/resources/pipeline.go:13

  • [nitpick] Consider defining constants for PipelinePermissionLevel (similar to those in job.go) to promote consistency and help prevent typos when specifying permission levels for pipelines.
type PipelinePermissionLevel string

@pieternpietern left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks.

Comment threadbundle/config/mutator/resourcemutator/apply_bundle_permissions_test.go Outdated
Comment threadbundle/config/mutator/resourcemutator/filter_current_user_test.go Outdated
import "fmt"

// Permission holds the permission level setting for a single principal.
// Multiple of these can be defined on any resource.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this generic permission struct still used?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we need that for top-level permissions. We can make it enum as well, but it needs more thought

@kanterov
kanterov marked this pull request as ready for review April 8, 2025 18:01
@kanterov

Copy link
Copy Markdown
CollaboratorAuthor

@pietern fixed, please take a look again

@pieternpietern left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

It would be nice to have native enum support so that we can issue errors if a user specifies an unsupported value. With schema support alone, it will produce warnings in an editor, but the CLI still happily accepts invalid values.

@kanterov
kanterov added this pull request to the merge queueApr 9, 2025
Merged via the queue into main with commit 642cccfApr 9, 2025
@kanterov
kanterov deleted the all-permission branch April 9, 2025 09:16
deco-sdk-taggingBot added a commit that referenced this pull request Apr 9, 2025
## Release v0.247.0
### CLI
* Added include/exclude flags support to sync command ([#2650](#2650))
### Bundles
* Added support for model serving endpoints in deployment bind/unbind commands ([#2634](#2634))
* Added include/exclude flags support to bundle sync command ([#2650](#2650))
* Added JSON schema for resource permissions ([#2674](#2674))
* Removed pipeline 'deployment' field from jsonschema ([#2653](#2653))
* Updated JSON schema for deprecated pipeline fields ([#2646](#2646))
* The --config-dir and --source-dir flags for "bundle generate app" are now relative to CWD, not bundle root ([#2683](#2683))
* Reverts [#2549](#2549) to resolve issues with Web Terminal host mismatch ([#2685](#2685))
denik pushed a commit that referenced this pull request May 20, 2026
## Changes
Specify JSON schema for resource permissions.
We replace a string with an enum for the `level` field. Each resource
supports different permission-level values and has its own enum.
Bundle root permissions remain as-is, and there is already a translation
code that, for example, changes `CAN_RUN` into `CAN_MANAGE_RUN` for
jobs. However, when `CAN_RUN` is specified directly on a job, it doesn't
get translated, which makes sense. With the correct schema, we are going
to avoid the mistake of accidentally specifying `CAN_RUN`, assuming that
it works.
## Why
`resources.Permission` schema allows arbitrary strings while different
resources support different permission levels.
## Tests
Manually by inspecting JSON schema
denik pushed a commit that referenced this pull request May 20, 2026
## Release v0.247.0
### CLI
* Added include/exclude flags support to sync command ([#2650](#2650))
### Bundles
* Added support for model serving endpoints in deployment bind/unbind commands ([#2634](#2634))
* Added include/exclude flags support to bundle sync command ([#2650](#2650))
* Added JSON schema for resource permissions ([#2674](#2674))
* Removed pipeline 'deployment' field from jsonschema ([#2653](#2653))
* Updated JSON schema for deprecated pipeline fields ([#2646](#2646))
* The --config-dir and --source-dir flags for "bundle generate app" are now relative to CWD, not bundle root ([#2683](#2683))
* Reverts [#2549](#2549) to resolve issues with Web Terminal host mismatch ([#2685](#2685))
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@kanterov@pietern