Overhaul VirtFusion provider: 20 resources, 30 data sources, multipage pagination

Complete rewrite of the VirtFusion Terraform provider with full API coverage:

- 20 managed resources (server, build, SSH key, user, firewall, IP blocks, etc.)
- 30 data sources (hypervisors, packages, servers, IP blocks, self-service, etc.)
- New HTTP client with proper error handling, query parameter support, and
  automatic multipage pagination via GetAllPages (fetches all pages from
  Laravel-style paginated endpoints and merges into a single response)
- Fixed type mismatches against live API: ServerData.Suspended (int→bool),
  IPBlockData.Type (string→int), PackageData json tags (primaryStorage, etc.),
  ServerData nested CPU/Settings/Resources structure, HypervisorGroupResources
  array response
- Configurable results-per-page (default 300) on all list data sources
- Migrated CI from GitHub Actions to Gitea Actions
- Updated goreleaser config, go.mod dependencies, and examples

Verified against live VirtFusion instance at cp.vps.ezscale.tech:
all data sources return correct data with full pagination support.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-16 02:01:16 -04:00
parent a3a16f46fa
commit 6b7430b67b
92 changed files with 18443 additions and 1488 deletions

33
.gitea/workflows/ci.yaml Normal file
View File

@@ -0,0 +1,33 @@
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build
run: go build -v ./...
- name: Lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
- name: Test
run: go test -race -v ./internal/...
- name: Check go generate
run: |
go generate ./...
git diff --exit-code || (echo "go generate produced changes; please run 'go generate ./...' and commit" && exit 1)

View File

@@ -0,0 +1,22 @@
name: Endpoint Sync Check
on:
schedule:
- cron: '0 9 * * 1'
push:
paths:
- 'openapi.yaml'
workflow_dispatch:
jobs:
check-drift:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Check endpoint drift
run: go run ./scripts/check-endpoint-drift.go

View File

@@ -0,0 +1,49 @@
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- name: Check endpoint drift
run: go run ./scripts/check-endpoint-drift.go
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
- name: Create Gitea release
if: success()
run: |
TAG="${GITHUB_REF#refs/tags/}"
curl -s -X POST \
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\": \"${TAG}\", \"name\": \"${TAG}\", \"body\": \"Release ${TAG} — see GitHub mirror for artifacts.\"}" \
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases"

View File

@@ -0,0 +1,25 @@
name: Version Check
on:
pull_request:
paths:
- 'main.go'
- 'internal/**'
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check version bump
run: |
BASE_VERSION=$(git show origin/${{ github.base_ref }}:main.go | grep -oP 'version string = "\K[^"]+')
HEAD_VERSION=$(grep -oP 'version string = "\K[^"]+' main.go)
if [ "$BASE_VERSION" = "$HEAD_VERSION" ]; then
echo "::warning::Version in main.go has not been bumped (still ${HEAD_VERSION}). Consider updating it for this release."
else
echo "Version bumped: ${BASE_VERSION} → ${HEAD_VERSION}"
fi