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

Rename --print to --call and make previous name hidden #2487

Merged
merged 4 commits into from
Jun 3, 2024

Conversation

daghack
Copy link
Contributor

@daghack daghack commented May 30, 2024

This adds the --call flag, which allows for calling out to specific frontend method. This is effectively just an alias for the --print experimental flag that both brings the feature out of experimental and renames it, while maintaining backwards compatibility with the already existing flag.

@daghack daghack requested a review from tonistiigi May 30, 2024 20:50
Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we also want to remove experimental from --print (and leave it hidden)

commands/build.go Outdated Show resolved Hide resolved
util/buildflags/printfunc.go Outdated Show resolved Hide resolved
@daghack daghack force-pushed the call-lint branch 2 times, most recently from 59ea5ec to ffd2154 Compare May 30, 2024 21:21
@daghack
Copy link
Contributor Author

daghack commented May 30, 2024

Ah, yes! I think I misunderstood the goal slightly! Updated!

@daghack daghack self-assigned this May 30, 2024
@tonistiigi tonistiigi added this to the v0.15.0 milestone May 31, 2024
@@ -633,12 +628,18 @@ func buildCmd(dockerCli command.Cli, rootOpts *rootOptions, debugConfig *debug.D
cobrautil.MarkFlagsExperimental(flags, "root", "detach", "server-config")
}

flags.StringVar(&options.printFunc, "call", "", "Call a specific frontend method")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is a new flag, we should have some documentation with basic use cases in Examples before having a dedicated page for it on docs website (probably in "Building images" section, WDYT @dvdksn?):

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to also align tests like changing testBuildPrint to testBuildCall in

func testBuildPrint(t *testing.T, sb integration.Sandbox) {
and using this new flag.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned about the name of this flag (and the description of it). I don't expect most users to know what a frontend method is. Buildx should have an opinionated UX, but this seems like the opposite, where it's just a very shallow layer on top of buildkit's frontends.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@colinhemmings - can we get a better description for call? plz

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the user won't know what frontend is. This flag is for setting the build method use. So I would recommend the following help Set method for evaluating build ("check", "outline", "targets").
@dvdksn thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated with the suggested description @colinhemmings 🫡

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description is better. I still have reservations about the flag name. To me, a "call" flag doesn't really imply that this changes the build request type from the default "build an artifact from source" to something else. Neither did the --print flag really (maybe if you squinted hard enough), but that one was experimental. Another flag name that's more descriptive might be:

--mode string          Set method for evaluating build (default "build")

Even with a different flag name, having this switch on the build command is a bit misleading because the user is no longer building anything. Subrequests (as far as my understanding goes) is meant for other tasks, like analyzing source files, "introspection", or some custom output generation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default "build" was added

@tonistiigi tonistiigi changed the title Adds a hidden flag as an alias to the flag Rename --print to --call and make previous name hidden May 31, 2024
@@ -633,12 +628,18 @@ func buildCmd(dockerCli command.Cli, rootOpts *rootOptions, debugConfig *debug.D
cobrautil.MarkFlagsExperimental(flags, "root", "detach", "server-config")
}

flags.StringVar(&options.printFunc, "call", "", `Set method for evaluating build ("check", "outline", "targets")`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we could use subrequests names from BuildKit instead of hardcoding like: https://github.com/moby/buildkit/blob/03d2f9fc4074ea8bf36cea2db8d0829f5442864b/frontend/subrequests/lint/lint.go#L19

Would probably need to move these consts to another package in https://github.com/moby/buildkit/tree/03d2f9fc4074ea8bf36cea2db8d0829f5442864b/frontend/subrequests

Signed-off-by: Talon Bowler <talon.bowler@docker.com>
commands/build.go Outdated Show resolved Hide resolved
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
commands/build.go Outdated Show resolved Hide resolved
This adds an alias for `--check` that causes it to behave the same as
`--call=check`. This is done using `BoolFunc` to call a function when
the option is seen and to set it to the correct value. This should allow
command line flags like `--check --call=targets` to work correctly (even
though they conflict) by making it so the first invocation sets the
print function to `check` and the second overwrites the first. This is
the expected behavior for these types of boolean flags.

`BoolFunc` itself is part of the standard library flags package, but
never seems to have made it into pflag possibly because it was added in
go 1.21.

https://pkg.go.dev/flag#FlagSet.BoolFunc

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's bring this in for RC. If there are still changes we want to make (or keep experimental) we can update before GA.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
@tonistiigi tonistiigi merged commit a24043e into docker:master Jun 3, 2024
104 checks passed
@daghack daghack deleted the call-lint branch June 6, 2024 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants