Skip to content

Auto-generate custom role permissions reference from IAM metadata - #26336

Merged
dvdksn merged 6 commits into
docker:mainfrom
gmondello:gmondello/sync-custom-role-permissions
Oct 29, 2026
Merged

dvdksn merged 6 commits into
docker:mainfrom
gmondello:gmondello/sync-custom-role-permissions

Conversation

@gmondello

@gmondello gmondello commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Replaces the manual edits we make to this page whenever a custom-role permission is added or renamed with a synced data file + Hugo shortcode. The source of truth is custom-role-metadata.yaml in docker/iam-services.

What's in this PR

  • data/custom_role_permissions.yaml: the upstream YAML, vendored verbatim from iam-services main.
  • layouts/_shortcodes/custom-role-permissions.html and .markdown.md: render one section per group, with a Permission/Description table, for both HTML and Markdown output. Cells escape |. The build fails with the group and permission name if a group, name or description is missing. The page calls it as {{% custom-role-permissions %}} so the headings stay in the page table of contents.
  • permissions-reference.md: the generated region is replaced by the shortcode call. Intro and "Next steps" stay hand-maintained.
  • .github/workflows/sync-custom-role-permissions.yml: workflow_dispatch (with a ref input) that fetches the YAML at that ref, writes it to data/, and opens a PR via peter-evans/create-pull-request. Site builds never need access to the private upstream repo.
  • .prettierignore: excludes the shortcode, because it emits Markdown and Prettier's go-template plugin reflows the table.

The Node generator, hand-rolled YAML parser and generation markers are removed.

How the automation fires

A companion workflow in docker/iam-services (PR #1175) triggers this one whenever custom-role-metadata.yaml changes on main. The result is always a PR for review, so nothing publishes automatically.

Opt out of any given change: close the generated PR; it re-opens on the next source change.

Testing

Built the full site with Hugo 0.163.0. HTML and Markdown output both contain the same 32 permissions in 8 tables, the section anchors and table of contents are intact, and removing a description fails the build with a clear error. Prettier passes on the YAML and the workflow. The workflow itself has not run.

⚠️ Provisioning needed before this runs (docs maintainers)

  1. HUB_PLATFORM_APP_ID / HUB_PLATFORM_APP_PRIVATE_KEY secrets present in this repo, with the GitHub App installed here (PR-write) and granted contents-read on docker/iam-services. (Same app already used by iam-services ↔ frontends sync.)
  2. A workflow file added via a fork PR won't auto-run, so a maintainer needs to land/enable it.

🤖 Generated with Claude Code

Adds a generator + workflow that rebuild the custom-role permissions
reference from custom-role-metadata.yaml in docker/iam-services (the
source of truth), replacing the manual updates done by hand.

- scripts/generate-custom-role-permissions.mjs rewrites the tables
  between generation markers; frontmatter, intro, and "Next steps" are
  hand-maintained.
- .github/workflows/sync-custom-role-permissions.yml regenerates the
  page and opens a PR when triggered by docker/iam-services.

The regenerated page adds the Licensing and Cloud Sandboxes sections and
the DHI "Manage customizations" row (from iam-services#1172 and docker#1173),
superseding the manual docker#26324.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@netlify

netlify Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for docsdocker ready!

Name Link
🔨 Latest commit 87f8dee
🔍 Latest deploy log https://app.netlify.com/projects/docsdocker/deploys/6ae21e40d3204b10d3bfaf82
😎 Deploy Preview https://deploy-preview-26336--docsdocker.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added area/security area/release Relates to CI or deployment ci ci updates labels Oct 12, 2026
@gmondello
gmondello marked this pull request as ready for review October 14, 2026 14:37
@akristen
akristen requested review from dvdksn and removed request for aevesdocker October 15, 2026 20:58
@dvdksn

dvdksn commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Could this follow the existing Hugo data/template approach? The CLI reference already renders structured data through hugo.Data, and other shortcodes use transform.Unmarshal.

The sync workflow could vendor the upstream YAML into data/, with a shortcode or layout rendering the permission tables in both HTML and Markdown output. That would keep the surrounding prose hand-maintained without needing a custom YAML parser, table formatter, or generation markers.

For example, the Markdown rendering could look roughly like this, with the YAML stored at data/custom_role_permissions.yaml:

{{/* Pseudocode: validate the expected structure and escape table cells. */}}
{{ range hugo.Data.custom_role_permissions.groups }}
## {{ .name }}

| Permission | Description |
| :--------- | :---------- |
{{ range .relations }}
| {{ .name }} | {{ .description }} |
{{ end }}
{{ end }}

The page could invoke the shortcode between its introduction and next steps, with a corresponding HTML renderer. The workflow would only fetch the YAML and open a PR containing the data update, so builds wouldn't need access to the private upstream repository.

Separately, the upstream metadata needs a description correction: “Manage organization access tokens” describes creating, updating, and deleting repositories, while model.fga connects permset-access-token-write to organization access-token read/write/delete operations. That error already exists in the docs; it should be corrected at the source before syncing the descriptions automatically.

Generated by Codex

@gmondello

Copy link
Copy Markdown
Contributor Author

Separately, the upstream metadata needs a description correction: “Manage organization access tokens” describes creating, updating, and deleting repositories, while model.fga connects permset-access-token-write to organization access-token read/write/delete operations. That error already exists in the docs; it should be corrected at the source before syncing the descriptions automatically.

This was fixed in https://github.com/docker/iam-services/pull/1181

Replace the Node generator and generation markers with a data file and a
custom-role-permissions shortcode, following the existing hugo.Data approach.

The sync workflow now only vendors custom-role-metadata.yaml into
data/custom_role_permissions.yaml. The shortcode renders the tables for both
HTML and Markdown output and fails the build on missing names or
descriptions. Exclude the Markdown-emitting shortcode from Prettier.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the hugo Updates related to hugo label Oct 23, 2026
gmondello and others added 3 commits October 23, 2026 14:55
Take main's version of the page so the upcoming merge of main is conflict-free. The next commit swaps the tables for the shortcode.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…rtcode

Replace the hand-maintained tables from main with the shortcode call. Keeps main's updated front matter and intro.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@gmondello

gmondello commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Could this follow the existing Hugo data/template approach?

Thanks for the review, @dvdksn. I've followed your steer. Mind taking another look? In particular I am not sure about the .prettierignore piece 🤷

Cc: @akristen

| Permission | Description |
| :------------------ | :------------------------------------ |
| Use Cloud Sandboxes | Create and use Docker Cloud Sandboxes |
{{% custom-role-permissions %}}

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.

Could this use an inline shortcode instead? This rendering is specific to one page, so keeping it here would avoid two identical shortcode templates and the Prettier exception. Inline shortcodes are already enabled in this repo.

For example, move the existing template body into this page:

{{% custom_role_permissions.inline %}}
{{- $data := hugo.Data.custom_role_permissions -}}
{{/* Existing validation and table-rendering logic goes here. */}}
{{% /custom_role_permissions.inline %}}

Keep the existing validation and pipe escaping, but omit the introductory template comment: its literal shortcode example is interpreted as nesting inside an inline shortcode.

I tested this with the PR's data and the site's Markdown output template: all 32 permissions render in eight tables in both formats, the HTML table of contents includes the headings, and a missing description still fails the build.

Generated by Codex

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@dvdksn thanks. Addressed in 87f8dee

@gmondello
gmondello requested a review from dvdksn October 28, 2026 16:12

@dvdksn dvdksn 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.

LGTM!

@dvdksn
dvdksn merged commit ae41294 into docker:main Oct 29, 2026
17 checks passed
@akristen

Copy link
Copy Markdown
Contributor

Yay! This is awesome. Thank you so much @dvdksn and @gmondello!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/release Relates to CI or deployment area/security ci ci updates hugo Updates related to hugo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants