Add AD group management to authorization workflow#1619
Open
Conversation
1569a09 to
215b5ab
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds AD group management to the CLI authorization (init) workflow so that, when creating/updating subscription authorization config, the 8 default AD groups are ensured in terraform.tfvars.json alongside the bootstrap identity.
Changes:
- Extend
RequestAuthorizationInputwithprefixandenvShort, and generate default AD group names/specs. - Update the PagoPA authorization adapter to upsert default AD groups (add missing, fix roles, preserve members/custom groups) and support no-op results (no PR created).
- Update CLI output + tests to account for optional PR URLs and new group upsert behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/cli/src/domain/authorization.ts | Adds input fields (prefix, envShort), default AD group specs, and makes AuthorizationResult.url optional for no-op runs. |
| apps/cli/src/adapters/pagopa-technology/authorization.ts | Implements parsing + identity ensure + AD group upsert, and short-circuits PR creation on no-op. |
| apps/cli/src/adapters/pagopa-technology/tests/authorization.test.ts | Adds extensive test coverage for group upsert scenarios and no-op behavior. |
| apps/cli/src/use-cases/tests/request-authorization.test.ts | Updates tests to reflect removal of IdentityAlreadyExistsError. |
| apps/cli/src/adapters/commander/commands/add.ts | Filters out no-op authorization results when printing “Next Steps”. |
| apps/cli/src/adapters/commander/commands/tests/add.test.ts | Updates tests for new prefix/envShort input and no-op handling. |
| .nx/version-plans/version-plan-17760680773N.md | Declares a patch version bump for @pagopa/dx-cli. |
ae94a18 to
f332589
Compare
When creating a PR for bootstrap identity, the CLI now also ensures all default AD groups are present in the subscription's terraform.tfvars.json. Groups are added if missing, roles are updated if they differ from the defaults (preserving members), and custom groups are left untouched. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rework the authorization adapter to avoid leaving dangling branches on no-op runs by reading from main before creating a branch. Also apply the following review suggestions: - Make inner groups zod schema loose to preserve unknown keys - Preserve existing group order in upsertGroups, appending missing defaults at the end instead of rebuilding in a fixed order - Tailor commit/PR title and body to the actual change kind (identity-only, groups-only, or both) - Rename mismatched test title in add.test.ts - Add tests for identity-only messaging, groups-only messaging, group order preservation, and extra-field round-trip safety Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
f332589 to
b0f8be2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements AD group management in the CLI
init(authorization) workflow, re-implementing #1400 on top of the JSON format introduced by #1541.When the CLI creates a PR in
eng-azure-authorizationto add a bootstrap identity, it now also ensures all 8 default AD groups are present in the subscription'sterraform.tfvars.json.Default AD groups
<prefix>-<envShort>-adgroup-{admin,developers,operations,security,technical-project-managers,product-owners,externals,oncall}Closes CES-1658