Skip to content

Commit

Permalink
chore: v6provider setup + ip resource and data source (#110)
Browse files Browse the repository at this point in the history
* chore: v6_provider setup with resource_ip and datasource_ip
  • Loading branch information
ikadix authored Nov 9, 2023
1 parent 38a6fee commit c5d68c4
Show file tree
Hide file tree
Showing 32 changed files with 6,229 additions and 276 deletions.
9 changes: 3 additions & 6 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,12 @@ provider "katapult" {
<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `api_key` (String, Sensitive) API Key for Katapult Core API. Can be specified with the `KATAPULT_API_KEY` environment variable.
- `data_center` (String) Data center permalink. Can be specified with the `KATAPULT_DATA_CENTER` environment variable.
- `organization` (String) Organization sub-domain. Can be specified with the `KATAPULT_ORGANIZATION` environment variable.

### Optional

- `api_key` (String, Sensitive) **REQUIRED** via config or environment variable. API Key for Katapult Core API. Can be specified with the `KATAPULT_API_KEY` environment variable.
- `data_center` (String) **REQUIRED** via config or environment variable. Data center permalink. Can be specified with the `KATAPULT_DATA_CENTER` environment variable.
- `log_level` (String) Log level used by Katapult Terraform provider. Can be specified with the `KATAPULT_LOG_LEVEL` environment variable. Defaults to `info`.
- `organization` (String) **REQUIRED** via config or environment variable. Organization sub-domain. Can be specified with the `KATAPULT_ORGANIZATION` environment variable.
- `skip_trash_object_purge` (Boolean) Skip purging deleted resources from Katapult's trash when they are destroyed by Terraform. Only relevant to some resources which are moved to the trash when they are deleted. Can be specified with the
`KATAPULT_SKIP_TRASH_OBJECT_PURGE` environment variable. Defaults to `false`.

Expand Down
4 changes: 2 additions & 2 deletions docs/resources/ip.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ resource "katapult_ip" "primary-db" {

- `label` (String) VIP label. Required when **vip** is `true`.
- `network_id` (String)
- `version` (Number) IPv4 or IPv6. Defaults to `4`.
- `vip` (Boolean) Defaults to `false`.
- `version` (Number) IPv4 or IPv6. Default is `4`.
- `vip` (Boolean) Default is `false`.

### Read-Only

Expand Down
7 changes: 7 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ require (
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/go-hclog v1.5.0
github.com/hashicorp/go-retryablehttp v0.7.4
github.com/hashicorp/terraform-plugin-framework v1.4.2
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0
github.com/hashicorp/terraform-plugin-go v0.19.0
github.com/hashicorp/terraform-plugin-mux v0.12.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0
github.com/hashicorp/terraform-plugin-testing v1.5.1
github.com/jimeh/rands v0.3.0
github.com/jimeh/undent v1.1.1
github.com/krystal/go-katapult v0.2.1
Expand Down Expand Up @@ -43,6 +46,8 @@ require (
github.com/hashicorp/terraform-registry-address v0.2.2 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/kr/pretty v0.2.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
Expand All @@ -58,6 +63,7 @@ require (
github.com/zclconf/go-cty v1.14.1 // indirect
go.mongodb.org/mongo-driver v1.12.1 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
Expand All @@ -66,6 +72,7 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
18 changes: 15 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7N
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/cloudflare/circl v1.3.6 h1:/xbKIqSHbZXHwkhbrhrt2YOHIwYJlXH94E3tI/gDlUg=
github.com/cloudflare/circl v1.3.6/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down Expand Up @@ -77,6 +78,10 @@ github.com/hashicorp/terraform-exec v0.19.0 h1:FpqZ6n50Tk95mItTSS9BjeOVUb4eg81Sp
github.com/hashicorp/terraform-exec v0.19.0/go.mod h1:tbxUpe3JKruE9Cuf65mycSIT8KiNPZ0FkuTE3H4urQg=
github.com/hashicorp/terraform-json v0.17.1 h1:eMfvh/uWggKmY7Pmb3T85u86E2EQg6EQHgyRwf3RkyA=
github.com/hashicorp/terraform-json v0.17.1/go.mod h1:Huy6zt6euxaY9knPAFKjUITn8QxUFIe9VuSzb4zn/0o=
github.com/hashicorp/terraform-plugin-framework v1.4.2 h1:P7a7VP1GZbjc4rv921Xy5OckzhoiO3ig6SGxwelD2sI=
github.com/hashicorp/terraform-plugin-framework v1.4.2/go.mod h1:GWl3InPFZi2wVQmdVnINPKys09s9mLmTZr95/ngLnbY=
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 h1:HOjBuMbOEzl7snOdOoUfE2Jgeto6JOjLVQ39Ls2nksc=
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0/go.mod h1:jfHGE/gzjxYz6XoUwi/aYiiKrJDeutQNUtGQXkaHklg=
github.com/hashicorp/terraform-plugin-go v0.19.0 h1:BuZx/6Cp+lkmiG0cOBk6Zps0Cb2tmqQpDM3iAtnhDQU=
github.com/hashicorp/terraform-plugin-go v0.19.0/go.mod h1:EhRSkEPNoylLQntYsk5KrDHTZJh9HQoumZXbOGOXmec=
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
Expand All @@ -85,6 +90,8 @@ github.com/hashicorp/terraform-plugin-mux v0.12.0 h1:TJlmeslQ11WlQtIFAfth0vXx+gS
github.com/hashicorp/terraform-plugin-mux v0.12.0/go.mod h1:8MR0AgmV+Q03DIjyrAKxXyYlq2EUnYBQP8gxAAA0zeM=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0 h1:wcOKYwPI9IorAJEBLzgclh3xVolO7ZorYd6U1vnok14=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0/go.mod h1:qH/34G25Ugdj5FcM95cSoXzUgIbgfhVLXCcEcYaMwq8=
github.com/hashicorp/terraform-plugin-testing v1.5.1 h1:T4aQh9JAhmWo4+t1A7x+rnxAJHCDIYW9kXyo4sVO92c=
github.com/hashicorp/terraform-plugin-testing v1.5.1/go.mod h1:dg8clO6K59rZ8w9EshBmDp1CxTIPu3yA4iaDpX1h5u0=
github.com/hashicorp/terraform-registry-address v0.2.2 h1:lPQBg403El8PPicg/qONZJDC6YlgCVbWDtNmmZKtBno=
github.com/hashicorp/terraform-registry-address v0.2.2/go.mod h1:LtwNbCihUoUZ3RYriyS2wF/lGPB6gF9ICLRtuDk7hSo=
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
Expand All @@ -100,11 +107,13 @@ github.com/jimeh/undent v1.1.1 h1:ZAzvd2DDx7gxQvOMGkQjfeRx9gRPIXe2cq+8ZNiGKaM=
github.com/jimeh/undent v1.1.1/go.mod h1:oxYCIzdbyQNy8GXnCnjRJ2NS6Uq4p4yWoeawiGFqoHI=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/krystal/go-katapult v0.2.1 h1:UltHtVShIrqX/6jx7PHLKEJBH7KAsme2veHku7O5TBg=
github.com/krystal/go-katapult v0.2.1/go.mod h1:yTy0Lx0qpwK8RwhOHqmsGJhMcDlcg00AswfJWh1yw3w=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
Expand Down Expand Up @@ -173,6 +182,8 @@ golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2Uz
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 h1:EDuYyU/MkFXllv9QF9819VlI9a4tzGuCbhG0ExK9o1U=
golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
Expand Down Expand Up @@ -245,8 +256,9 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
Expand Down
12 changes: 6 additions & 6 deletions internal/provider/data_source_file_storage_volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ func TestAccKatapultDataSourceFileStorageVolume_associations(t *testing.T) {
Steps: []resource.TestStep{
{
Config: undent.Stringf(`
resource "katapult_ip" "web" {}
resource "katapult_legacy_ip" "web" {}
resource "katapult_virtual_machine" "web" {
hostname = "%s-web"
package = "rock-3"
disk_template = "ubuntu-18-04"
disk_template_options = {
install_agent = true
}
ip_address_ids = [katapult_ip.web.id]
ip_address_ids = [katapult_legacy_ip.web.id]
}
resource "katapult_file_storage_volume" "my_vol" {
Expand Down Expand Up @@ -117,26 +117,26 @@ func TestAccKatapultDataSourceFileStorageVolume_associations(t *testing.T) {
},
{
Config: undent.Stringf(`
resource "katapult_ip" "web" {}
resource "katapult_legacy_ip" "web" {}
resource "katapult_virtual_machine" "web" {
hostname = "%s-web"
package = "rock-3"
disk_template = "ubuntu-18-04"
disk_template_options = {
install_agent = true
}
ip_address_ids = [katapult_ip.web.id]
ip_address_ids = [katapult_legacy_ip.web.id]
}
resource "katapult_ip" "db" {}
resource "katapult_legacy_ip" "db" {}
resource "katapult_virtual_machine" "db" {
hostname = "%s-db"
package = "rock-3"
disk_template = "ubuntu-18-04"
disk_template_options = {
install_agent = true
}
ip_address_ids = [katapult_ip.db.id]
ip_address_ids = [katapult_legacy_ip.db.id]
}
resource "katapult_file_storage_volume" "my_vol" {
Expand Down
69 changes: 0 additions & 69 deletions internal/provider/data_source_ip.go

This file was deleted.

16 changes: 8 additions & 8 deletions internal/provider/data_source_virtual_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestAccKatapultDataSourceVirtualMachine_by_id(t *testing.T) {
Steps: []resource.TestStep{
{
Config: undent.Stringf(`
resource "katapult_ip" "web" {}
resource "katapult_legacy_ip" "web" {}
resource "katapult_virtual_machine_group" "web" {
name = "%s"
Expand All @@ -38,7 +38,7 @@ func TestAccKatapultDataSourceVirtualMachine_by_id(t *testing.T) {
disk_template_options = {
install_agent = true
}
ip_address_ids = [katapult_ip.web.id]
ip_address_ids = [katapult_legacy_ip.web.id]
group_id = katapult_virtual_machine_group.web.id
tags = ["web", "public"]
network_speed_profile = "1gbps"
Expand Down Expand Up @@ -78,11 +78,11 @@ func TestAccKatapultDataSourceVirtualMachine_by_id(t *testing.T) {
),
resource.TestCheckTypeSetElemAttrPair(
"data.katapult_virtual_machine.src", "ip_address_ids.*",
"katapult_ip.web", "id",
"katapult_legacy_ip.web", "id",
),
resource.TestCheckTypeSetElemAttrPair(
"data.katapult_virtual_machine.src", "ip_addresses.*",
"katapult_ip.web", "address",
"katapult_legacy_ip.web", "address",
),
resource.TestCheckTypeSetElemAttrPair(
"data.katapult_virtual_machine.src", "group_id",
Expand Down Expand Up @@ -123,7 +123,7 @@ func TestAccKatapultDataSourceVirtualMachine_by_fqdn(t *testing.T) {
Steps: []resource.TestStep{
{
Config: undent.Stringf(`
resource "katapult_ip" "web" {}
resource "katapult_legacy_ip" "web" {}
resource "katapult_virtual_machine_group" "web" {
name = "%s"
Expand All @@ -138,7 +138,7 @@ func TestAccKatapultDataSourceVirtualMachine_by_fqdn(t *testing.T) {
disk_template_options = {
install_agent = true
}
ip_address_ids = [katapult_ip.web.id]
ip_address_ids = [katapult_legacy_ip.web.id]
group_id = katapult_virtual_machine_group.web.id
tags = ["web", "public"]
network_speed_profile = "1gbps"
Expand Down Expand Up @@ -178,11 +178,11 @@ func TestAccKatapultDataSourceVirtualMachine_by_fqdn(t *testing.T) {
),
resource.TestCheckTypeSetElemAttrPair(
"data.katapult_virtual_machine.src", "ip_address_ids.*",
"katapult_ip.web", "id",
"katapult_legacy_ip.web", "id",
),
resource.TestCheckTypeSetElemAttrPair(
"data.katapult_virtual_machine.src", "ip_addresses.*",
"katapult_ip.web", "address",
"katapult_legacy_ip.web", "address",
),
resource.TestCheckTypeSetElemAttrPair(
"data.katapult_virtual_machine.src", "group_id",
Expand Down
Loading

0 comments on commit c5d68c4

Please sign in to comment.