diff --git a/cmd/ninja/cmd/plugin.go b/cmd/ninja/cmd/plugin.go index 947af06..1b8eaa8 100644 --- a/cmd/ninja/cmd/plugin.go +++ b/cmd/ninja/cmd/plugin.go @@ -85,7 +85,7 @@ func printPublicSection(ctx context.Context, cli *orchclient.Client) { continue } for _, p := range gs.Msg.Plugins { - fmt.Printf(" @%s/%s [%s]\n", s.Slug, p.Name, core.VisibilityLabel(p.Visibility)) + fmt.Printf(" @%s/%s [%s]\n", s.Slug, p.Name, visibilityLabel(p.Visibility)) } } } @@ -175,6 +175,29 @@ func newPluginDeleteVersionCmd() *cobra.Command { return cmd } +// visibilityLabel converts the proto PluginVisibility enum into the +// lowercase, user-facing form ("private", "public", ...). Kept here in the +// CLI rather than in core/plugin so that external consumers of core/plugin +// don't transitively pull in core/internal/api/... — every such pull-in +// races with the orchestrator's own generated bindings of the same proto +// file at proto-registration time. +func visibilityLabel(v v1.PluginVisibility) string { + switch v { + case v1.PluginVisibility_PLUGIN_VISIBILITY_PRIVATE: + return "private" + case v1.PluginVisibility_PLUGIN_VISIBILITY_UNDER_REVIEW: + return "under_review" + case v1.PluginVisibility_PLUGIN_VISIBILITY_PUBLIC, + v1.PluginVisibility_PLUGIN_VISIBILITY_UNSPECIFIED: + return "public" + case v1.PluginVisibility_PLUGIN_VISIBILITY_REJECTED: + return "rejected" + case v1.PluginVisibility_PLUGIN_VISIBILITY_TAKEN_DOWN: + return "taken_down" + } + return "unknown" +} + // parsePrivateCoord accepts either a bare plugin name ("myplugin") or the // canonical "@private/name" form and returns just the plugin name. Any other // scope is rejected to make accidental deletion of public plugins impossible. @@ -740,7 +763,7 @@ func newPluginStatusCmd() *cobra.Command { continue } for _, p := range gs.Msg.Plugins { - fmt.Printf(" @%s/%s [%s]\n", s.Slug, p.Name, core.VisibilityLabel(p.Visibility)) + fmt.Printf(" @%s/%s [%s]\n", s.Slug, p.Name, visibilityLabel(p.Visibility)) } } return nil diff --git a/plugin/mod.go b/plugin/mod.go index ceca26a..a66d2b9 100644 --- a/plugin/mod.go +++ b/plugin/mod.go @@ -4,31 +4,8 @@ import ( "strings" tomlpkg "github.com/BurntSushi/toml" - - v1 "git.dev.alexdunmow.com/block/core/internal/api/orchestrator/v1" ) -// VisibilityLabel returns the lowercase, user-facing form of a PluginVisibility -// value (e.g. "private", "public", "under_review"). The default for the -// UNSPECIFIED zero value is "public", matching pre-enum behaviour for plugins -// that don't carry an explicit visibility. -func VisibilityLabel(v v1.PluginVisibility) string { - switch v { - case v1.PluginVisibility_PLUGIN_VISIBILITY_PRIVATE: - return "private" - case v1.PluginVisibility_PLUGIN_VISIBILITY_UNDER_REVIEW: - return "under_review" - case v1.PluginVisibility_PLUGIN_VISIBILITY_PUBLIC, - v1.PluginVisibility_PLUGIN_VISIBILITY_UNSPECIFIED: - return "public" - case v1.PluginVisibility_PLUGIN_VISIBILITY_REJECTED: - return "rejected" - case v1.PluginVisibility_PLUGIN_VISIBILITY_TAKEN_DOWN: - return "taken_down" - } - return "unknown" -} - type ModFile struct { Plugin ModPlugin `toml:"plugin"` Compatibility *ModCompat `toml:"compatibility"`