From 524ce9b7d72e118f5c1f05a77690b053ac316105 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 22 Oct 2022 16:46:49 -0400 Subject: [PATCH] feat: download all src files for go mod dependencies for use in vscode Without this, the LSP within the container continually complains that the source for go files cannot be found. While this method isn't _exactly_ correct, it does help with development. --- .devcontainer/bin/download-go-mod | 25 +++++++++++++++++++++++++ .devcontainer/devcontainer.json | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100755 .devcontainer/bin/download-go-mod diff --git a/.devcontainer/bin/download-go-mod b/.devcontainer/bin/download-go-mod new file mode 100755 index 000000000..f2804e440 --- /dev/null +++ b/.devcontainer/bin/download-go-mod @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +main() { + declare PLUGIN_NAME="$1" + local plugin_root="/root/go/src/github.com/dokku/dokku/plugins" + + export GO111MODULE=off + echo "-----> Fetching onsi/gomega dependency for tests" + go get github.com/onsi/gomega || true + + echo "-----> Fetching spf13/pflag dependency for subcommands" + go get github.com/spf13/pflag || true + pushd "$plugin_root" >/dev/null + find "$plugin_root/" -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | while read -r plugin; do + pushd "$plugin_root/$plugin" >/dev/null + if [[ -f "go.mod" ]]; then + echo "-----> Fetching dependencies for $plugin plugin" + go get || true + fi + popd >/dev/null + done + popd >/dev/null +} + +main "$@" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b1112f0be..c29fc4a38 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", + "postCreateCommand": "download-go-mod && 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"