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

Method GetSourceOrModuleRef

private/buf/buffetch/ref_parser.go:282–306  ·  view source on GitHub ↗
(
	ctx context.Context,
	value string,
)

Source from the content-addressed store, hash-verified

280}
281
282func (a *refParser) GetSourceOrModuleRef(
283 ctx context.Context,
284 value string,
285) (SourceOrModuleRef, error) {
286 parsedRef, err := a.getParsedRef(ctx, value, sourceOrModuleFormats)
287 if err != nil {
288 return nil, err
289 }
290 switch t := parsedRef.(type) {
291 case internal.ParsedSingleRef:
292 return nil, fmt.Errorf("invalid ParsedRef type for source or module: %T", parsedRef)
293 case internal.ParsedArchiveRef:
294 return newSourceRef(t), nil
295 case internal.ParsedDirRef:
296 return newDirRef(t), nil
297 case internal.ParsedGitRef:
298 return newSourceRef(t), nil
299 case internal.ParsedModuleRef:
300 return newModuleRef(t), nil
301 case internal.ProtoFileRef:
302 return newProtoFileRef(t), nil
303 default:
304 return nil, fmt.Errorf("unknown ParsedRef type: %T", parsedRef)
305 }
306}
307
308func (a *refParser) GetSourceOrModuleRefForInputConfig(
309 ctx context.Context,

Callers

nothing calls this directly

Calls 5

getParsedRefMethod · 0.95
newSourceRefFunction · 0.85
newDirRefFunction · 0.70
newModuleRefFunction · 0.70
newProtoFileRefFunction · 0.70

Tested by

no test coverage detected