Accept a boolean in the no-argument flag setters

未关闭
#1,530 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 4 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
docker, node.js, typescript
领域
api, testing

调研方向

Start with the listed generic container, builder, Docker Compose environment, and test files; compare the six no-argument setters with the existing boolean setters. Check the related work in #1524 and coordinate the shared TestContainer interface edit with #1529. Done means the flag setters accept an optional boolean defaulting to true, existing calls still work, conditional calls can turn flags off, and tests cover the behavior.

由索引模型根据 Issue 内容生成。

描述

enhancement minor

What happens

On/off settings are spelled two ways.

No argument, can only switch on:

  • GenericContainer.withReuse()
  • GenericContainer.withPrivilegedMode()
  • GenericContainer.withDefaultLogDriver()
  • DockerComposeEnvironment.withBuild()
  • DockerComposeEnvironment.withNoRecreate()
  • GenericContainerBuilder.withBuildkit()

Boolean argument:

  • GenericContainer.withAutoCleanup(boolean)
  • GenericContainer.withAutoRemove(boolean)
  • DockerComposeEnvironment.withAutoCleanup(boolean)
  • GenericContainerBuilder.withCache(boolean)

The no-argument form breaks the chain for conditional settings and cannot undo a setting that a subclass or module turned on:

const container = new GenericContainer(image).withExposedPorts(8080);
if (!process.env.CI) {
  container.withReuse();
}

The modules are split the same way: 6 no-argument flag setters and 4 that take a boolean.

Expected

Flag setters accept an optional boolean that defaults to true, so withReuse() keeps working and withReuse(!process.env.CI) becomes possible.

Where

  • packages/testcontainers/src/generic-container/generic-container.ts
  • packages/testcontainers/src/generic-container/generic-container-builder.ts
  • packages/testcontainers/src/docker-compose-environment/docker-compose-environment.ts
  • packages/testcontainers/src/test-container.ts

Notes

  • Java takes a boolean in both withReuse(boolean reusable) and withPrivilegedMode(boolean mode).
  • Worth adding the convention to the add-module skill.

Dependencies

  • Stack on #1524: both change withNoRecreate.
  • Coordinate with #1529: both edit the TestContainer interface.
主要语言
TypeScript
星标
2.7k
派生
290
平均合并
4 天 1 小时
30 天内合并 PR
22

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

testcontainers/testcontainers-node 的其他 Issue

查看 testcontainers/testcontainers-node 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。