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

Method WithTargetOpaqueIDs

private/bufpkg/bufmodule/module_set.go:343–359  ·  view source on GitHub ↗
(opaqueIDs ...string)

Source from the content-addressed store, hash-verified

341}
342
343func (m *moduleSet) WithTargetOpaqueIDs(opaqueIDs ...string) (ModuleSet, error) {
344 if len(opaqueIDs) == 0 {
345 return nil, errors.New("at least one Module must be targeted")
346 }
347 opaqueIDMap := xslices.ToStructMap(opaqueIDs)
348 modules := make([]Module, len(m.modules))
349 for i, module := range m.modules {
350 _, isTarget := opaqueIDMap[module.OpaqueID()]
351 // Always make a copy regardless of if targeting changes. We're going to set a new ModuleSet on the Module.
352 module, err := module.withIsTarget(isTarget)
353 if err != nil {
354 return nil, err
355 }
356 modules[i] = module
357 }
358 return newModuleSet(modules)
359}
360
361// This should only be used by Modules and FileInfos.
362func (m *moduleSet) getModuleForFilePath(ctx context.Context, filePath string) (Module, error) {

Callers

nothing calls this directly

Calls 3

newModuleSetFunction · 0.70
OpaqueIDMethod · 0.65
withIsTargetMethod · 0.65

Tested by

no test coverage detected