Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "description" to "cloudconnexa_network" resource #11

Merged
merged 8 commits into from
Jul 3, 2024

Conversation

sahaqaa
Copy link
Contributor

@sahaqaa sahaqaa commented Jul 2, 2024

This PR is intended to fix next issue: OpenVPN/cloudconnexa-go-client#14

@sahaqaa sahaqaa requested a review from a team as a code owner July 2, 2024 16:11
@patoarvizu
Copy link

Are those lint failures normal?

@patoarvizu
Copy link

Oh I'm guessing they depended on the change in cloudconnexa-go-client?

@sahaqaa
Copy link
Contributor Author

sahaqaa commented Jul 2, 2024

@patoarvizu this is strange,
when trying to build provider i get next error:

$ make
go build -o terraform-provider-cloudconnexa
# github.com/OpenVPN/terraform-provider-cloudconnexa/cloudconnexa
cloudconnexa/data_source_host.go:110:32: c.Description undefined (type "github.com/openvpn/cloudconnexa-go-client/v2/cloudconnexa".Connector has no field or method Description)
cloudconnexa/resource_connector.go:88:3: unknown field Description in struct literal of type "github.com/openvpn/cloudconnexa-go-client/v2/cloudconnexa".Connector
cloudconnexa/resource_connector.go:154:33: c.Description undefined (type "github.com/openvpn/cloudconnexa-go-client/v2/cloudconnexa".Connector has no field or method Description)
make: *** [Makefile:11: build] Error 1

When we did the testing with @michaelfmnk all was OK 😢

@sahaqaa
Copy link
Contributor Author

sahaqaa commented Jul 2, 2024

Never mind, my bad, i forgot to update tag to point to new cloudconnexa-go-client version ;-)

@sahaqaa
Copy link
Contributor Author

sahaqaa commented Jul 2, 2024

For the record: resource_connector.go has next line:

			"description": {
				Type:         schema.TypeString,
				Optional:     true,
				ForceNew:     true,
				Default:      "Managed by Terraform",
				ValidateFunc: validation.StringLenBetween(1, 120),
				Description:  "The display description for this resource. Defaults to `Managed by Terraform`.",
			},

"ForceNew: true," is needed because for resource "cloudconnexa_connector" we currently don't have an "Update" method. One day in the future it will be added (hopefully), but for now we did an ad-hoc workaround.

@sahaqaa sahaqaa marked this pull request as draft July 2, 2024 16:49
@sahaqaa sahaqaa marked this pull request as ready for review July 3, 2024 07:17
@sahaqaa
Copy link
Contributor Author

sahaqaa commented Jul 3, 2024

This was tested, all OK. As part of this PR we fixed next:

1/ Perpetual drift for resource "cloudconnexa_network" ("default_connector" "description" field)
appeared every terraform plan / apply command was run

2/ Data source "cloudconnexa_network" was not able to show "connectors" hash / structure

data "cloudconnexa_network" "this" {
  name = "qqq"
}

output "this" {
  value = data.cloudconnexa_network.this
}

before:

data.cloudconnexa_network.this: Reading...
data.cloudconnexa_network.this: Read complete after 1s [id=1719894343]

Changes to Outputs:
  + this = {
      + connectors      = null
      + egress          = true
      + id              = "1719894343"
      + internet_access = "LOCAL"
      + name            = "foo"
      + network_id      = "62adb91a-15e6-4803-a81e-444345005d99"
      + routes          = [
          + {
              + id     = "d09c5be5-1096-4c0b-8fc7-6c58fd821a6b"
              + subnet = "10.8.128.0/17"
              + type   = "IP_V4"
            },
        ]
      + system_subnets  = [
          + "100.96.1.16/28",
          + "fd:0:0:8101::/64",
        ]
    }

after:

data.cloudconnexa_network.this: Reading...
data.cloudconnexa_network.this: Read complete after 1s [id=1719981323]

Changes to Outputs:
  + this = {
      + connectors      = [
          + {
              + description       = "ggggggggggg"
              + id                = "8c6cd714-4cf3-4165-9b32-c19619a120f4"
              + ip_v4_address     = "100.96.1.18/28"
              + ip_v6_address     = "fd:0:0:8101::2/64"
              + name              = "foo"
              + network_item_id   = "1eadd9ae-b085-4a59-9b1e-0881879bb17c"
              + network_item_type = "NETWORK"
              + vpn_region_id     = "eu-central-1"
            },
        ]
      + egress          = true
      + id              = "1719981323"
      + internet_access = "LOCAL"
      + name            = "qqq"
      + network_id      = "1eadd9ae-b085-4a59-9b1e-0881879bb17c"
      + routes          = [
          + {
              + id     = "5965e3ad-a999-43d8-a3f7-ffa19bad372a"
              + subnet = "10.8.128.0/17"
              + type   = "IP_V4"
            },
        ]
      + system_subnets  = [
          + "100.96.1.16/28",
          + "fd:0:0:8101::/64",
        ]
    }

@sahaqaa sahaqaa merged commit 369e52a into main Jul 3, 2024
1 check passed
@sahaqaa sahaqaa deleted the feature/network_schema_fixes branch July 3, 2024 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants