MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / IsExistingFile

Function IsExistingFile

pkg/validation/validation.go:46–60  ·  view source on GitHub ↗
(val interface{})

Source from the content-addressed store, hash-verified

44}
45
46func IsExistingFile(val interface{}) error {
47 if str, ok := val.(string); ok {
48 info, err := os.Stat(str)
49 if os.IsNotExist(err) {
50 return fmt.Errorf("\"%s\" is not a valid file path", str)
51 }
52 if info.IsDir() {
53 return fmt.Errorf("\"%s\" is a directory, the path must be a file", str)
54 }
55 } else {
56 return fmt.Errorf("cannot check value on response of type %v", reflect.TypeOf(val).Name())
57 }
58 // path is real file
59 return nil
60}

Callers 8

NewCmdCreateFunction · 0.92
NewCmdCreateFunction · 0.92
NewCmdCreateFunction · 0.92
NewCmdCreateFunction · 0.92
NewCmdCreateFunction · 0.92
NewCmdCreateFunction · 0.92
NewCmdCreateFunction · 0.92
NewCmdCreateFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected