diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index e5403b8..e5659e7 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -8,10 +8,20 @@ on: - created jobs: gh-pages: + env: + GOPATH: ${{ github.workspace }} + WORKING_PATH: ${{ github.workspace }}/src/github.com/${{ github.repository }} runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 + with: + path: ${{env.WORKING_PATH}} + + - name: Install Go + uses: actions/setup-go@v2-beta + with: + go-version: 1.14.x - name: Setup Hugo uses: peaceiris/actions-hugo@v2 @@ -19,11 +29,16 @@ jobs: hugo-version: '0.68.2' extended: true + - name: Setup Outline + run: go get github.com/mcuadros/outline + - name: Hugo Build run: make hugo-build + working-directory: ${{env.WORKING_PATH}} - name: Push to gh-pages uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./_site/public \ No newline at end of file + publish_dir: src/github.com/${{ github.repository }}/_site/public + cname: ascode.run \ No newline at end of file diff --git a/Makefile b/Makefile index bbb9726..9653b75 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,11 @@ RUNTIME_MODULES = \ github.com/qri-io/starlib/re \ github.com/qri-io/starlib/http +QUERY_GO_MOD_CMD = go run _scripts/query-go-mod.go +STARLIB_PKG ?= github.com/qri-io/starlib +STARLIB_COMMIT ?= $(shell $(QUERY_GO_MOD_CMD) . $(STARLIB_PKG)) +STARLIB_PKG_LOCATION = $(GOPATH)/src/$(STARLIB_PKG) + # Build Info GO_LDFLAGS_CMD = go run _scripts/goldflags.go GO_LDFLAGS_PACKAGE = cmd @@ -37,7 +42,7 @@ export HUGO_PARAMS_VERSION .PHONY: documentation clean hugo-server documentation: $(RUNTIME_MODULES) -$(RUNTIME_MODULES): $(DOCUMENTATION_RUNTIME_PATH) +$(RUNTIME_MODULES): $(DOCUMENTATION_RUNTIME_PATH) $(STARLIB_PKG_LOCATION) $(OUTLINE_CMD) package \ -t $(DOCUMENTATION_REFERENCE_TEMPLATE) \ -d $(EXAMPLES_PATH) \ @@ -47,13 +52,19 @@ $(RUNTIME_MODULES): $(DOCUMENTATION_RUNTIME_PATH) $(DOCUMENTATION_REFERENCE_PATH): mkdir -p $@ +$(STARLIB_PKG_LOCATION): + git clone https://$(STARLIB_PKG) $@; \ + cd $@; \ + git checkout $(STARLIB_COMMIT); \ + cd $(BASE_PATH); + goldflags: @$(GO_LDFLAGS_CMD) $(GO_LDFLAGS_PACKAGE) . $(GO_LDFLAGS_PACKAGES) -hugo-build: $(HUGO_SITE_PATH) +hugo-build: $(HUGO_SITE_PATH) documentation hugo --minify --source $(HUGO_SITE_PATH) --config $(DOCUMENTATION_PATH)/config.toml -hugo-server: $(HUGO_SITE_PATH) +hugo-server: $(HUGO_SITE_PATH) documentation hugo server --source $(HUGO_SITE_PATH) --config $(DOCUMENTATION_PATH)/config.toml $(HUGO_SITE_PATH): $(HUGO_SITE_TEMPLATE_PATH) @@ -63,6 +74,7 @@ $(HUGO_SITE_PATH): $(HUGO_SITE_TEMPLATE_PATH) ln -s $(DOCUMENTATION_PATH) $(HUGO_SITE_CONTENT_PATH)/docs ln -s $(DOCUMENTATION_PATH)/_home.md $(HUGO_SITE_CONTENT_PATH)/_index.md + $(HUGO_SITE_TEMPLATE_PATH): git clone $(HUGO_THEME_URL) $(HUGO_SITE_TEMPLATE_PATH) diff --git a/_documentation/config.toml b/_documentation/config.toml index 8534313..458d36c 100644 --- a/_documentation/config.toml +++ b/_documentation/config.toml @@ -1,4 +1,4 @@ -baseURL = "ascode.run" +baseURL = "https://ascode.run" languageCode = "en-us" title = "AsCode - Terraform Alternative Syntax" theme = "hugo-ascode-theme" diff --git a/_scripts/query-go-mod.go b/_scripts/query-go-mod.go new file mode 100644 index 0000000..bdfb86f --- /dev/null +++ b/_scripts/query-go-mod.go @@ -0,0 +1,42 @@ +package main + +import ( + "fmt" + "io/ioutil" + "log" + "os" + "path/filepath" + "strings" + + "github.com/rogpeppe/go-internal/modfile" +) + +func main() { + path := os.Args[1] + pkg := os.Args[2] + + f, err := readGoMod(path) + if err != nil { + log.Fatal(err) + } + + for _, r := range f.Require { + if r.Mod.Path != pkg { + continue + } + + parts := strings.Split(r.Mod.Version, "-") + if len(parts) > 1 { + fmt.Println(parts[len(parts)-1]) + } + } +} + +func readGoMod(path string) (*modfile.File, error) { + content, err := ioutil.ReadFile(filepath.Join(path, "go.mod")) + if err != nil { + return nil, err + } + + return modfile.ParseLax("", content, nil) +} diff --git a/go.mod b/go.mod index f6df735..9b39fe0 100644 --- a/go.mod +++ b/go.mod @@ -4,28 +4,33 @@ go 1.14 require ( github.com/Masterminds/semver/v3 v3.0.3 - github.com/b5/outline v0.0.0-20190307020728-8cdd78996e40 github.com/containers/image/v5 v5.2.1 github.com/docker/distribution v2.7.1+incompatible // indirect github.com/docker/go-metrics v0.0.1 // indirect github.com/go-git/go-git/v5 v5.0.0 - github.com/gophercloud/utils v0.0.0-20190128072930-fbb6ab446f01 github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect github.com/hashicorp/go-hclog v0.11.0 github.com/hashicorp/go-plugin v1.0.1-0.20190610192547-a1bc61569a26 - github.com/hashicorp/go-version v1.2.0 github.com/hashicorp/hcl2 v0.0.0-20190618163856-0b64543c968c github.com/hashicorp/terraform v0.12.23 github.com/jessevdk/go-flags v1.4.0 + github.com/kr/text v0.2.0 // indirect github.com/mitchellh/cli v1.0.0 + github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect github.com/oklog/ulid/v2 v2.0.2 - github.com/qri-io/starlib v0.4.2-0.20200213133954-ff2e8cd5ef8d + github.com/qri-io/starlib v0.4.2-0.20200326221746-d3997998591b + github.com/rogpeppe/go-internal v1.5.2 + github.com/sergi/go-diff v1.1.0 // indirect github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304 // indirect github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c // indirect github.com/stretchr/testify v1.5.1 github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/zclconf/go-cty v1.3.1 go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 + golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 // indirect + golang.org/x/net v0.0.0-20200301022130-244492dfa37a // indirect + golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 // indirect + gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect gopkg.in/yaml.v2 v2.2.8 // indirect ) diff --git a/go.sum b/go.sum index 7a1367d..f382ba7 100644 --- a/go.sum +++ b/go.sum @@ -60,7 +60,6 @@ github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agl/ed25519 v0.0.0-20150830182803-278e1ec8e8a6/go.mod h1:WPjqKcmVOxf0XSf3YxCJs6N6AOSrOx3obionmG7T0y0= -github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -71,7 +70,6 @@ github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190103054945-8205d1f41e70/go.mod h1 github.com/aliyun/aliyun-tablestore-go-sdk v4.1.2+incompatible h1:ABQ7FF+IxSFHDMOTtjCfmMDMHiCq6EsAoCV/9sFinaM= github.com/aliyun/aliyun-tablestore-go-sdk v4.1.2+incompatible/go.mod h1:LDQHRZylxvcg8H7wBIDfvO5g/cy4/sz1iucBlc2l3Jw= github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= -github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/antchfx/xpath v0.0.0-20190129040759-c8489ed3251e h1:ptBAamGVd6CfRsUtyHD+goy2JGhv1QC32v3gqM8mYAM= github.com/antchfx/xpath v0.0.0-20190129040759-c8489ed3251e/go.mod h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNYhvtNk= @@ -92,13 +90,10 @@ github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmV github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= github.com/aws/aws-sdk-go v1.25.3 h1:uM16hIw9BotjZKMZlX05SN2EFtaWfi/NonPKIARiBLQ= github.com/aws/aws-sdk-go v1.25.3/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/b5/outline v0.0.0-20190307020728-8cdd78996e40 h1:If4MhYsam+FSSNhQiTIpZ7b7PobN1Bs5AiAcOo1xeAY= -github.com/b5/outline v0.0.0-20190307020728-8cdd78996e40/go.mod h1:ese4/gabYqGhOf3egE6Eekms1hxIIs6iNQXj/TNpFwQ= github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f h1:ZNv7On9kyUzm7fvRZumSyy/IUiSC7AzL0I1jKKtwooA= github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -193,20 +188,19 @@ github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3 github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa/go.mod h1:KnogPXtdwXqoenmZCw6S+25EAm2MkxbG0deNDu4cbSA= github.com/ghodss/yaml v0.0.0-20161207003320-04f313413ffd/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= github.com/go-git/go-billy/v5 v5.0.0 h1:7NQHvd9FVid8VL4qVUMm8XifBK+2xCoZ2lSk0agRrHM= github.com/go-git/go-billy/v5 v5.0.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= -github.com/go-git/go-git-fixtures/v4 v4.0.1 h1:q+IFMfLx200Q3scvt2hN79JsEzy4AmBTp/pqnefH+Bc= +github.com/go-git/go-git v1.0.0 h1:YcN9iDGDoXuIw0vHls6rINwV416HYa0EB2X+RBsyYp4= +github.com/go-git/go-git v4.7.0+incompatible h1:+W9rgGY4DOKKdX2x6HxSR7HNeTxqiKrOvKnuittYVdA= github.com/go-git/go-git-fixtures/v4 v4.0.1/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw= github.com/go-git/go-git/v5 v5.0.0 h1:k5RWPm4iJwYtfWoxIJy4wJX9ON7ihPeZZYC1fLYDnpg= github.com/go-git/go-git/v5 v5.0.0/go.mod h1:oYD8y9kWsGINPFJoLdaScGCN6dlKg23blmClfZwtUVA= @@ -539,9 +533,11 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= github.com/prometheus/procfs v0.0.5 h1:3+auTFlqw+ZaQYJARz6ArODtkaIwtvBTx3N2NehQlL8= github.com/prometheus/procfs v0.0.5/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= -github.com/qri-io/starlib v0.4.2-0.20200213133954-ff2e8cd5ef8d h1:K6eOUihrFLdZjZnA4XlRp864fmWXv9YTIk7VPLhRacA= -github.com/qri-io/starlib v0.4.2-0.20200213133954-ff2e8cd5ef8d/go.mod h1:7DPO4domFU579Ga6E61sB9VFNaniPVwJP5C4bBCu3wA= +github.com/qri-io/starlib v0.4.2-0.20200326221746-d3997998591b h1:n460ZPlc7+1evliXpUzGhIVr080j5c+2zsXuThfEGGM= +github.com/qri-io/starlib v0.4.2-0.20200326221746-d3997998591b/go.mod h1:7DPO4domFU579Ga6E61sB9VFNaniPVwJP5C4bBCu3wA= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/go-internal v1.5.2 h1:qLvObTrvO/XRCqmkKxUlOBc48bI3efyDuAZe25QiF0w= +github.com/rogpeppe/go-internal v1.5.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= @@ -782,6 +778,7 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/ini.v1 v1.42.0 h1:7N3gPTt50s8GuLortA00n8AqRTk75qOP98+mTPpgzRk= gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= diff --git a/starlark/runtime/runtime.go b/starlark/runtime/runtime.go index 33b26f2..1e20d92 100644 --- a/starlark/runtime/runtime.go +++ b/starlark/runtime/runtime.go @@ -84,6 +84,9 @@ func (r *Runtime) ExecFile(filename string) (starlark.StringDict, error) { func (r *Runtime) REPL() { thread := &starlark.Thread{Name: "thread", Load: r.load} + thread.SetLocal("base_path", r.path) + thread.SetLocal(types.PluginManagerLocal, r.pm) + repl.REPL(thread, r.predeclared) }