pack icon indicating copy to clipboard operation
pack copied to clipboard

Add `--dry-run` option to pack commands

Open simonjjones opened this issue 5 years ago • 8 comments

Description

I would like to validate the configuration and intended outcome of a command I plan to run without incurring the cost of executing against real code and resources

Proposed solution

Each pack command can be invoked with a --dry-run argument which:

  • validates the configuration
  • outputs any pack generated logs that would occur during a real execution
  • describes interactions that would happen with dependencies outside of pack (e.g. Invoke this lifecycle phase with these arguments)
  • exits with the exit code that would occur during a real execution (assuming interactions with external dependencies are successful)
  • outputs any other useful information depending on the subcommand being invoked

Describe alternatives you've considered

  • Consumers can currently parse help text to ensure particular commands and arguments or available in their version of pack, and assume their configuration will be successful
  • App developers with large apps, who might incur long waits for commands to run may use a smaller test app to validate commands

Additional context

  • [ ] This feature should be documented somewhere

simonjjones avatar Jun 09 '20 20:06 simonjjones

Should this be supported for all commands, or only for some? For instance, pack version --dry-run wouldn't seem to add much value, while obviously pack build --dry-run or pack rebase --dry-run would.

dfreilich avatar Jun 09 '20 21:06 dfreilich

Could you elaborate on "outputs any pack generated logs that would occur during a real execution"?

Thinking about something like pack build how would the output be generated if it's mostly output of executed buildpacks and from my understanding the buildpack's build binary wouldn't actually execute.

jromero avatar Jun 10 '20 02:06 jromero

This is a really good idea! I agree with @dfreilich (https://github.com/buildpacks/pack/issues/681#issuecomment-641576328) that it's probably not necessary for all of the pack commands. Maybe it's worth being more specific and specifying the expected output of each command (AC with examples of each relevant command).

yaelharel avatar Jun 11 '20 04:06 yaelharel

I think the stateless commands should still run, the solution would still be valid as there are no interactions with external dependencies in those cases.

simonjjones avatar Jun 11 '20 12:06 simonjjones

A pack detect or similar command (with optional json output?) would be pretty neat so that we can report to users what their apps look like before actually building it (useful for platform onboarding).

josegonzalez avatar Jul 21 '21 15:07 josegonzalez

@josegonzalez Agreed. This is an underlying premise with pack-interact-mode.

aemengo avatar Jul 22 '21 03:07 aemengo

@simonjjones @jromero @dfreilich Can we have a little more detail about what the original intent of --dry-run was?

@haliliceylan and I were following the thread and are lost. In the pack build case for example:

  • Does dry-run simply mean run the detect phase?
  • Just about every phase requires creating an ephemeral builder on the daemon, so does that count as "incurring the cost of executing against real code and resources"?
  • How we "exits with the exit code that would occur during a real execution"? Without actually executing?

aemengo avatar Jul 28 '21 15:07 aemengo