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

refactor(codepipeline): introduce IAction and unify the Action.bind() signature #3012

Merged
merged 5 commits into from
Jun 24, 2019

Conversation

skinny85
Copy link
Contributor

@skinny85 skinny85 commented Jun 23, 2019

This brings the Action bind() API in line with our conventions.

It also introduces an IAction interface for those who want to work with the low-level Action interface.
The Action class has been moved from the aws-codepipeline to the aws-codepipeline-actions module.

This API is much more flexible, and I show the capabilities by changing the implementation of the PipelineDeployStackAction from @app-delivery.

BREAKING CHANGE:

  • app-delivery: PipelineDeployStackAction is now a codepipeline.IAction instead of a Construct.

Please read the contribution guidelines and follow the pull-request checklist.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license


@skinny85 skinny85 requested a review from eladb June 23, 2019 09:26
@skinny85 skinny85 requested review from RomainMuller and a team as code owners June 23, 2019 09:26
@@ -12,3 +12,4 @@ export * from './lambda/invoke-action';
export * from './manual-approval-action';
export * from './s3/deploy-action';
export * from './s3/source-action';
export * from './action'; // for some reason, JSII fails building the module without exporting this class
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 actually don't want to export this class - but if I don't, JSII fails building with an error. Any ideas how to sidestep that...?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Corrected in the newest revision.

Copy link
Contributor Author

@skinny85 skinny85 Jun 24, 2019

Choose a reason for hiding this comment

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

My mistake - it is not in fact resolved. When I marked the class as @internal, the build for @aws-codepipeline succeeded, but then @app-delivery failed saying the CloudFormation Actions don't implement the IAction interface. So I reverted the change, and I'm back to exporting the class.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's mark it as @experimental for now and we'll figure it out

@eladb eladb changed the title refactor(codepipeline): unify the Action bind() signature, and introd… refactor(codepipeline): introduce IAction and unify the Action.bind() signature Jun 24, 2019
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

Some minor comments that we should address after merge

/**
* Low-level class for generic CodePipeline Actions.
*/
export abstract class Action implements codepipeline.IAction {
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: probably should be called ActionBase

protected abstract bound(scope: Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions):
codepipeline.ActionConfig;

private get pipeline(): codepipeline.IPipeline {
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: seems like these are only used in onStateChange so I'd just move this code in there, and simplify (it's probably sufficient to check if this._pipeline is undefined).


/**
* Low-level class for generic CodePipeline Actions.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: this is internal right? We are settling on a convention where the file name of internal classes will begin with _

return this.bound(scope, stage, options);
}

public onStateChange(name: string, target?: events.IRuleTarget, options?: events.RuleProps) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Something tells me onStateChange should not be here. Without it, we basically don't need ActionBase and it will greatly simplify things. But that's okay... Not that important.

@@ -218,27 +236,12 @@ interface CloudFormationDeployActionProps extends CloudFormationActionProps {
*/
abstract class CloudFormationDeployAction extends CloudFormationAction {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a Base suffix (should be the convention for abstract base classes)

@@ -12,3 +12,4 @@ export * from './lambda/invoke-action';
export * from './manual-approval-action';
export * from './s3/deploy-action';
export * from './s3/source-action';
export * from './action'; // for some reason, JSII fails building the module without exporting this class
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's mark it as @experimental for now and we'll figure it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants