github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/tiltfile/include/include.go (about) 1 package include 2 3 import ( 4 "go.starlark.net/starlark" 5 6 "github.com/tilt-dev/tilt/internal/tiltfile/starkit" 7 ) 8 9 // Implements the include() built-in. 10 // 11 // The main difference is that include() doesn't bind any arguments into the 12 // global scope, whereas load() forces you to bind at least one argument into the global 13 // scope (i.e., you can't load() a Tilfile for its side-effects). 14 // 15 // Users should generally be discouraged from using this function. They should use 16 // load_dynamic instead, which has a more self-descriptive name and can load symbols. 17 type IncludeFn struct { 18 } 19 20 func (IncludeFn) OnStart(e *starkit.Environment) error { 21 return e.AddBuiltin("include", include) 22 } 23 24 func include(t *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { 25 var p string 26 err := starkit.UnpackArgs(t, fn.Name(), args, kwargs, "path", &p) 27 if err != nil { 28 return nil, err 29 } 30 31 _, err = t.Load(t, p) 32 return starlark.None, err 33 }