Skip to content

Commit

Permalink
Remove alpha wasm plugin support (#2789)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkwarren authored Feb 27, 2024
1 parent 0ed1653 commit ff69892
Show file tree
Hide file tree
Showing 20 changed files with 13 additions and 1,261 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ require (
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
github.com/tetratelabs/wazero v1.6.0
go.opentelemetry.io/otel v1.24.0
go.opentelemetry.io/otel/sdk v1.24.0
go.opentelemetry.io/otel/trace v1.24.0
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/tetratelabs/wazero v1.6.0 h1:z0H1iikCdP8t+q341xqepY4EWvHEw8Es7tlqiVzlP3g=
github.com/tetratelabs/wazero v1.6.0/go.mod h1:0U0G41+ochRKoPKCJlh0jMg1CHkyfK8kDqiirMmKY8A=
github.com/vbatts/tar-split v0.11.5 h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinCts=
github.com/vbatts/tar-split v0.11.5/go.mod h1:yZbwRsSeGjusneWgA781EKej9HF8vme8okylkAeNKLk=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
11 changes: 0 additions & 11 deletions private/buf/bufcli/bufcli.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,13 @@ const (
alphaSuppressWarningsEnvKey = "BUF_ALPHA_SUPPRESS_WARNINGS"
betaSuppressWarningsEnvKey = "BUF_BETA_SUPPRESS_WARNINGS"

// AlphaEnableWASMEnvKey is an env var to enable WASM local plugin execution
AlphaEnableWASMEnvKey = "BUF_ALPHA_ENABLE_WASM"

inputHashtagFlagName = "__hashtag__"
inputHashtagFlagShortName = "#"

userPromptAttempts = 3

publicVisibility = "public"
privateVisibility = "private"

// WASMCompilationCacheDir compiled WASM plugin cache directory
WASMCompilationCacheDir = "wasmplugin-bin"
)

var (
Expand Down Expand Up @@ -876,11 +870,6 @@ func VisibilityFlagToVisibilityAllowUnspecified(visibility string) (registryv1al
}
}

// IsAlphaWASMEnabled returns an BUF_ALPHA_ENABLE_WASM is set to true.
func IsAlphaWASMEnabled(container app.EnvContainer) (bool, error) {
return app.EnvBool(container, AlphaEnableWASMEnvKey, false)
}

// ValidateErrorFormatFlag validates the error format flag for all commands but lint.
func ValidateErrorFormatFlag(errorFormatString string, errorFormatFlagName string) error {
return validateErrorFormatFlag(bufanalysis.AllFormatStrings, errorFormatString, errorFormatFlagName)
Expand Down
10 changes: 0 additions & 10 deletions private/buf/bufgen/bufgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduleref"
"github.com/bufbuild/buf/private/bufpkg/bufplugin/bufpluginref"
"github.com/bufbuild/buf/private/bufpkg/bufremoteplugin"
"github.com/bufbuild/buf/private/bufpkg/bufwasm"
"github.com/bufbuild/buf/private/pkg/app"
"github.com/bufbuild/buf/private/pkg/command"
"github.com/bufbuild/buf/private/pkg/connectclient"
Expand Down Expand Up @@ -117,14 +116,12 @@ func NewGenerator(
logger *zap.Logger,
storageosProvider storageos.Provider,
runner command.Runner,
wasmPluginExecutor bufwasm.PluginExecutor,
clientConfig *connectclient.Config,
) Generator {
return newGenerator(
logger,
storageosProvider,
runner,
wasmPluginExecutor,
clientConfig,
)
}
Expand Down Expand Up @@ -161,13 +158,6 @@ func GenerateWithIncludeWellKnownTypes() GenerateOption {
}
}

// GenerateWithWASMEnabled says to enable WASM support.
func GenerateWithWASMEnabled() GenerateOption {
return func(generateOptions *generateOptions) {
generateOptions.wasmEnabled = true
}
}

// Config is a configuration.
type Config struct {
// Required
Expand Down
19 changes: 2 additions & 17 deletions private/buf/bufgen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/bufbuild/buf/private/bufpkg/bufplugin"
"github.com/bufbuild/buf/private/bufpkg/bufplugin/bufpluginref"
"github.com/bufbuild/buf/private/bufpkg/bufpluginexec"
"github.com/bufbuild/buf/private/bufpkg/bufwasm"
"github.com/bufbuild/buf/private/gen/proto/connect/buf/alpha/registry/v1alpha1/registryv1alpha1connect"
registryv1alpha1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/registry/v1alpha1"
"github.com/bufbuild/buf/private/pkg/app"
Expand All @@ -53,13 +52,12 @@ func newGenerator(
logger *zap.Logger,
storageosProvider storageos.Provider,
runner command.Runner,
wasmPluginExecutor bufwasm.PluginExecutor,
clientConfig *connectclient.Config,
) *generator {
return &generator{
logger: logger,
storageosProvider: storageosProvider,
pluginexecGenerator: bufpluginexec.NewGenerator(logger, storageosProvider, runner, wasmPluginExecutor),
pluginexecGenerator: bufpluginexec.NewGenerator(logger, storageosProvider, runner),
clientConfig: clientConfig,
}
}
Expand Down Expand Up @@ -100,7 +98,6 @@ func (g *generator) Generate(
generateOptions.baseOutDirPath,
generateOptions.includeImports,
generateOptions.includeWellKnownTypes,
generateOptions.wasmEnabled,
)
}

Expand All @@ -112,7 +109,6 @@ func (g *generator) generate(
baseOutDirPath string,
includeImports bool,
includeWellKnownTypes bool,
wasmEnabled bool,
) error {
if err := modifyImage(ctx, g.logger, config, image); err != nil {
return err
Expand All @@ -124,7 +120,6 @@ func (g *generator) generate(
image,
includeImports,
includeWellKnownTypes,
wasmEnabled,
)
if err != nil {
return err
Expand Down Expand Up @@ -165,10 +160,9 @@ func (g *generator) execPlugins(
image bufimage.Image,
includeImports bool,
includeWellKnownTypes bool,
wasmEnabled bool,
) ([]*pluginpb.CodeGeneratorResponse, error) {
imageProvider := newImageProvider(image)
// Collect all of the plugin jobs so that they can be executed in parallel.
// Collect all the plugin jobs so that they can be executed in parallel.
jobs := make([]func(context.Context) error, 0, len(config.PluginConfigs))
responses := make([]*pluginpb.CodeGeneratorResponse, len(config.PluginConfigs))
requiredFeatures := computeRequiredFeatures(image)
Expand All @@ -194,7 +188,6 @@ func (g *generator) execPlugins(
currentPluginConfig,
includeImports,
includeWellKnownTypes,
wasmEnabled,
)
if err != nil {
return err
Expand Down Expand Up @@ -274,7 +267,6 @@ func (g *generator) execLocalPlugin(
pluginConfig *PluginConfig,
includeImports bool,
includeWellKnownTypes bool,
wasmEnabled bool,
) (*pluginpb.CodeGeneratorResponse, error) {
pluginImages, err := imageProvider.GetImages(pluginConfig.Strategy)
if err != nil {
Expand All @@ -284,12 +276,6 @@ func (g *generator) execLocalPlugin(
bufpluginexec.GenerateWithPluginPath(pluginConfig.Path...),
bufpluginexec.GenerateWithProtocPath(pluginConfig.ProtocPath),
}
if wasmEnabled {
generateOptions = append(
generateOptions,
bufpluginexec.GenerateWithWASMEnabled(),
)
}
response, err := g.pluginexecGenerator.Generate(
ctx,
container,
Expand Down Expand Up @@ -617,7 +603,6 @@ type generateOptions struct {
baseOutDirPath string
includeImports bool
includeWellKnownTypes bool
wasmEnabled bool
}

func newGenerateOptions() *generateOptions {
Expand Down
11 changes: 0 additions & 11 deletions private/buf/cmd/buf/command/alpha/protoc/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ import (
"fmt"
"strings"

"github.com/bufbuild/buf/private/buf/bufcli"
"github.com/bufbuild/buf/private/bufpkg/bufimage"
"github.com/bufbuild/buf/private/bufpkg/bufpluginexec"
"github.com/bufbuild/buf/private/bufpkg/bufwasm"
"github.com/bufbuild/buf/private/pkg/app"
"github.com/bufbuild/buf/private/pkg/command"
"github.com/bufbuild/buf/private/pkg/storage/storageos"
Expand All @@ -48,7 +46,6 @@ func executePlugin(
logger *zap.Logger,
storageosProvider storageos.Provider,
runner command.Runner,
wasmPluginExecutor bufwasm.PluginExecutor,
container app.EnvStderrContainer,
images []bufimage.Image,
pluginName string,
Expand All @@ -58,19 +55,11 @@ func executePlugin(
logger,
storageosProvider,
runner,
wasmPluginExecutor,
)
var options []bufpluginexec.GenerateOption
if pluginInfo.Path != "" {
options = append(options, bufpluginexec.GenerateWithPluginPath(pluginInfo.Path))
}
wasmEnabled, err := bufcli.IsAlphaWASMEnabled(container)
if err != nil {
return nil, err
}
if wasmEnabled {
options = append(options, bufpluginexec.GenerateWithWASMEnabled())
}
response, err := generator.Generate(
ctx,
container,
Expand Down
8 changes: 0 additions & 8 deletions private/buf/cmd/buf/command/alpha/protoc/protoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package protoc
import (
"context"
"fmt"
"path/filepath"
"strings"

"github.com/bufbuild/buf/private/buf/bufcli"
Expand All @@ -28,7 +27,6 @@ import (
"github.com/bufbuild/buf/private/bufpkg/bufimage/bufimageutil"
"github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulebuild"
"github.com/bufbuild/buf/private/bufpkg/bufpluginexec"
"github.com/bufbuild/buf/private/bufpkg/bufwasm"
"github.com/bufbuild/buf/private/pkg/app"
"github.com/bufbuild/buf/private/pkg/app/appcmd"
"github.com/bufbuild/buf/private/pkg/app/appflag"
Expand Down Expand Up @@ -184,11 +182,6 @@ func run(
}
span.End()
}
wasmPluginExecutor, err := bufwasm.NewPluginExecutor(
filepath.Join(container.CacheDirPath(), bufcli.WASMCompilationCacheDir))
if err != nil {
return err
}
pluginResponses := make([]*appproto.PluginResponse, 0, len(env.PluginNamesSortedByOutIndex))
for _, pluginName := range env.PluginNamesSortedByOutIndex {
pluginInfo, ok := env.PluginNameToPluginInfo[pluginName]
Expand All @@ -200,7 +193,6 @@ func run(
container.Logger(),
storageosProvider,
runner,
wasmPluginExecutor,
container,
images,
pluginName,
Expand Down
18 changes: 0 additions & 18 deletions private/buf/cmd/buf/command/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ package generate
import (
"context"
"fmt"
"path/filepath"

"github.com/bufbuild/buf/private/buf/bufcli"
"github.com/bufbuild/buf/private/buf/buffetch"
"github.com/bufbuild/buf/private/buf/bufgen"
"github.com/bufbuild/buf/private/bufpkg/bufanalysis"
"github.com/bufbuild/buf/private/bufpkg/bufimage"
"github.com/bufbuild/buf/private/bufpkg/bufimage/bufimageutil"
"github.com/bufbuild/buf/private/bufpkg/bufwasm"
"github.com/bufbuild/buf/private/pkg/app/appcmd"
"github.com/bufbuild/buf/private/pkg/app/appflag"
"github.com/bufbuild/buf/private/pkg/command"
Expand Down Expand Up @@ -379,16 +377,6 @@ func run(
bufgen.GenerateWithIncludeWellKnownTypes(),
)
}
wasmEnabled, err := bufcli.IsAlphaWASMEnabled(container)
if err != nil {
return err
}
if wasmEnabled {
generateOptions = append(
generateOptions,
bufgen.GenerateWithWASMEnabled(),
)
}
var includedTypes []string
if len(flags.Types) > 0 || len(flags.TypesDeprecated) > 0 {
// command-line flags take precedence
Expand All @@ -402,16 +390,10 @@ func run(
return err
}
}
wasmPluginExecutor, err := bufwasm.NewPluginExecutor(
filepath.Join(container.CacheDirPath(), bufcli.WASMCompilationCacheDir))
if err != nil {
return err
}
return bufgen.NewGenerator(
logger,
storageosProvider,
runner,
wasmPluginExecutor,
clientConfig,
).Generate(
ctx,
Expand Down
Loading

0 comments on commit ff69892

Please sign in to comment.