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:
@@ -1,3 +0,0 @@
|
||||
data "scaffolding_example" "example" {
|
||||
configurable_attribute = "some-value"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
data "virtfusion_hypervisors" "all" {}
|
||||
|
||||
output "hypervisor_names" {
|
||||
value = [for h in data.virtfusion_hypervisors.all.hypervisors : h.name]
|
||||
}
|
||||
5
examples/data-sources/virtfusion_packages/data-source.tf
Normal file
5
examples/data-sources/virtfusion_packages/data-source.tf
Normal file
@@ -0,0 +1,5 @@
|
||||
data "virtfusion_packages" "all" {}
|
||||
|
||||
output "package_names" {
|
||||
value = [for p in data.virtfusion_packages.all.packages : p.name]
|
||||
}
|
||||
7
examples/data-sources/virtfusion_server/data-source.tf
Normal file
7
examples/data-sources/virtfusion_server/data-source.tf
Normal file
@@ -0,0 +1,7 @@
|
||||
data "virtfusion_server" "example" {
|
||||
id = 1
|
||||
}
|
||||
|
||||
output "server_name" {
|
||||
value = data.virtfusion_server.example.name
|
||||
}
|
||||
@@ -1,4 +1,9 @@
|
||||
provider "virtfusion" {
|
||||
endpoint = "example.com"
|
||||
api_token = "myapikey"
|
||||
endpoint = "https://cp.example.com"
|
||||
api_token = var.virtfusion_api_token
|
||||
}
|
||||
|
||||
variable "virtfusion_api_token" {
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
resource "virtfusion_build" "node1" {
|
||||
server_id = virtfusion_server.node1.id
|
||||
name = "node1-demo"
|
||||
hostname = "node1.example.com"
|
||||
osid = 1
|
||||
vnc = true
|
||||
ipv6 = true
|
||||
ssh_keys = [virtfusion_ssh.dummy_key.id]
|
||||
email = true
|
||||
}
|
||||
@@ -12,3 +12,7 @@ resource "virtfusion_server" "node1" {
|
||||
storage_profile = 1
|
||||
network_profile = 1
|
||||
}
|
||||
|
||||
output "server_id" {
|
||||
value = virtfusion_server.node1.id
|
||||
}
|
||||
|
||||
10
examples/resources/virtfusion_server_build/resource.tf
Normal file
10
examples/resources/virtfusion_server_build/resource.tf
Normal file
@@ -0,0 +1,10 @@
|
||||
resource "virtfusion_server_build" "node1_build" {
|
||||
server_id = virtfusion_server.node1.id
|
||||
name = "my-server"
|
||||
hostname = "my-server.example.com"
|
||||
osid = 1
|
||||
vnc = true
|
||||
ipv6 = false
|
||||
ssh_keys = [virtfusion_ssh_key.mykey.id]
|
||||
email = false
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
resource "virtfusion_ssh" "dummy_key" {
|
||||
# This is what is displayed in the UI on the SSH keys page.
|
||||
name = "dummy_key"
|
||||
|
||||
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCRM5gzj6BpVbTEZ8XX5meQOC9X+znTMCQbXTfdqm9IP3HY2JbqH+yfCBWSsLpXim6WvsYtfkAhrtrkdmaX66Wn1uo6XvARwi/5D1VRTM94vwoitJb0rne4OorpwGIGCpDIi1iRA/ERIbAIQpw/2PJfm7q+fEj9TS+n/MzYOOmwTaKPEJ8+wHwXbjcSNoBQmEPonafbQKQN5PXe5rwnTNAqJWhGPHqF2t7lvZy+m7Sl7X1vUVlw+7iZzOVm9iDXmUInc8A0kz18l/O+4ELhRxxzjmSX5/KkN0GG7wS7CHlq9MS2741MS6p0ZNMgTT/04RfsY5JXoOa1gCeAdnXQST9ylvBd6hXubV95lRM8AXAhEJFHpa0Xn1gHMJ4F0cjjvmBIDx39QztuYsNJPk8veBBQwhOzhnJ3Zh2IYTQD+Mwu5yUrJzUt7ia8X5fhjbrYlfUgdH+siBbvJRzyXwnZdHArher55U4xPCJO4qRrFr72Jn+WGzkcY53oLnW5K3NnPaYViCJD2BgJZU1YF8oA3RyEG+2GS7Ksqs2nXXlZ1c+RXLUXM0pxDrwqvYrE3Ae+O/PtZ0cqpesyjxDfH/R2cj86jjdEi7S8nhgkumHwkoac8LCJnoAeC9S7sxmI99VBHcNwCazx3ZL2UAI3Ik/DQBZXcCPXw9MfY25SyQwEYftMKw== dummy_key"
|
||||
|
||||
# This is the user ID that the key will be associated with.
|
||||
user_id = 1
|
||||
}
|
||||
9
examples/resources/virtfusion_ssh_key/resource.tf
Normal file
9
examples/resources/virtfusion_ssh_key/resource.tf
Normal file
@@ -0,0 +1,9 @@
|
||||
resource "virtfusion_ssh_key" "mykey" {
|
||||
user_id = 1
|
||||
name = "my-ssh-key"
|
||||
public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExample user@example.com"
|
||||
}
|
||||
|
||||
output "ssh_key_id" {
|
||||
value = virtfusion_ssh_key.mykey.id
|
||||
}
|
||||
5
examples/resources/virtfusion_user/resource.tf
Normal file
5
examples/resources/virtfusion_user/resource.tf
Normal file
@@ -0,0 +1,5 @@
|
||||
resource "virtfusion_user" "customer1" {
|
||||
name = "John Doe"
|
||||
email = "john@example.com"
|
||||
ext_relation_id = "cust-12345"
|
||||
}
|
||||
Reference in New Issue
Block a user