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

PDE-2981: feature(cli) - Update "promote" and "migrate" to use new endpoint #480

Merged
merged 5 commits into from
Feb 7, 2022

Conversation

standielpls
Copy link
Contributor

@standielpls standielpls commented Feb 1, 2022

Internally points the CLI promote and migrate command to use the new migration endpoint.

These commands currently point to an endpoint that calls out to the new migration endpoint so this is work to remove that indirection.

percent,
name: 'migrate',
from_version: fromVersion,
to_version: toVersion,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

yep!

@standielpls standielpls changed the title PDE-2981 - Update "promote" and "migrate" to use new endpoint PDE-2981: chore(cli) - Update "promote" and "migrate" to use new endpoint Feb 3, 2022
@standielpls
Copy link
Contributor Author

@eliangcs - not sure what testing this looks like but I can supply a screenshot of this working locally when pointing to zapier-staging.com

https://cdn.zappy.app/aa83a9fda53ee99209fd85dc9749cc49.png

@standielpls standielpls marked this pull request as ready for review February 3, 2022 21:07
packages/cli/src/oclif/commands/promote.js Outdated Show resolved Hide resolved
if (changelog) {
body.changelog = changelog;
body.job.changelog = changelog;
Copy link
Contributor

Choose a reason for hiding this comment

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

I know you were just following existing code, but you can move this above for the same effect:

const body = {
      job: {
        name: 'promote',
        to_version: version,
        changelog,
      },
    };

Since it'll be undefined if it's missing, it just works

@@ -15,6 +15,7 @@ class MigrateCommand extends BaseCommand {
const user = this.flags.user;
const fromVersion = this.args.fromVersion;
const toVersion = this.args.toVersion;
const email = this.args.email;
Copy link
Contributor

Choose a reason for hiding this comment

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

This won't quite work. If you look below at MigrateCommand.flags, we only define the user flag. I think if you provide --email, the CLI will error at you.

Because the name email vs user doesn't matter, I'd keep the existing flag name and just save it as email in the request body. That way the flags don't change for our users, but we send the right data to the API. Does that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, makes sense, good catch!

Because the name email vs user doesn't matter

Can you help me locate this for my own learning? I'm tracing where the endpoint builds the payload and find it set here but not sure where it will end up being used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://cdn.zappy.app/eb7c153daa90542ec50c964bdc903dcb.png

nvm! I see now that user is email in this system!

@@ -120,7 +126,7 @@ PromoteCommand.args = [
{
name: 'version',
required: true,
description: 'The version you want promote.',
description: 'The version you want to promote.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch! 🙌

percent,
name: 'migrate',
from_version: fromVersion,
to_version: toVersion,
Copy link
Contributor

Choose a reason for hiding this comment

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

yep!

Copy link
Contributor

@xavdid xavdid left a comment

Choose a reason for hiding this comment

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

This is a great start! There are some things we'll want to fix before we ship, but we're most of the way there.

re: testing- we don't have great unit test coverage on CLI now, so as long as you've done thorough testing against staging/local, we're probably fine. Make sure to test all the args/flags! 😁

@standielpls
Copy link
Contributor Author

@xavdid Good notes, I've tested with the available flags and the commands are working

I've found some logs that indicate the requests went through, but I don't see a "request body" in them. Perhaps this field isn't logged?

@standielpls standielpls force-pushed the pde-2981.promote-migrate-new-endpoint branch from 0e0b72f to 3160a48 Compare February 4, 2022 16:48
Copy link
Contributor

@xavdid xavdid left a comment

Choose a reason for hiding this comment

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

Looks great! had one minor suggestion, but you can also go ahead and merge.

Also- the title of this PR is chore(cli), but that's usually reserved for bumping deps, fixing typos, etc. This is a feature! New and better migrations!

@@ -58,8 +62,12 @@ class MigrateCommand extends BaseCommand {
`Starting migration from ${fromVersion} to ${toVersion} for ${percent}%`
);
}
if (percent) {
body.job.percent_human = percent;
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this can also be included rigtht in the job above, since it's always defined (either from the default or from the user passing it explicitly)

Copy link
Member

@eliangcs eliangcs left a comment

Choose a reason for hiding this comment

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

I tested all the code branches locally, and they all work wonderfully! Nice work!

@standielpls standielpls changed the title PDE-2981: chore(cli) - Update "promote" and "migrate" to use new endpoint PDE-2981: feature(cli) - Update "promote" and "migrate" to use new endpoint Feb 7, 2022
@standielpls standielpls merged commit 6879849 into master Feb 7, 2022
@standielpls standielpls deleted the pde-2981.promote-migrate-new-endpoint branch February 7, 2022 14:38
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.

None yet

3 participants