refactor: use vscode workspace to better support go modules in devcontainer

This allows gopls to handle autocompletion by setting multiple workspace roots it can traverse for dependencies.
This commit is contained in:
Jose Diaz-Gonzalez
2022-01-22 02:52:08 -05:00
parent 3bb8812e33
commit d3b01ffb2f
4 changed files with 118 additions and 33 deletions

View File

@@ -21,6 +21,6 @@ RUN make ci-dependencies
COPY . .
ENV DOKKU_HOSTNAME=dokku.me GOROOT=/usr/local/go PATH=/usr/local/go/bin:$PATH PLUGIN_MAKE_TARGET=build
ENV DOKKU_HOSTNAME=dokku.me GOROOT=/usr/local/go PATH=/usr/local/go/bin:/root/go/bin:$PATH PLUGIN_MAKE_TARGET=build
LABEL org.label-schema.schema-version=1.0 org.label-schema.vendor=dokku com.dokku.devcontainer=true

View File

@@ -1,31 +0,0 @@
#!/usr/bin/env bash
set -x
main() {
find plugins/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | while read plugin; do
if [[ ! -f "plugins/$plugin/go.mod" ]]; then
continue
fi
pushd "plugins/$plugin" >/dev/null || return 1
echo "====> Cloning all modules $plugin"
go list -m -f '{{define "M"}}git clone https://{{.Path}}.git /root/go/src/{{.Path}} || true{{end}}{{if not .Main}}{{if not .Replace}}{{template "M" .}}{{end}}{{end}}' all >tmp-file
bash tmp-file
rm tmp-file
popd >/dev/null || return 1
done
git clone --branch v2 https://github.com/go-yaml/yaml.git /root/go/src/gopkg.in/yaml.v2 || true
git clone --branch v3 https://github.com/robfig/cron /root/go/src/github.com/robfig/cron/v3 || true
git clone https://github.com/golang/net /root/go/src/golang.org/x/net || true
git clone https://github.com/golang/protobuf.git /root/go/src/github.com/golang/protobuf || true
git clone https://github.com/golang/sync /root/go/src/golang.org/x/sync || true
git clone https://github.com/golang/sys.git /root/go/src/golang.org/x/sys || true
git clone https://github.com/golang/text.git /root/go/src/golang.org/x/text || true
git clone https://github.com/googleapis/go-genproto.git /root/go/src/google.golang.org/genproto || true
git clone https://github.com/grpc/grpc-go.git /root/go/src/google.golang.org/grpc || true
git clone https://github.com/onsi/gomega /root/go/src/github.com/onsi/gomega || true
git clone https://github.com/protocolbuffers/protobuf-go.git /root/go/src/google.golang.org/protobuf || true
}
main "$@"

View File

@@ -18,7 +18,7 @@
"source=${localWorkspaceFolder}/tmp/data/,target=/mnt/dokku/,type=bind"
],
"overrideCommand": false,
"postCreateCommand": "make setup-deploy-tests && go-mod-downloadall",
"postCreateCommand": "make setup-deploy-tests",
"runArgs": ["--init"],
"workspaceFolder": "/root/go/src/github.com/dokku/dokku",
"workspaceMount": "type=bind,source=${localWorkspaceFolder},target=/root/go/src/github.com/dokku/dokku,consistency=cached"

116
workspace.code-workspace Normal file
View File

@@ -0,0 +1,116 @@
{
"folders": [
{
"path": "."
},
{
"path": "plugins/00_dokku-standard"
},
{
"path": "plugins/20_events"
},
{
"path": "plugins/app-json"
},
{
"path": "plugins/apps"
},
{
"path": "plugins/builder"
},
{
"path": "plugins/builder-dockerfile"
},
{
"path": "plugins/builder-herokuish"
},
{
"path": "plugins/builder-null"
},
{
"path": "plugins/builder-pack"
},
{
"path": "plugins/buildpacks"
},
{
"path": "plugins/certs"
},
{
"path": "plugins/checks"
},
{
"path": "plugins/common"
},
{
"path": "plugins/config"
},
{
"path": "plugins/cron"
},
{
"path": "plugins/docker-options"
},
{
"path": "plugins/domains"
},
{
"path": "plugins/enter"
},
{
"path": "plugins/git"
},
{
"path": "plugins/logs"
},
{
"path": "plugins/network"
},
{
"path": "plugins/nginx-vhosts"
},
{
"path": "plugins/plugin"
},
{
"path": "plugins/proxy"
},
{
"path": "plugins/ps"
},
{
"path": "plugins/registry"
},
{
"path": "plugins/repo"
},
{
"path": "plugins/resource"
},
{
"path": "plugins/run"
},
{
"path": "plugins/scheduler"
},
{
"path": "plugins/scheduler-docker-local"
},
{
"path": "plugins/scheduler-null"
},
{
"path": "plugins/shell"
},
{
"path": "plugins/ssh-keys"
},
{
"path": "plugins/storage"
},
{
"path": "plugins/trace"
}
],
"settings": {}
}