Pass the image to `ImagePullPolicy.shouldPull`

Open
#1,537 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 4 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
docker, node.js, typescript
Domain
backend, devtools

Research direction

Start with packages/testcontainers/src/utils/pull-policy.ts, then trace policy use in generic-container.ts, generic-container-builder.ts and docker-compose-environment.ts. Check #1518 for the existing return values before deciding how to handle the compatibility and multiple-image cases. Done means policies receive the relevant image, named outcomes are accepted alongside current values, and the documented call sites handle them consistently.

Written by the indexing model from the issue text.

Description

enhancement minor

What happens

ImagePullPolicy.shouldPull() takes no arguments:

export interface ImagePullPolicy {
  shouldPull(): boolean | "never";
}

A custom policy cannot see which image it is being asked about, so it cannot express rules such as "always pull :latest, use the cache for pinned tags" or "never pull images from the local registry". One policy instance is applied to every image a container, a Dockerfile build or a Compose environment needs.

The return type mixes two booleans with a string: false means "pull if missing", true means "always pull" and "never" means "fail if missing".

Expected

  • shouldPull receives the image, for example shouldPull(image: ImageName).
  • The three outcomes have names, for example "always" | "missing" | "never", accepted alongside the current values.

Where

  • packages/testcontainers/src/utils/pull-policy.ts
  • call sites in generic-container.ts, generic-container-builder.ts and docker-compose-environment.ts

Notes

  • Java's interface is boolean shouldPull(DockerImageName imageName). .NET's policy is a Func<ImageInspectResponse, bool>.
  • Passing an argument is compatible with existing policies, hence minor. Dropping the boolean | "never" return values would be major.
  • Compose and Dockerfile builds resolve several images. Decide what they pass.

Dependencies

  • Nothing blocks this. It can start now.
  • Coordinate with #1518: for the old return values.
Dominant language
TypeScript
Stars
2.7k
Forks
290
Avg merge
4d 1h
Merged PRs (30d)
22

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from testcontainers/testcontainers-node

All issues in testcontainers/testcontainers-node

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.