Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI-1103: Fix #1558: Notification arg formats #1567

Merged
merged 9 commits into from
Jul 14, 2023

Conversation

danepowell
Copy link
Contributor

Motivation

Fixes #1558

Proposed changes

Anywhere that a notification UUID is required as argument, support passing a notification object or URL as well. This basically generalizes the getNotificationUuid logic in app:task-wait to all commands.

Testing steps

  1. Follow the contribution guide to set up your development environment or download a pre-built acli.phar for this PR.
  2. Clear the kernel cache to pick up new and changed commands: ./bin/acli ckc
  3. Try acli app:task-wait with various forms of arguments to ensure they still work:
# Notifications object response
wacli app:task-wait "$(acli api:environments:domain-clear-caches pipelinesvalidation2.dev pipelinesvalidation2dev.prod.acquia-sites.com)"
# Notification UUID
wacli app:task-wait 227eccb1-3345-4a2d-b042-eddd56a78ed7
# Notification URL
wacli app:task-wait https:\/\/cloud.acquia.com\/api\/notifications\/64df4412-20fa-4489-8cbf-1e73095d03eb

@cdubz could you please help test and let me know if it satisfies your request? If you follow the steps above, you can find a pre-built version of CLI for this PR to test with, or you can build it yourself.

@cdubz
Copy link
Contributor

cdubz commented Jul 10, 2023

@danepowell thanks for picking this up! This does exactly what I'm looking for and will eliminate a lot of complexity in my CI processes (:

I think there is just one small issue to address -- if I give task-wait an input that is not a valid UUID or notification URL there will be a PHP fatal error in most cases because the code will get all the way to the URL check where it checks for $urlParts[5] without ensuring that array index exists. So we get:

PHP Warning:  Undefined array key 5 in phar:///src/Command/CommandBase.php on line 1068
PHP Fatal error:  Uncaught TypeError: Acquia\Cli\Command\CommandBase::validateUuid(): Argument #1 ($uuid) must be of type string, null given, called in phar:///src/Command/CommandBase.php on line 1069 and defined in phar:///src/Command/CommandBase.php:726

If that can be avoided it will just end up at the generic "Notification format is not one of UUID, JSON response, or URL" which seems fine.

@codecov
Copy link

codecov bot commented Jul 11, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.02 🎉

Comparison is base (17d93cd) 91.75% compared to head (db131f9) 91.77%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1567      +/-   ##
============================================
+ Coverage     91.75%   91.77%   +0.02%     
- Complexity     1657     1663       +6     
============================================
  Files           110      110              
  Lines          5942     5957      +15     
============================================
+ Hits           5452     5467      +15     
  Misses          490      490              
Impacted Files Coverage Δ
src/Command/App/TaskWaitCommand.php 100.00% <100.00%> (ø)
src/Command/CommandBase.php 94.32% <100.00%> (+0.18%) ⬆️
src/Command/Env/EnvCertCreateCommand.php 100.00% <100.00%> (ø)
src/Command/Env/EnvCreateCommand.php 100.00% <100.00%> (ø)
src/Command/Env/EnvMirrorCommand.php 97.87% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@danepowell
Copy link
Contributor Author

Thanks for the feedback! I fixed that and a few other bugs. Feel free to hammer on the new version, otherwise I'll merge this after getting coverage up.

@danepowell danepowell merged commit 4dc1a18 into acquia:main Jul 14, 2023
12 checks passed
@danepowell danepowell deleted the CLI-1103 branch September 20, 2024 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI-1103: Support notification URLs/JSON strings as input for commands accepting a notification UUID
2 participants