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

Method GetWorkspace

private/buf/bufctl/controller.go:292–317  ·  view source on GitHub ↗
(
	ctx context.Context,
	sourceOrModuleInput string,
	options ...FunctionOption,
)

Source from the content-addressed store, hash-verified

290}
291
292func (c *controller) GetWorkspace(
293 ctx context.Context,
294 sourceOrModuleInput string,
295 options ...FunctionOption,
296) (_ bufworkspace.Workspace, retErr error) {
297 defer c.handleFileAnnotationSetRetError(&retErr)
298 functionOptions := newFunctionOptions(c)
299 for _, option := range options {
300 option(functionOptions)
301 }
302 sourceOrModuleRef, err := c.buffetchRefParser.GetSourceOrModuleRef(ctx, sourceOrModuleInput)
303 if err != nil {
304 return nil, err
305 }
306 switch t := sourceOrModuleRef.(type) {
307 case buffetch.ProtoFileRef:
308 return c.getWorkspaceForProtoFileRef(ctx, t, functionOptions)
309 case buffetch.SourceRef:
310 return c.getWorkspaceForSourceRef(ctx, t, functionOptions)
311 case buffetch.ModuleRef:
312 return c.getWorkspaceForModuleRef(ctx, t, functionOptions)
313 default:
314 // This is a system error.
315 return nil, syserror.Newf("invalid SourceOrModuleRef: %T", sourceOrModuleRef)
316 }
317}
318
319func (c *controller) GetWorkspaceDepManager(
320 ctx context.Context,

Callers

nothing calls this directly

Calls 8

NewfFunction · 0.92
newFunctionOptionsFunction · 0.85
optionStruct · 0.85
GetSourceOrModuleRefMethod · 0.65

Tested by

no test coverage detected