github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/tiltfile/starkit/module.go (about) 1 package starkit 2 3 import ( 4 "fmt" 5 6 "go.starlark.net/starlark" 7 ) 8 9 // A frozen starlark module object. Can only be changed from Go. 10 type Module struct { 11 fullName string 12 attrs starlark.StringDict 13 } 14 15 func (m Module) Freeze() {} 16 17 func (m Module) Type() string { return "module" } 18 19 func (m Module) Hash() (uint32, error) { 20 return 0, fmt.Errorf("unhashable type: module") 21 } 22 23 func (m Module) Attr(name string) (starlark.Value, error) { 24 val := m.attrs[name] 25 return val, nil 26 } 27 28 func (m Module) AttrNames() []string { 29 keys := make([]string, 0, len(m.attrs)) 30 for key := range m.attrs { 31 keys = append(keys, key) 32 } 33 return keys 34 } 35 36 func (m Module) Truth() starlark.Bool { 37 return true 38 } 39 40 func (m Module) String() string { 41 return fmt.Sprintf("[module: %s]", m.fullName) 42 } 43 44 var _ starlark.HasAttrs = Module{}