Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.

ch-image modify: pretty print and validate parse tree #1908

@lucaudill

Description

@lucaudill

PR #1408 adds ch-image modify to modify existing images interactively or non-interactively. In the non-interactive case, the program will create a parse tree under the hood analogous to those produced by parsing Dockerfiles during ch-image build. After parsing a Dockerfile, ch-image build will "pretty print" the resulting parse tree at the verbose level, e.g.

$ ch-image -v build -t foo -f - . << 'EOF'
> FROM almalinux:8
> RUN echo foo
> EOF
[...]
   1   1  start
   1   1    dockerfile
   1   1      from_
   1   6        image_ref
   1   6           IMAGE_REF almalinux:8
   2   1      run
   2   5        run_shell
   2   5           LINE_CHUNK echo foo
[...]
grown in 2 instructions: foo

The way we construct the parse tree under the hood is not amicable to pretty printing, which also means that we can't easily validate parse trees in the test suite. We should:

  1. Change how we construct ch-image modify parse trees so they can be pretty printed, and
  2. Use pretty printing to validate that one or more example trees are what we expect as part of the test suite

Note that I'm deferring this as a future issue so it doesn't further delay the PR.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions