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

Function ParseFileNode

private/pkg/cas/file_node.go:62–88  ·  view source on GitHub ↗

ParseFileNode parses the FileNode from its string representation. The string representation is "digestString[SP][SP]path". This reverses FileNode.String().

(s string)

Source from the content-addressed store, hash-verified

60//
61// This reverses FileNode.String().
62func ParseFileNode(s string) (FileNode, error) {
63 split := strings.Split(s, " ")
64 if len(split) != 2 {
65 return nil, newParseError(
66 "file node",
67 s,
68 errors.New(`must in the form "digest[SP][SP]path"`),
69 )
70 }
71 digest, err := ParseDigest(split[0])
72 if err != nil {
73 return nil, newParseError(
74 "file node",
75 s,
76 err,
77 )
78 }
79 path := split[1]
80 if err := validateFileNodeParameters(path, digest); err != nil {
81 return nil, newParseError(
82 "file node",
83 s,
84 err,
85 )
86 }
87 return newFileNode(path, digest), nil
88}
89
90// *** PRIVATE ***
91

Callers 1

ParseManifestFunction · 0.85

Calls 4

newParseErrorFunction · 0.85
newFileNodeFunction · 0.85
ParseDigestFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…