From d3b01ffb2fea4f94dc5e606663bd97cc54f19fd6 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 22 Jan 2022 02:52:08 -0500 Subject: [PATCH] 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. --- .devcontainer/Dockerfile | 2 +- .devcontainer/bin/go-mod-downloadall | 31 ------- .devcontainer/devcontainer.json | 2 +- workspace.code-workspace | 116 +++++++++++++++++++++++++++ 4 files changed, 118 insertions(+), 33 deletions(-) delete mode 100755 .devcontainer/bin/go-mod-downloadall create mode 100644 workspace.code-workspace diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index b324f3097..9f09bd79f 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -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 diff --git a/.devcontainer/bin/go-mod-downloadall b/.devcontainer/bin/go-mod-downloadall deleted file mode 100755 index db605cf53..000000000 --- a/.devcontainer/bin/go-mod-downloadall +++ /dev/null @@ -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 "$@" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index db695e264..b1112f0be 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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" diff --git a/workspace.code-workspace b/workspace.code-workspace new file mode 100644 index 000000000..050d9fded --- /dev/null +++ b/workspace.code-workspace @@ -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": {} +} \ No newline at end of file