From 38968ae06aaea6f95d2fc153d9f826a3146fb9f7 Mon Sep 17 00:00:00 2001 From: Doria Keung Date: Mon, 9 Dec 2024 18:11:01 -0500 Subject: [PATCH] No need to resolve keys, use refs directly --- .../command/plugin/pluginprune/pluginprune.go | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/private/buf/cmd/buf/command/plugin/pluginprune/pluginprune.go b/private/buf/cmd/buf/command/plugin/pluginprune/pluginprune.go index 304dadfd66..f2dd2769c8 100644 --- a/private/buf/cmd/buf/command/plugin/pluginprune/pluginprune.go +++ b/private/buf/cmd/buf/command/plugin/pluginprune/pluginprune.go @@ -19,6 +19,7 @@ import ( "github.com/bufbuild/buf/private/buf/bufcli" "github.com/bufbuild/buf/private/buf/bufworkspace" + "github.com/bufbuild/buf/private/bufpkg/bufparse" "github.com/bufbuild/buf/private/bufpkg/bufplugin" "github.com/bufbuild/buf/private/pkg/app/appcmd" "github.com/bufbuild/buf/private/pkg/app/appext" @@ -66,24 +67,12 @@ func run( if err != nil { return err } - pluginKeyProvider, err := bufcli.NewPluginKeyProvider(container) - if err != nil { - return err - } - configuredRemotePluginKeys, err := pluginKeyProvider.GetPluginKeysForPluginRefs( - ctx, - configuredRemotePluginRefs, - bufplugin.DigestTypeP1, - ) - if err != nil { - return err - } return prune( ctx, slicesext.Map( - configuredRemotePluginKeys, - func(pluginKey bufplugin.PluginKey) string { - return pluginKey.String() + configuredRemotePluginRefs, + func(pluginRef bufparse.Ref) string { + return pluginRef.FullName().String() }, ), workspaceDepManager, @@ -92,10 +81,10 @@ func run( func prune( ctx context.Context, - bufYAMLBasedRemotePluginKeys []string, + bufYAMLBasedRemotePluginNames []string, workspaceDepManager bufworkspace.WorkspaceDepManager, ) error { - bufYAMLPluginKeys := slicesext.ToStructMap(bufYAMLBasedRemotePluginKeys) + bufYAMLRemotePluginNames := slicesext.ToStructMap(bufYAMLBasedRemotePluginNames) existingRemotePluginKeys, err := workspaceDepManager.ExistingBufLockFileRemotePluginKeys(ctx) if err != nil { return err @@ -103,7 +92,7 @@ func prune( var prunedBufLockPluginKeys []bufplugin.PluginKey for _, existingRemotePluginKey := range existingRemotePluginKeys { // Check if an existing plugin key from the buf.lock is confiugred in the buf.yaml. - if _, ok := bufYAMLPluginKeys[existingRemotePluginKey.String()]; ok { + if _, ok := bufYAMLRemotePluginNames[existingRemotePluginKey.FullName().String()]; ok { // If yes, then we keep it for the updated buf.lock. prunedBufLockPluginKeys = append(prunedBufLockPluginKeys, existingRemotePluginKey) }