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

Add beta plugin command (remove alpha plugin) #2128

Merged
merged 1 commit into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions private/buf/cmd/buf/buf.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ import (
"time"

"github.com/bufbuild/buf/private/buf/bufcli"
curatedplugindelete "github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/plugin/plugindelete"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/plugin/pluginpush"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/protoc"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/registry/token/tokendelete"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/registry/token/tokenget"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/registry/token/tokenlist"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/workspace/workspacepush"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/migratev1beta1"
curatedplugindelete "github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/plugin/plugindelete"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/plugin/pluginpush"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/price"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/commit/commitget"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/commit/commitlist"
Expand Down Expand Up @@ -146,6 +146,14 @@ func NewRootCommand(name string) *appcmd.Command {
stats.NewCommand("stats", builder),
migratev1beta1.NewCommand("migrate-v1beta1", builder),
studioagent.NewCommand("studio-agent", noTimeoutBuilder),
{
Use: "plugin",
Short: "Manage plugins on the Buf Schema Registry",
SubCommands: []*appcmd.Command{
pluginpush.NewCommand("push", builder),
curatedplugindelete.NewCommand("delete", builder),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
curatedplugindelete.NewCommand("delete", builder),
plugindelete.NewCommand("delete", builder),

Maybe as part of this we remove the old buf beta registry plugin and buf beta registry template commands since the old RPCs no longer support making changes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Any objections if we do this in a follow-up PR, I'd like to keep the removal of the legacy bits separate from feature work?

},
},
{
Use: "registry",
Short: "Manage assets on the Buf Schema Registry",
Expand Down Expand Up @@ -263,14 +271,6 @@ func NewRootCommand(name string) *appcmd.Command {
},
},
},
{
Use: "plugin",
Short: "Manage plugins on the Buf Schema Registry",
SubCommands: []*appcmd.Command{
pluginpush.NewCommand("push", builder),
curatedplugindelete.NewCommand("delete", builder),
},
},
{
Use: "workspace",
Short: "Manage workspaces",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func run(
container appflag.Container,
flags *flags,
) error {
bufcli.WarnAlphaCommand(ctx, container)
bufcli.WarnBetaCommand(ctx, container)
identity, version, _ := strings.Cut(container.Arg(0), ":")
pluginIdentity, err := bufpluginref.PluginIdentityForString(identity)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,18 @@ func (f *flags) Bind(flagSet *pflag.FlagSet) {
flagSet.StringVar(
&f.Visibility,
visibilityFlagName,
"public",
"",
fmt.Sprintf(`The plugin's visibility setting. Must be one of %s`, stringutil.SliceToString(allVisibiltyStrings)),
)
_ = cobra.MarkFlagRequired(flagSet, visibilityFlagName)
}

func run(
ctx context.Context,
container appflag.Container,
flags *flags,
) (retErr error) {
bufcli.WarnAlphaCommand(ctx, container)
bufcli.WarnBetaCommand(ctx, container)
if err := bufcli.ValidateErrorFormatFlag(flags.ErrorFormat, errorFormatFlagName); err != nil {
return err
}
Expand Down Expand Up @@ -399,11 +400,7 @@ func findExistingDigestForImageID(
imageID string,
currentImageDigest string,
) (string, error) {
pluginsRemote := plugin.Name.Remote()
if !strings.HasPrefix(pluginsRemote, bufplugindocker.PluginsImagePrefix) {
pluginsRemote = bufplugindocker.PluginsImagePrefix + pluginsRemote
}
repo, err := name.NewRepository(fmt.Sprintf("%s/%s/%s", pluginsRemote, plugin.Name.Owner(), plugin.Name.Plugin()))
repo, err := name.NewRepository(fmt.Sprintf("%s/%s/%s", plugin.Name.Remote(), plugin.Name.Owner(), plugin.Name.Plugin()))
if err != nil {
return "", err
}
Expand Down
6 changes: 0 additions & 6 deletions private/bufpkg/bufplugin/bufplugindocker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ import (
)

const (
// PluginsImagePrefix is used to prefix all image names with the correct path for pushing to the OCI registry.
PluginsImagePrefix = "plugins."

// Setting this value on the buf docker client allows us to propagate a custom
// value to the OCI registry. This is a useful property that enables registries
// to differentiate between the buf cli vs other tools like docker cli.
Expand Down Expand Up @@ -152,9 +149,6 @@ func (d *dockerAPIClient) Tag(ctx context.Context, image string, config *bufplug
}
buildID := stringid.GenerateRandomID()
imageName := config.Name.IdentityString() + ":" + buildID
if !strings.HasPrefix(imageName, PluginsImagePrefix) {
imageName = PluginsImagePrefix + imageName
}
if err := d.cli.ImageTag(ctx, image, imageName); err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestRegistryAuthMarshalJSON(t *testing.T) {
Username: "someuser",
Password: "somepass",
Email: "someemail@buf.build",
ServerAddress: "plugins.buf.build",
ServerAddress: "buf.build",
}
encoded, err := json.Marshal(auth)
require.NoError(t, err)
Expand All @@ -44,7 +44,7 @@ func TestRegistryAuthToFromHeader(t *testing.T) {
Username: "someuser",
Password: "somepass",
Email: "someemail@buf.build",
ServerAddress: "plugins.buf.build",
ServerAddress: "buf.build",
}
encoded, err := auth.ToHeader()
require.NoError(t, err)
Expand Down