mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-06-29 18:21:10 +00:00
chore(ci): improve devcontainer UX (#1973)
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
b1b8d1570f
commit
d8a7bc093f
17
.devcontainer/Dockerfile
Normal file
17
.devcontainer/Dockerfile
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
FROM golang:1.24.3
|
||||||
|
|
||||||
|
ARG GOLANGCI_LINT_VERSION=2.1.6 # renovate: depName=golangci/golangci-lint datasource=github-releases
|
||||||
|
|
||||||
|
RUN apt update && apt upgrade -y && \
|
||||||
|
apt-get install --no-install-recommends -y ca-certificates curl gnupg lsb-release jq zsh neovim && \
|
||||||
|
chsh -s $(which zsh) && \
|
||||||
|
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin v${GOLANGCI_LINT_VERSION}
|
||||||
|
|
||||||
|
|
||||||
|
RUN curl --proto '=https' --tlsv1.2 -fsSL https://get.opentofu.org/install-opentofu.sh -o install-opentofu.sh && \
|
||||||
|
chmod +x install-opentofu.sh && \
|
||||||
|
./install-opentofu.sh --install-method deb && \
|
||||||
|
rm -f install-opentofu.sh
|
@ -3,27 +3,75 @@
|
|||||||
{
|
{
|
||||||
"name": "Default Linux Universal",
|
"name": "Default Linux Universal",
|
||||||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
||||||
"image": "mcr.microsoft.com/devcontainers/go:1.24-bullseye",
|
"dockerFile": "Dockerfile",
|
||||||
|
|
||||||
// Features to add to the dev container. More info: https://containers.dev/features.
|
// Features to add to the dev container. More info: https://containers.dev/features.
|
||||||
"features": {
|
"features": {
|
||||||
"ghcr.io/devcontainers/features/terraform:1": {
|
"ghcr.io/devcontainers/features/terraform:1": {}
|
||||||
"version": "1.10.3"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"postAttachCommand": ["bash", "./.devcontainer/post-attach.sh"],
|
"mounts": [
|
||||||
|
// Zsh commands history persistence
|
||||||
|
{
|
||||||
|
"source": "${localEnv:HOME}/.zsh_history",
|
||||||
|
"target": "/root/.zsh_history",
|
||||||
|
"type": "bind"
|
||||||
|
},
|
||||||
|
// Git configuration file
|
||||||
|
{
|
||||||
|
"source": "${localEnv:HOME}/.gitconfig",
|
||||||
|
"target": "/root/.gitconfig",
|
||||||
|
"type": "bind"
|
||||||
|
},
|
||||||
|
// SSH directory for Linux, OSX and WSL
|
||||||
|
// On Linux and OSX, a symlink /mnt/ssh <-> ~/.ssh is
|
||||||
|
// created in the container. On Windows, files are copied
|
||||||
|
// from /mnt/ssh to ~/.ssh to fix permissions.
|
||||||
|
{
|
||||||
|
"source": "${localEnv:HOME}/.ssh",
|
||||||
|
"target": "/mnt/ssh",
|
||||||
|
"type": "bind"
|
||||||
|
},
|
||||||
|
// Docker socket to access the host Docker server
|
||||||
|
{
|
||||||
|
"source": "/var/run/docker.sock",
|
||||||
|
"target": "/var/run/docker.sock",
|
||||||
|
"type": "bind"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||||
// "forwardPorts": [],
|
// "forwardPorts": [],
|
||||||
|
|
||||||
// Configure tool-specific properties.
|
// Configure tool-specific properties.
|
||||||
// "customizations": {},
|
"customizations": {
|
||||||
|
// Configure properties specific to VS Code.
|
||||||
|
"vscode": {
|
||||||
|
// Set *default* container specific settings.json values on container create.
|
||||||
|
"settings": {
|
||||||
|
"go.toolsManagement.checkForUpdates": "local",
|
||||||
|
"go.useLanguageServer": true
|
||||||
|
},
|
||||||
|
// Add the IDs of extensions you want installed when the container is created.
|
||||||
|
"extensions": [
|
||||||
|
"britesnow.vscode-toggle-quotes",
|
||||||
|
"davidanson.vscode-markdownlint",
|
||||||
|
"EditorConfig.editorconfig",
|
||||||
|
"golang.go",
|
||||||
|
"hashicorp.terraform",
|
||||||
|
"joshbolduc.commitlint",
|
||||||
|
"ms-azuretools.vscode-docker",
|
||||||
|
"ms-vscode.makefile-tools",
|
||||||
|
"psioniq.psi-header"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
||||||
// "remoteUser": "root"
|
"remoteUser": "root",
|
||||||
|
|
||||||
|
"postAttachCommand": ["bash", "./.devcontainer/post-attach.sh"],
|
||||||
|
|
||||||
// Use 'postCreateCommand' to run commands after the container is created.
|
// Use 'postCreateCommand' to run commands after the container is created.
|
||||||
"postCreateCommand": "make build"
|
"postCreateCommand": "make build"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,21 @@
|
|||||||
#!/usr/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Display welcome banner
|
||||||
|
echo -e "\033[1;36m"
|
||||||
|
echo "════════════════════════════════════════════════════════════════════════════════════════════"
|
||||||
|
echo
|
||||||
|
echo " 🚀 Terraform Provider For Proxmox Development Environment"
|
||||||
|
echo
|
||||||
|
echo " ⚠️ EXPERIMENTAL"
|
||||||
|
echo " Use at your own risk! Some tools may be missing or not work as expected."
|
||||||
|
echo
|
||||||
|
echo " • Go Version: $(go version | cut -d' ' -f3 | sed 's/^go//')"
|
||||||
|
echo " • Terraform Version: $(terraform version -json | jq -r '.terraform_version')"
|
||||||
|
echo " • OpenTofu Version: $(tofu version -json | jq -r '.terraform_version')"
|
||||||
|
echo " • Working Directory: $(pwd)"
|
||||||
|
echo
|
||||||
|
echo "════════════════════════════════════════════════════════════════════════════════════════════"
|
||||||
|
echo -e "\033[0m"
|
||||||
|
|
||||||
# Workaround for https://github.com/orgs/community/discussions/75161
|
# Workaround for https://github.com/orgs/community/discussions/75161
|
||||||
unset GIT_COMMITTER_NAME
|
unset GIT_COMMITTER_NAME
|
||||||
|
3
.vscode/extensions.json
vendored
3
.vscode/extensions.json
vendored
@ -7,6 +7,7 @@
|
|||||||
"hashicorp.terraform",
|
"hashicorp.terraform",
|
||||||
"joshbolduc.commitlint",
|
"joshbolduc.commitlint",
|
||||||
"PKief.material-icon-theme",
|
"PKief.material-icon-theme",
|
||||||
"psioniq.psi-header"
|
"psioniq.psi-header",
|
||||||
|
"ms-azuretools.vscode-docker"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,20 @@ make docs
|
|||||||
|
|
||||||
If you are using VS Code, feel free to copy `settings.json` from `.vscode/settings.example.json`.
|
If you are using VS Code, feel free to copy `settings.json` from `.vscode/settings.example.json`.
|
||||||
|
|
||||||
|
## Devcontainer support
|
||||||
|
|
||||||
|
Prerequisites:
|
||||||
|
|
||||||
|
- Docker (or Docker Desktop) installed on your machine
|
||||||
|
- [VS Code Remote - Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
|
||||||
|
|
||||||
|
To launch the devcontainer:
|
||||||
|
|
||||||
|
1. Open the project in VS Code.
|
||||||
|
2. Run **Remote-Containers: Open Folder in Container** from the Command Palette.
|
||||||
|
|
||||||
|
See [Developing inside a Container](https://code.visualstudio.com/docs/devcontainers/containers) for more details.
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
### Unit Tests
|
### Unit Tests
|
||||||
|
16
Makefile
16
Makefile
@ -3,7 +3,7 @@ TARGETS=darwin linux windows
|
|||||||
TERRAFORM_PLUGIN_EXTENSION=
|
TERRAFORM_PLUGIN_EXTENSION=
|
||||||
VERSION=0.78.0# x-release-please-version
|
VERSION=0.78.0# x-release-please-version
|
||||||
|
|
||||||
GOLANGCI_LINT_VERSION=v2.1.6# renovate: depName=golangci/golangci-lint datasource=github-releases
|
GOLANGCI_LINT_VERSION=2.1.6# renovate: depName=golangci/golangci-lint datasource=github-releases
|
||||||
|
|
||||||
# check if opentofu is installed and use it if it is,
|
# check if opentofu is installed and use it if it is,
|
||||||
# otherwise use terraform
|
# otherwise use terraform
|
||||||
@ -110,10 +110,18 @@ testacc:
|
|||||||
@TF_ACC=1 env $$(cat testacc.env | xargs) go test --timeout=30m --tags=acceptance -count=1 -v github.com/bpg/terraform-provider-proxmox/fwprovider/...
|
@TF_ACC=1 env $$(cat testacc.env | xargs) go test --timeout=30m --tags=acceptance -count=1 -v github.com/bpg/terraform-provider-proxmox/fwprovider/...
|
||||||
|
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint:
|
lint: ensure-golangci-lint
|
||||||
# NOTE: This target is for local runs only. For linting in CI see .github/workflows/golangci-lint.yml
|
# NOTE: This target is for local runs only. For linting in CI see .github/workflows/golangci-lint.yml
|
||||||
@docker run -t --rm -v $$(pwd):/app -v ~/.cache/golangci-lint/$(GOLANGCI_LINT_VERSION):/root/.cache -w /app golangci/golangci-lint:$(GOLANGCI_LINT_VERSION) golangci-lint fmt
|
golangci-lint fmt
|
||||||
@docker run -t --rm -v $$(pwd):/app -v ~/.cache/golangci-lint/$(GOLANGCI_LINT_VERSION):/root/.cache -w /app golangci/golangci-lint:$(GOLANGCI_LINT_VERSION) golangci-lint run --fix
|
golangci-lint run --fix
|
||||||
|
|
||||||
|
.PHONY: ensure-golangci-lint
|
||||||
|
ensure-golangci-lint:
|
||||||
|
@CURRENT_VERSION=$$(golangci-lint version --short 2>/dev/null | sed 's/^v//' || echo "not installed"); \
|
||||||
|
if [ "$$CURRENT_VERSION" != "$(GOLANGCI_LINT_VERSION)" ]; then \
|
||||||
|
echo "Installing golangci-lint $(GOLANGCI_LINT_VERSION) (current: $$CURRENT_VERSION)"; \
|
||||||
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v$(GOLANGCI_LINT_VERSION); \
|
||||||
|
fi
|
||||||
|
|
||||||
.PHONY: release-build
|
.PHONY: release-build
|
||||||
release-build:
|
release-build:
|
||||||
|
Loading…
Reference in New Issue
Block a user