Add --against-registry flag for buf breaking#3696
Conversation
|
The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).
|
| ModuleFullName() bufparse.FullName | ||
| ModuleOpaqueID() string |
There was a problem hiding this comment.
Maybe this could be Module() bufmodule.Module and document that it may be nil? From the docs it seems like the Module.FullName might be empty (like in Module) not that it isn't a Module, as the opaque ID can be empty.
There was a problem hiding this comment.
The OpaqueID should always be present:
buf/private/bufpkg/bufmodule/module.go
Lines 42 to 60 in 37b5a2a
My reasoning for not carrying the entire Module around is because the Image should be a compiled version of the Module (and the Module is otherwise lazily loaded) -- so it seems unnecessary... but maybe it's easier?
There was a problem hiding this comment.
Discussed outside of the PR: this is mostly for the case of messageRef, where we resolve the message through the bucket without the Module, so there is no FullName or OpaqueID. In those cases, we are not able to use --against-registry flag.
| return fmt.Errorf( | ||
| "cannot use --%s with unnamed module, %s", | ||
| againstRegistryFlagName, | ||
| imageWithConfig.ModuleOpaqueID(), |
There was a problem hiding this comment.
Do you need to check for empty opaque ID here?
There was a problem hiding this comment.
Re: the comment above, the OpaqueID should always be present, but I could check for an empty and return a different error under those circumstances (and a syserror).
There was a problem hiding this comment.
Adjusted this error for the buffetch.MessageRef case -- given that we don't build the module for those cases, --against-registry basically cannot be used.
This PR adds a
--against-registryflag tobuf breakingthat can beset in lieu of
--against. When--against-registryis set, breaking checksare run against the latest commit on the default label of the remote module
in the registry.
buf breakingwill error if one of--againstor--against-registryisnot set:
buf breaking --against-registrywill error if not all modules in the inputare named (and thus a remote cannot be resolved):
Fixes #3654