Skip to content

Commit 63d995b

Browse files
authored
Fix curated plugin latest fetching (#3994)
1 parent ea657c1 commit 63d995b

File tree

1 file changed

+20
-0
lines changed
  • private/buf/cmd/buf/command/beta/registry/plugin/pluginpush

1 file changed

+20
-0
lines changed

private/buf/cmd/buf/command/beta/registry/plugin/pluginpush/pluginpush.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,26 @@ func run(
307307
slog.String("name", pluginConfig.Name.IdentityString()),
308308
slog.String("digest", plugin.ContainerImageDigest()),
309309
)
310+
if latestPluginResp == nil {
311+
latestPluginResp, err = service.GetLatestCuratedPlugin(
312+
ctx,
313+
connect.NewRequest(
314+
registryv1alpha1.GetLatestCuratedPluginRequest_builder{
315+
Owner: pluginConfig.Name.Owner(),
316+
Name: pluginConfig.Name.Plugin(),
317+
Version: pluginConfig.PluginVersion,
318+
Revision: 0, // get latest revision for the plugin version.
319+
}.Build(),
320+
),
321+
)
322+
if err != nil {
323+
return fmt.Errorf("unable to fetch latest plugin after AlreadyExists error: %w", err)
324+
}
325+
}
326+
// Ensure the image digest matches.
327+
if latestPluginResp.Msg.GetPlugin().GetContainerImageDigest() != plugin.ContainerImageDigest() {
328+
return fmt.Errorf("a plugin with the same name and version already exists, but with a different image digest (%s). If you want to push a new revision, please retry", latestPluginResp.Msg.GetPlugin().GetContainerImageDigest())
329+
}
310330
curatedPlugin = latestPluginResp.Msg.GetPlugin()
311331
} else {
312332
curatedPlugin = createPluginResp.Msg.GetConfiguration()

0 commit comments

Comments
 (0)