-
Notifications
You must be signed in to change notification settings - Fork 4.3k
refactor(cli): resource-import uses IoHost #33412
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some minor refactoring to make the code more human readable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This review is outdated)
e3322f5 to
05df617
Compare
Codecov ReportAttention: Patch coverage is
❌ Your patch status has failed because the patch coverage (71.92%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #33412 +/- ##
==========================================
- Coverage 80.90% 80.90% -0.01%
==========================================
Files 236 238 +2
Lines 14261 14287 +26
Branches 2493 2495 +2
==========================================
+ Hits 11538 11559 +21
- Misses 2438 2442 +4
- Partials 285 286 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
| action: ToolkitAction; | ||
| } | ||
|
|
||
| export interface ImportDeploymentOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made this an explicit copy to limit the interface to a small subset of expected options.
|
|
||
| constructor(private readonly props: CdkToolkitProps) { | ||
| this.ioHost = props.ioHost ?? CliIoHost.instance(); | ||
| this.toolkitStackName = props.toolkitStackName ?? DEFAULT_TOOLKIT_STACK_NAME; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made this a class property to mimic behavior in new toolkit and to provide a fallback when an action option is unset. In practice, the class toolkitStackName and action option toolkitStackName will be the same in the CLI. Will clean this up in a later follow-up PR.
| ioHost: this.ioHost, | ||
| action: 'diff', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would love to use the withAction pattern here, but I don't to duplicate code. Will revisit this after the CLI split.
321f073 to
ffe21fd
Compare
ffe21fd to
4fcc061
Compare
| * | ||
| * @default CDKToolkit | ||
| */ | ||
| readonly toolkitStackName?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in favor of the same option on the Toolkit.
kaizencc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor comments otherwise looks good
| : ' ✅ %s'; | ||
|
|
||
| success('\n' + message, this.stack.displayName); | ||
| await this.ioHost.notify(info(this.action, '\n' + chalk.green(format(message, this.stack.displayName)))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did we do away with the success helper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting rid of all helpers with implicit formatting.
| @@ -0,0 +1,2 @@ | |||
| export * from './importer'; | |||
| export * from './migrator'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sort of a meta question -- is there a way to block us from importing directly from the file itself when we have an index.ts?
i want to disawllow import * as blah from 'aws-cdk/lib/api/resource-inport/importer'; in favor of import * as blah from 'aws-cdk/lib/api/resource-import'; in this case, so that we don't have multiple ways of doing the same thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could write an eslint rule for it, might need a plugin. There can be good reasons to import directly though. My current concern is that anything outside of api should only import form the barrel files. Within api I don't mind so much.
| * | ||
| * @default CDKToolkit | ||
| */ | ||
| readonly toolkitStackName: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this where you're pointing to when you say "makes toolkitStackName a mandatory option"? outside of 'mandatory option' feeling like an oxymoron, i'm curious why that decision was made and what it means to have a mandatory option with a default.
when i first read 'mandatory option' i thought you meant that you were mandating toolkitStackName as an option for cli option bags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's mandatory on the Toolkit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outside of 'mandatory option' feeling like an oxymoron
I guess it's more of a forced choice. You do have options, but you are mandated to pick one. I'm open to learn about better language choices though!
| const importable = await importer.askForResourceIdentifiers(additions); | ||
| await importer.importResourcesFromMap(importable, {}); | ||
| await importer.importResourcesFromMap(importable, { | ||
| toolkitStackName: 'CDKToolkit', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like this is required now. similar to the other comment, im iffy on why that's necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. We currently have toolkitStackName passed through from the CLI Action options all the way down and at every level it's optional. A few times when the value is needed we add a default fallback. I'm annoyed that this exists so many times.
But it's even worse - it doesn't even look used.
| * | ||
| * @default CDKToolkit | ||
| */ | ||
| toolkitStackName?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kaizencc This is the new option on the toolkit itself. Already exists on the new toolkit.
|
➡️ PR build request submitted to A maintainer must now check the pipeline and add the |
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Comments on closed issues and PRs are hard for our team to see. |
Issue
Relates to #32292
Description of changes
ResourceImporterandResourceMigratorinto a new api submoduleImportDeploymentOptionsoptions that only expose actually used deployment options, it is used for bothResourceImporterandResourceMigratorIoHostfor all loggingDescribe any new or updated permissions being added
n/a
Description of how you validated changes
Existing tests and cli-integ tests
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license