MCPcopy
hub / github.com/cloudfoundry/cli / UnmarshalFlag

Method UnmarshalFlag

command/flag/path.go:64–90  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

62}
63
64func (p *ManifestPathWithExistenceCheck) UnmarshalFlag(path string) error {
65 fileInfo, err := checkIfFileExists(path)
66 if err != nil {
67 return err
68 }
69
70 if fileInfo.IsDir() {
71 locator := manifestparser.NewLocator()
72 pathToFile, existsInDirectory, err := locator.Path(path)
73 if err != nil {
74 return err
75 }
76
77 if !existsInDirectory {
78 return &flags.Error{
79 Type: flags.ErrRequired,
80 Message: fmt.Sprintf("The specified directory '%s' does not contain a file named 'manifest.yml'.", path),
81 }
82 }
83
84 *p = ManifestPathWithExistenceCheck(pathToFile)
85 } else {
86 *p = ManifestPathWithExistenceCheck(path)
87 }
88
89 return nil
90}
91
92type JSONOrFileWithValidation types.OptionalObject
93

Callers

nothing calls this directly

Calls 5

PathMethod · 0.95
NewLocatorFunction · 0.92
checkIfFileExistsFunction · 0.85
IsDirMethod · 0.80

Tested by

no test coverage detected