Skip to content

Add --app-scope option for variables (legacy)#51

Closed
pjcdawkins wants to merge 2 commits intomainfrom
migrate/legacy-pr-1590
Closed

Add --app-scope option for variables (legacy)#51
pjcdawkins wants to merge 2 commits intomainfrom
migrate/legacy-pr-1590

Conversation

@pjcdawkins
Copy link
Copy Markdown
Contributor

Reimplemented from platformsh/legacy-cli#1590 against the 5.x architecture in legacy/.

Adds --app-scope to var:create and var:update, allowing variables to be scoped to specific applications within a project. The option accepts multiple values (--app-scope app1 --app-scope app2), validates app names against the current deployment when one is available, and skips validation when no deployment exists (e.g. inactive environments). The application_scope property already shows in variable:get output without further code changes.

The original PR's diff did not apply because:

  • The 5.x legacy/ tree has no Command/Variable/VariableCommandBase.php; variable form fields now live in Service/VariableCommandUtil::getFields(). The new application_scope ArrayField was added there, with the validator using the lazy $getSelection() callable to reach the project/environment.
  • The listApps() helper was added as a private method on the same service, calling $this->api->getCurrentDeployment() (now a 2-arg signature in 5.x) and catching exceptions in place of the old "throw=false" flag.
  • The integration tests were ported from the now-deleted go-tests/ directory to integration-tests/variable_write_test.go, using t.Cleanup and the existing mockapi helpers (SetCurrentDeployment, MakeHALLinks).

Adds an `--app-scope` option to `var:create` and `var:update`, allowing
variables to be scoped to specific applications within a project.

- The option accepts multiple values: `--app-scope app1 --app-scope app2`.
- App names are validated against the current deployment when one is
  available, and validation is skipped for inactive environments without a
  deployment.
- The new `application_scope` property already shows in `variable:get`
  output without further code changes.

Reimplemented from platformsh/legacy-cli#1590 against the 5.x architecture
in `legacy/`: the field and `listApps()` helper live in
`Service/VariableCommandUtil.php` (the 5.x equivalent of
`Command/Variable/VariableCommandBase.php`), and the integration tests
were ported to `integration-tests/variable_write_test.go` (replacing the
original `go-tests/` location).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 27, 2026 19:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds legacy CLI support for scoping project-level variables to specific applications via a new --app-scope option, aligned with the 5.x legacy/ architecture.

Changes:

  • Introduces an application_scope ArrayField (CLI option --app-scope) for variable create/update flows, with validation against deployed app names when available.
  • Adds deployment-based app-name discovery helper (listApps()) to support validation and safely skip it when a deployment can’t be determined.
  • Ports/extends integration coverage in Go to exercise --app-scope (single, multiple, invalid, and no-deployment scenarios).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
legacy/src/Service/VariableCommandUtil.php Adds the new application_scope field and deployment-aware validation helper for --app-scope.
integration-tests/variable_write_test.go Adds integration tests covering var:create/var:update with --app-scope, including validation skip behavior without a deployment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread legacy/src/Service/VariableCommandUtil.php Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@pjcdawkins
Copy link
Copy Markdown
Contributor Author

pjcdawkins commented Apr 27, 2026

Already included in #19

@pjcdawkins pjcdawkins closed this Apr 27, 2026
Sign up for free to 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.

2 participants