Skip to content

Feat: Use sandbox id by default for generation commands #669

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

Conversation

sdstolworthy
Copy link
Contributor

Issue #, if available:

Description of changes:
See #605 for previous comments.

This commit genericizes the Fallback resolver somewhat, accepting a default resolver and a fallback resolver.

Additionally, BackendIdentifierResolver['resolve'] can now return undefined, addressing the comment thread here: #605 (comment).

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

changeset-bot bot commented Nov 16, 2023

🦋 Changeset detected

Latest commit: be7c8a2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@aws-amplify/backend-cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

sobolk
sobolk previously approved these changes Nov 16, 2023
@@ -6,6 +6,13 @@ type BackendIdentifierParameters = {
appId?: string;
branch?: string;
};

export type BackendIdentityResolver = {
Copy link
Contributor

@edwardfoyle edwardfoyle Nov 16, 2023

Choose a reason for hiding this comment

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

Having BackendIdentifierResolver and BackendIdentityResolver is confusing. It's difficult to know what the difference between each is. Could we have a single BackendIdentifierResolver type with two implementation: one that resolves a single type of BackendId and another that goes through the fallback chain?

If that proves to be too much refactoring, I think I'd rather just add the sandbox fallback directly to the existing BackendIdentifierResolver

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/**
* Resolves the backend id when branch or stack is passed as an arg, otherwise returns a sandbox backend identifier
*/
export class BackendIdentifierResolverWithFallback {
Copy link
Contributor

Choose a reason for hiding this comment

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

should this implement BackendIdentityResolver?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

edwardfoyle
edwardfoyle previously approved these changes Nov 16, 2023
Copy link
Contributor

@edwardfoyle edwardfoyle left a comment

Choose a reason for hiding this comment

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

Nice, much clearer! A few nits if you're feeling generous but no blockers

/**
* Resolves the backend id when branch or stack is passed as an arg, otherwise returns a sandbox backend identifier
*/
export class BackendIdentifierResolverWithFallback
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

Suggested change
export class BackendIdentifierResolverWithFallback
export class BackendIdentifierResolverChain

Could even generalize to taking in an array of resolvers and return the first one that doesn't return undefined. But that could also be a load of YAGNI

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went down that road last night and decided it was YAGNI and walked it back

* resolves the backend id, falling back to the sandbox id if there is an error
*/
public resolve = async (
...args: Parameters<BackendIdentifierResolver['resolve']>
Copy link
Contributor

Choose a reason for hiding this comment

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

pretty sure this type will be inferred from the implementing interface. If not, just type it with BackendIdentifierParameters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yep now that this is implementing the interface, this should be removed.

/**
* resolves the backend id, falling back to the sandbox id if there is an error
*/
public resolve = async (
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: public is the default

@sdstolworthy sdstolworthy merged commit dce8a0e into aws-amplify:main Nov 16, 2023
@sdstolworthy sdstolworthy deleted the use-sandbox-id-by-default-for-formgen branch November 16, 2023 20:08
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.

3 participants