MCPcopy Create free account
hub / github.com/github/gh-aw / validateMountEntries

Function validateMountEntries

pkg/workflow/validation_helpers.go:152–173  ·  view source on GitHub ↗

validateMountEntries applies shared mount parsing and classification across callers while allowing each caller to preserve its own logging and error construction. onValid may be nil. onInvalid must be non-nil and must return a non-nil error for all non-OK mountValidationKind values.

(mounts []string, onValid func(int, mountParts), onInvalid func(int, string, mountParts, mountValidationKind) error)

Source from the content-addressed store, hash-verified

150// construction. onValid may be nil. onInvalid must be non-nil and must return
151// a non-nil error for all non-OK mountValidationKind values.
152func validateMountEntries(mounts []string, onValid func(int, mountParts), onInvalid func(int, string, mountParts, mountValidationKind) error) error {
153 if onInvalid == nil {
154 return errors.New("internal error: onInvalid callback must not be nil")
155 }
156
157 for i, mount := range mounts {
158 parts, kind := parseMountEntry(mount)
159 if kind == mountValidationOK {
160 if onValid != nil {
161 onValid(i, parts)
162 }
163 continue
164 }
165 err := onInvalid(i, mount, parts, kind)
166 if err == nil {
167 return fmt.Errorf("internal error: onInvalid callback returned nil for mount kind %d", kind)
168 }
169 return err
170 }
171
172 return nil
173}
174
175// validateStringEnumField checks that a config field, if present, contains one
176// of the allowed string values. Non-string values and unrecognised strings are

Callers 3

validateMCPMountsSyntaxFunction · 0.85
TestValidateMountEntriesFunction · 0.85
validateMountsSyntaxFunction · 0.85

Calls 2

parseMountEntryFunction · 0.85
ErrorfMethod · 0.45

Tested by 1

TestValidateMountEntriesFunction · 0.68