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

Function getBuildableWorkspace

cmd/buf/internal/command/push/push.go:302–340  ·  view source on GitHub ↗
(
	ctx context.Context,
	container appext.Container,
	flags *flags,
)

Source from the content-addressed store, hash-verified

300}
301
302func getBuildableWorkspace(
303 ctx context.Context,
304 container appext.Container,
305 flags *flags,
306) (bufworkspace.Workspace, error) {
307 source, err := bufcli.GetInputValue(container, flags.InputHashtag, ".")
308 if err != nil {
309 return nil, err
310 }
311 controller, err := bufcli.NewController(
312 container,
313 bufctl.WithDisableSymlinks(flags.DisableSymlinks),
314 bufctl.WithFileAnnotationErrorFormat(flags.ErrorFormat),
315 )
316 if err != nil {
317 return nil, err
318 }
319 workspace, err := controller.GetWorkspace(
320 ctx,
321 source,
322 // We actually could make it so that buf push would work with buf.work.yamls and push
323 // v1 workspaces as well, but this may have unintended (and potentially breaking) consequences
324 // that we don't want to deal with. If we have a v1 workspace, just outlaw pushing the whole
325 // workspace, and force people into the pre-refactor behavior.
326 bufctl.WithIgnoreAndDisallowV1BufWorkYAMLs(),
327 )
328 if err != nil {
329 return nil, err
330 }
331 // Make sure the workspace builds.
332 if _, err := controller.GetImageForWorkspace(
333 ctx,
334 workspace,
335 bufctl.WithImageExcludeSourceInfo(true),
336 ); err != nil {
337 return nil, err
338 }
339 return workspace, nil
340}
341
342func validateFlags(flags *flags) error {
343 if err := validateCreateFlags(flags); err != nil {

Callers 1

runFunction · 0.85

Calls 8

GetWorkspaceMethod · 0.95
GetImageForWorkspaceMethod · 0.95
GetInputValueFunction · 0.92
NewControllerFunction · 0.92
WithDisableSymlinksFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…