Skip to content

Commit

Permalink
chore: fix build break caused by exported deprecated functions (backp…
Browse files Browse the repository at this point in the history
…ort #17719) (#17720)

This is an automatic backport of pull request #17719 done by [Mergify](https://mergify.com).


---


<details>
<summary>Mergify commands and options</summary>

<br />

More conditions and actions can be found in the [documentation](https://docs.mergify.com/).

You can also trigger Mergify actions by commenting on this pull request:

- `@Mergifyio refresh` will re-evaluate the rules
- `@Mergifyio rebase` will rebase this PR on its base branch
- `@Mergifyio update` will merge the base branch into this PR
- `@Mergifyio backport <destination>` will backport this PR on `<destination>` branch

Additionally, on Mergify [dashboard](https://dashboard.mergify.com/) you can:

- look at your merge queues
- generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.com
</details>
  • Loading branch information
mergify[bot] authored Nov 25, 2021
1 parent 9398f37 commit cb468f9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ export class ApplicationListenerRule extends Construct {
* @internal
* @deprecated
*/
export function validateFixedResponse(fixedResponse: FixedResponse) {
function validateFixedResponse(fixedResponse: FixedResponse) {
if (fixedResponse.statusCode && !/^(2|4|5)\d\d$/.test(fixedResponse.statusCode)) {
throw new Error('`statusCode` must be 2XX, 4XX or 5XX.');
}
Expand All @@ -406,7 +406,7 @@ export function validateFixedResponse(fixedResponse: FixedResponse) {
* @internal
* @deprecated
*/
export function validateRedirectResponse(redirectResponse: RedirectResponse) {
function validateRedirectResponse(redirectResponse: RedirectResponse) {
if (redirectResponse.protocol && !/^(HTTPS?|#\{protocol\})$/i.test(redirectResponse.protocol)) {
throw new Error('`protocol` must be HTTP, HTTPS, or #{protocol}.');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { IListenerCertificate, ListenerCertificate } from '../shared/listener-ce
import { determineProtocolAndPort } from '../shared/util';
import { ListenerAction } from './application-listener-action';
import { ApplicationListenerCertificate } from './application-listener-certificate';
import { ApplicationListenerRule, FixedResponse, RedirectResponse, validateFixedResponse, validateRedirectResponse } from './application-listener-rule';
import { ApplicationListenerRule, FixedResponse, RedirectResponse } from './application-listener-rule';
import { IApplicationLoadBalancer } from './application-load-balancer';
import { ApplicationTargetGroup, IApplicationLoadBalancerTarget, IApplicationTargetGroup } from './application-target-group';
import { ListenerCondition } from './conditions';
Expand Down Expand Up @@ -377,7 +377,18 @@ export class ApplicationListener extends BaseListener implements IApplicationLis
messageBody: props.messageBody,
};

validateFixedResponse(fixedResponse);
/**
* NOTE - Copy/pasted from `application-listener-rule.ts#validateFixedResponse`.
* This was previously a deprecated, exported function, which caused issues with jsii's strip-deprecated functionality.
* Inlining the duplication functionality in v2 only (for now).
*/
if (fixedResponse.statusCode && !/^(2|4|5)\d\d$/.test(fixedResponse.statusCode)) {
throw new Error('`statusCode` must be 2XX, 4XX or 5XX.');
}

if (fixedResponse.messageBody && fixedResponse.messageBody.length > 1024) {
throw new Error('`messageBody` cannot have more than 1024 characters.');
}

if (props.priority) {
new ApplicationListenerRule(this, id + 'Rule', {
Expand Down Expand Up @@ -410,7 +421,18 @@ export class ApplicationListener extends BaseListener implements IApplicationLis
statusCode: props.statusCode,
};

validateRedirectResponse(redirectResponse);
/**
* NOTE - Copy/pasted from `application-listener-rule.ts#validateRedirectResponse`.
* This was previously a deprecated, exported function, which caused issues with jsii's strip-deprecated functionality.
* Inlining the duplication functionality in v2 only (for now).
*/
if (redirectResponse.protocol && !/^(HTTPS?|#\{protocol\})$/i.test(redirectResponse.protocol)) {
throw new Error('`protocol` must be HTTP, HTTPS, or #{protocol}.');
}

if (!redirectResponse.statusCode || !/^HTTP_30[12]$/.test(redirectResponse.statusCode)) {
throw new Error('`statusCode` must be HTTP_301 or HTTP_302.');
}

if (props.priority) {
new ApplicationListenerRule(this, id + 'Rule', {
Expand Down

0 comments on commit cb468f9

Please sign in to comment.