MCPcopy Create free account
hub / github.com/bufbuild/buf / executePlugin

Function executePlugin

cmd/buf/internal/command/alpha/protoc/plugin.go:43–81  ·  view source on GitHub ↗
(
	ctx context.Context,
	logger *slog.Logger,
	storageosProvider storageos.Provider,
	container app.EnvStderrContainer,
	images []bufimage.Image,
	pluginName string,
	pluginInfo *pluginInfo,
)

Source from the content-addressed store, hash-verified

41}
42
43func executePlugin(
44 ctx context.Context,
45 logger *slog.Logger,
46 storageosProvider storageos.Provider,
47 container app.EnvStderrContainer,
48 images []bufimage.Image,
49 pluginName string,
50 pluginInfo *pluginInfo,
51) (*pluginpb.CodeGeneratorResponse, error) {
52 generator := bufprotopluginexec.NewGenerator(
53 logger,
54 storageosProvider,
55 )
56 requests, err := bufimage.ImagesToCodeGeneratorRequests(
57 images,
58 strings.Join(pluginInfo.Opt, ","),
59 bufprotopluginexec.DefaultVersion,
60 false,
61 false,
62 )
63 if err != nil {
64 return nil, err
65 }
66 var options []bufprotopluginexec.GenerateOption
67 if pluginInfo.Path != "" {
68 options = append(options, bufprotopluginexec.GenerateWithPluginPath(pluginInfo.Path))
69 }
70 response, err := generator.Generate(
71 ctx,
72 container,
73 pluginName,
74 requests,
75 options...,
76 )
77 if err != nil {
78 return nil, fmt.Errorf("--%s_out: %v", pluginName, err)
79 }
80 return response, nil
81}

Callers 1

runFunction · 0.85

Calls 4

GenerateMethod · 0.95
NewGeneratorFunction · 0.92
GenerateWithPluginPathFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…