feat: add ory get opl - #451
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: Your plan includes up to 1 review per rolling hour; 0 remain after this review. 📝 WalkthroughWalkthroughChangesProject OPL retrieval
Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk: ⚪ Minimal · up to This adds retrieval of Ory Permission Language files and updates related configuration handling; no actionable merge-blocking risk remains after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant CLI as cloudx get opl
participant Project as project services
participant Resolver as oplLocation
participant Fetcher as fetcher
CLI->>Project: load permission configuration
CLI->>Resolver: resolve namespaces.location
Resolver-->>CLI: return OPL location
CLI->>Fetcher: fetch bytes from allowed scheme
Fetcher-->>CLI: return OPL bytes
CLI-->>CLI: write bytes to stdout
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
I think could cause problems when you import it again, will it not? Because the format is not the same? so "keto get project > config.yaml" and then "keto update project --from config.yaml" |
This change does not touch This change only adds I've added a test that verifies Does that make sense? |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmd/cloudx/project/get_namespace_config.go`:
- Around line 80-83: Replace the .CommandPath placeholder in the Example help
text with the literal command invocation, using “$ ory get opl --project ...” so
Cobra displays the intended command directly in default help output.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: cd580244-4eed-4822-a541-1d057a05f03e
📒 Files selected for processing (5)
cmd/cloudx/get.gocmd/cloudx/project/get_namespace_config.gocmd/cloudx/project/get_namespace_config_live_test.gocmd/cloudx/project/get_namespace_config_test.gocmd/cloudx/project/get_permission_config.go
Ory Network does not inline the Ory Permission Language file in the
project config, it stores a pointer to it. `ory get permission-config`
therefore returns `{"namespaces":{"location":"https://...bin"}}` rather
than the namespaces themselves, and there was no way to read the file
back: `ory update opl` could write it, but nothing could retrieve it,
so the config was writable as code but not retrievable as code.
`ory get opl` resolves that location and writes the file to stdout, so
it can be redirected to disk and checked into version control. The
location is resolved with ory/x/fetcher restricted to http, https and
base64: local files are deliberately not allowed, because the location
comes from the API and must never make the CLI read from the
developer's disk. The fetcher also checks the HTTP status code, so an
expired storage link cannot be written to stdout as if it were the OPL
file, honours the command context, and redacts base64 payloads from its
error messages.
Projects still using legacy namespace definitions get a message
pointing at `ory get permission-config` instead of an unhelpful type
error, while an empty legacy list is reported as "nothing configured".
Those paths, and a failing write to stdout, go through
cmdx.FailSilently so cobra does not append a usage dump.
Project services are read through the generated nil-safe accessors:
`ProjectServices.Identity`, `.Permission` and `.Oauth2` are pointers
with omitempty, so a project without the service in question panicked.
`get opl` needs this, and the surrounding commands dereferencing the
same fields are fixed alongside rather than left with a known panic.
Also corrects the `get permission-config` example, which advertised
inline namespaces that the command never returns for an OPL-based
project, and carried a stray character in the sample JSON.
The live test covers the round-trip in both directions against a
dedicated project: `update opl` output must come back out of
`get opl`, and `get opl` output must be accepted by `update opl` again,
which is the direction that matters for checking the permission model
into version control.
Closes #321
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tg5VWFUb7824qkrooUdvBA
Closes #321
Problem
Ory Network does not inline the Ory Permission Language file in the project config — it stores a pointer to it. So
ory get permission-configreturns:{"limit":{},"namespaces":{"location":"https://storage.googleapis.com/bac-gcs-production/xxxxx.bin"}}The reporter's complaint was accurate on two counts:
ory update opl --file ...could write it, but nothing could retrieve it — the permission config was writable as code but not retrievable as code, which breaks the gitops round-trip.{"namespaces":[{"name":"files","id":1}]}, which the command never returns for an OPL-based project, and carried a stray1in the sample JSON.Fix
ory get oplresolves the location and writes the file to stdout, so it can be redirected to disk and checked into version control:The
get permission-configexample now shows what the command actually returns, and points atory get oplfor the file itself.Resolution goes through
ory/x/fetcherrestricted tohttp,httpsandbase64— the same fetcherupdate_namespace_config_test.goalready uses. That choice matters for four reasons:err == nilfrom a plain reader, soory get opl > namespaces.tswould have written<Error><Code>AccessDenied</Code>...into the file and exited 0 — the user commits an error page as their permission model.cmd.Context().base64://payloads are redacted from errors.ory update oplstores the location asbase64://<whole file>; without redaction a decode failure dumps a multi-kilobyte blob to stderr.Two further fixes found in review:
ProjectServices.Permissionis a pointer withomitempty, so a project without a permission service panicked — including in the pre-existingget permission-config, which this branch already touched."namespaces": []) now reports "nothing configured" rather than sending the user to a command that would show them an empty list.Tests
TestOPLLocationcovers location extraction: OPL pointer, legacy list, empty legacy list, missing/null/empty location, nil config.TestOPLLocationIsReadablepins the loader contract — remote reads work, HTTP error responses are not mistaken for the file (httptest 403 with a GCS-style body), and a real local file is refused. The local-file case writes the file first; the earlier version asserted against a non-existent path and would have passed with the allowlist removed.TestUpdateNamespaceConfiggains a round-trip: the OPL uploaded byupdate opl/patchmust come back byte-identical fromget opl, for both project-selection modes. This ran against live staging and passes, so the resolve-and-fetch path is verified end to end and not just at the unit level.🤖 Generated with Claude Code
https://claude.ai/code/session_01JYzGVwAKQ4ormxRHZg1eDu
Summary by CodeRabbit
New Features
cloudx get oplto retrieve a project’s Ory Permission Language (OPL) file.Improvements