Skip to content

Commit

Permalink
Revert "Add beta plugin command (remove alpha plugin) (#2128)"
Browse files Browse the repository at this point in the history
This reverts commit 05b76d4.
  • Loading branch information
mfridman committed May 30, 2023
1 parent 05b76d4 commit d5e7134
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 17 deletions.
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,14 +146,6 @@ 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),
},
},
{
Use: "registry",
Short: "Manage assets on the Buf Schema Registry",
Expand Down Expand Up @@ -271,6 +263,14 @@ 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.WarnBetaCommand(ctx, container)
bufcli.WarnAlphaCommand(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,18 +132,17 @@ 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.WarnBetaCommand(ctx, container)
bufcli.WarnAlphaCommand(ctx, container)
if err := bufcli.ValidateErrorFormatFlag(flags.ErrorFormat, errorFormatFlagName); err != nil {
return err
}
Expand Down Expand Up @@ -400,7 +399,11 @@ func findExistingDigestForImageID(
imageID string,
currentImageDigest string,
) (string, error) {
repo, err := name.NewRepository(fmt.Sprintf("%s/%s/%s", plugin.Name.Remote(), plugin.Name.Owner(), plugin.Name.Plugin()))
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()))
if err != nil {
return "", err
}
Expand Down
6 changes: 6 additions & 0 deletions private/bufpkg/bufplugin/bufplugindocker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ 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 @@ -149,6 +152,9 @@ 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: "buf.build",
ServerAddress: "plugins.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: "buf.build",
ServerAddress: "plugins.buf.build",
}
encoded, err := auth.ToHeader()
require.NoError(t, err)
Expand Down

0 comments on commit d5e7134

Please sign in to comment.