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

feat(codepipeline-action): add support for externalEntityLink in the manual approval action #5558

Merged
merged 9 commits into from
Jan 8, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export interface ManualApprovalActionProps extends codepipeline.CommonAwsActionP
* Any additional information that you want to include in the notification email message.
*/
readonly additionalInformation?: string;

/**
* URL you want to provide to the reviewer as part of the approval request. The URL must begin with 'http://' or 'https://'.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is that condition ("must begin with 'http://' or 'https://'") checked by the CodePipeline API? Should we add some validation on our side that errors out if that is not the case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@skinny85
I am not sure, i know that the AWS console does this kind of validation. Are there some common examples of this kind of validation in CDK?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@skinny85 - Would something like this work?

    if (this.props.externalEntityLink) {
      const pattern = /^((http|https):\/\/)/;
      if (!pattern.test(this.props.externalEntityLink)) {
        throw Error("'externalEntityLink' - The URL must begin with 'http://' or 'https://'");
      }
    }

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, that could work :) (+ a unit test for this behavior, of course 😃). However, I'd rather not add this validation unless the CodePipeline API performs it as well (I don't think we should disallows things that the API accepts). Can you verify whether the CodePipeline API fails if you provide something that does not start with 'http://' or 'https://'? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@skinny85 - APL does allow for urls without http:// or https://, so i updated the docs to reflect this.

*/
readonly externalEntityLink?: string;
}

/**
Expand Down Expand Up @@ -73,6 +78,7 @@ export class ManualApprovalAction extends Action {
? {
NotificationArn: this._notificationTopic.topicArn,
CustomData: this.props.additionalInformation,
ExternalEntityLink: this.props.externalEntityLink,
}
: undefined,
};
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-codepipeline-actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
"props-default-doc:@aws-cdk/aws-codepipeline-actions.ManualApprovalActionProps.additionalInformation",
"props-default-doc:@aws-cdk/aws-codepipeline-actions.ManualApprovalActionProps.notificationTopic",
"props-default-doc:@aws-cdk/aws-codepipeline-actions.ManualApprovalActionProps.notifyEmails",
"props-default-doc:@aws-cdk/aws-codepipeline-actions.ManualApprovalActionProps.externalEntityLink",
michaelbrewer marked this conversation as resolved.
Show resolved Hide resolved
"props-default-doc:@aws-cdk/aws-codepipeline-actions.S3DeployActionProps.objectKey",
"docs-public-apis:@aws-cdk/aws-codepipeline-actions.S3SourceActionProps.output",
"docs-public-apis:@aws-cdk/aws-codepipeline-actions.GitHubTrigger.NONE",
Expand Down