Skip to content

Commit

Permalink
feat(client-ecr): Add support for Dualstack Endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
awstools committed Dec 26, 2024
1 parent 97570d2 commit aac320c
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 897 deletions.
11 changes: 4 additions & 7 deletions clients/client-ecr/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",
};
};

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/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
42 changes: 16 additions & 26 deletions clients/client-ecr/src/endpoint/ruleset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,20 @@ import { RuleSetObject } from "@smithy/types";
or see "smithy.rules#endpointRuleSet"
in codegen/sdk-codegen/aws-models/ecr.json */

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

0 comments on commit aac320c

Please sign in to comment.