@@ -91,6 +91,34 @@ func Validate(config *latest.Config) error {
9191 return err
9292 }
9393
94+ err = validateFunctions (config .Functions )
95+ if err != nil {
96+ return err
97+ }
98+
99+ return nil
100+ }
101+
102+ func isReservedFunctionName (name string ) bool {
103+ switch name {
104+ case "true" , ":" , "false" , "exit" , "set" , "shift" , "unset" ,
105+ "echo" , "printf" , "break" , "continue" , "pwd" , "cd" ,
106+ "wait" , "builtin" , "trap" , "type" , "source" , "." , "command" ,
107+ "dirs" , "pushd" , "popd" , "umask" , "alias" , "unalias" ,
108+ "fg" , "bg" , "getopts" , "eval" , "test" , "devspace" , "[" , "exec" ,
109+ "return" , "read" , "shopt" :
110+ return true
111+ }
112+ return false
113+ }
114+
115+ func validateFunctions (functions map [string ]string ) error {
116+ for name := range functions {
117+ if isReservedFunctionName (name ) {
118+ return fmt .Errorf ("you cannot use '%s' as a function name as its an internally used special function. Please choose another name" , name )
119+ }
120+ }
121+
94122 return nil
95123}
96124
0 commit comments