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

Fix getMappingInputs removing valid arguments #1169

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions awsx/ecs/container.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

import { normalizeTaskDefinitionContainers, getMappingInputs } from "./containers";

Expand All @@ -32,6 +33,33 @@ describe("port mappings", () => {
expect(inputs).toMatchObject({ containerPort: containerOut, hostPort: hostOut });
},
);

it("returns all valid arguments", () => {
const targetGroup = new aws.lb.TargetGroup("test-tg");

const inputs = getMappingInputs(
{
appProtocol: "grpc",
containerPort: 1,
containerPortRange: "1-65535",
hostPort: 2,
name: "test-mapping-1-2",
protocol: "tcp",
targetGroup,
},
undefined,
);

expect(inputs).toMatchObject({
appProtocol: "grpc",
containerPort: 1,
containerPortRange: "1-65535",
hostPort: 2,
name: "test-mapping-1-2",
protocol: "tcp",
targetGroup,
});
});
});

function promiseOf<T>(output: pulumi.Output<T>): Promise<T> {
Expand Down
3 changes: 2 additions & 1 deletion awsx/ecs/containers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@ function computeContainerDefinition(
}

export function getMappingInputs(
mappingInput: { containerPort?: number; hostPort?: number; protocol?: string },
mappingInput: schema.TaskDefinitionPortMappingInputs,
tgPort: number | undefined,
): schema.TaskDefinitionPortMappingInputs {
return {
...mappingInput,
containerPort: mappingInput.containerPort ?? mappingInput.hostPort ?? tgPort,
hostPort: mappingInput.hostPort ?? tgPort ?? mappingInput.containerPort,
protocol: mappingInput.protocol,
Expand Down
Loading