1
1
mirror of https://github.com/mcuadros/ascode synced 2024-11-23 01:11:59 +01:00
ascode/main.go
Máximo Cuadros 361461de32 *: package clean up
Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
2019-07-03 01:05:35 +02:00

36 lines
851 B
Go

package main
import (
"io/ioutil"
"log"
"os"
"github.com/mcuadros/terra/provider"
"go.starlark.net/repl"
"go.starlark.net/resolve"
"go.starlark.net/starlark"
)
func main() {
log.SetOutput(ioutil.Discard)
pm := &provider.PluginManager{".providers"}
resolve.AllowFloat = true
provider := starlark.NewBuiltin("provider", func(thread *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
name := args.Index(0).(starlark.String)
version := args.Index(1).(starlark.String)
return provider.MakeProvider(pm, string(name), string(version))
})
thread := &starlark.Thread{Name: "thread", Load: repl.MakeLoad()}
predeclared := starlark.StringDict{
"provider": provider,
}
if _, err := starlark.ExecFile(thread, os.Args[1], nil, predeclared); err != nil {
panic(err)
}
}