Skip to content

Commit

Permalink
feat(client-ecr-public): Add support for Dualstack endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
awstools committed Dec 23, 2024
1 parent 22b585a commit f8dab61
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 524 deletions.
11 changes: 4 additions & 7 deletions clients/client-ecr-public/src/endpoint/EndpointParameters.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// smithy-typescript generated code
import { Endpoint, EndpointParameters as __EndpointParameters, EndpointV2, Provider } from "@smithy/types";
import { EndpointParameters as __EndpointParameters, Provider } from "@smithy/types";

/**
* @public
*/
export interface ClientInputEndpointParameters {
region?: string | Provider<string>;
useDualstackEndpoint?: boolean | Provider<boolean>;
useFipsEndpoint?: boolean | Provider<boolean>;
endpoint?: string | Provider<string> | Endpoint | Provider<Endpoint> | EndpointV2 | Provider<EndpointV2>;
useDualstackEndpoint?: boolean | Provider<boolean>;
}

export type ClientResolvedEndpointParameters = ClientInputEndpointParameters & {
Expand All @@ -20,22 +19,20 @@ export const resolveClientEndpointParameters = <T>(
): T & ClientResolvedEndpointParameters => {
return {
...options,
useDualstackEndpoint: options.useDualstackEndpoint ?? false,
useFipsEndpoint: options.useFipsEndpoint ?? false,
useDualstackEndpoint: options.useDualstackEndpoint ?? false,
defaultSigningName: "ecr-public",
};
};

export const commonParams = {
UseFIPS: { type: "builtInParams", name: "useFipsEndpoint" },
Endpoint: { type: "builtInParams", name: "endpoint" },
Region: { type: "builtInParams", name: "region" },
UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" },
} as const;

export interface EndpointParameters extends __EndpointParameters {
Region?: string;
UseDualStack?: boolean;
UseFIPS?: boolean;
Endpoint?: string;
UseDualStack?: boolean;
}
2 changes: 1 addition & 1 deletion clients/client-ecr-public/src/endpoint/endpointResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ruleSet } from "./ruleset";

const cache = new EndpointCache({
size: 50,
params: ["Endpoint", "Region", "UseDualStack", "UseFIPS"],
params: ["Region", "UseDualStack", "UseFIPS"],
});

export const defaultEndpointResolver = (
Expand Down
33 changes: 10 additions & 23 deletions clients/client-ecr-public/src/endpoint/ruleset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,14 @@ import { RuleSetObject } from "@smithy/types";
or see "smithy.rules#endpointRuleSet"
in codegen/sdk-codegen/aws-models/ecr-public.json */

const s="required",
t="fn",
u="argv",
v="ref";
const a=true,
b="isSet",
c="booleanEquals",
d="error",
e="endpoint",
f="tree",
g="PartitionResult",
h={[s]:false,"type":"String"},
i={[s]:true,"default":false,"type":"Boolean"},
j={[v]:"Endpoint"},
k={[t]:c,[u]:[{[v]:"UseFIPS"},true]},
l={[t]:c,[u]:[{[v]:"UseDualStack"},true]},
m={},
n={[t]:"getAttr",[u]:[{[v]:g},"supportsFIPS"]},
o={[t]:c,[u]:[true,{[t]:"getAttr",[u]:[{[v]:g},"supportsDualStack"]}]},
p=[k],
q=[l],
r=[{[v]:"Region"}];
const _data={version:"1.0",parameters:{Region:h,UseDualStack:i,UseFIPS:i,Endpoint:h},rules:[{conditions:[{[t]:b,[u]:[j]}],rules:[{conditions:p,error:"Invalid Configuration: FIPS and custom endpoint are not supported",type:d},{conditions:q,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",type:d},{endpoint:{url:j,properties:m,headers:m},type:e}],type:f},{conditions:[{[t]:b,[u]:r}],rules:[{conditions:[{[t]:"aws.partition",[u]:r,assign:g}],rules:[{conditions:[k,l],rules:[{conditions:[{[t]:c,[u]:[a,n]},o],rules:[{endpoint:{url:"https://api.ecr-public-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:m,headers:m},type:e}],type:f},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",type:d}],type:f},{conditions:p,rules:[{conditions:[{[t]:c,[u]:[n,a]}],rules:[{endpoint:{url:"https://api.ecr-public-fips.{Region}.{PartitionResult#dnsSuffix}",properties:m,headers:m},type:e}],type:f},{error:"FIPS is enabled but this partition does not support FIPS",type:d}],type:f},{conditions:q,rules:[{conditions:[o],rules:[{endpoint:{url:"https://api.ecr-public.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:m,headers:m},type:e}],type:f},{error:"DualStack is enabled but this partition does not support DualStack",type:d}],type:f},{endpoint:{url:"https://api.ecr-public.{Region}.{PartitionResult#dnsSuffix}",properties:m,headers:m},type:e}],type:f}],type:f},{error:"Invalid Configuration: Missing Region",type:d}]};
const a=false,
b=true,
c="PartitionResult",
d="booleanEquals",
e="error",
f="endpoint",
g="tree",
h={"required":true,"default":false,"type":"Boolean"},
i=[{"ref":"Region"}];
const _data={version:"1.0",parameters:{Region:{required:a,type:"String"},UseFIPS:h,UseDualStack:h},rules:[{conditions:[{fn:"isSet",argv:i},{fn:"aws.partition",argv:i,assign:c}],rules:[{conditions:[{fn:d,argv:[{ref:"UseFIPS"},b]}],error:"ECR Public does not support FIPS",type:e},{conditions:[{fn:d,argv:[{ref:"UseDualStack"},b]}],rules:[{conditions:[{fn:d,argv:[b,{fn:"getAttr",argv:[{ref:c},"supportsDualStack"]}]}],rules:[{endpoint:{url:"https://ecr-public.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:{},headers:{}},type:f}],type:g},{error:"Dualstack is enabled but this partition does not support dualstack",type:e}],type:g},{endpoint:{url:"https://api.ecr-public.{Region}.{PartitionResult#dnsSuffix}",properties:{},headers:{}},type:f}],type:g}]};
export const ruleSet: RuleSetObject = _data;
Loading

0 comments on commit f8dab61

Please sign in to comment.