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

providers/google: Move URLMap hosts to TypeSet from TypeList #7472

Merged
merged 1 commit into from
Aug 8, 2016

Conversation

evandbrown
Copy link
Contributor

Using TypeSet allows host entries to be ordered arbitrarily in a manifest.

Acceptance test output:

❯ make testacc TEST=./builtin/providers/google GOOGLE_PROJECT=evandbrown17 GOOGLE_REGION=us-central1 TESTARGS='-
 run=TestAccComputeUrlMap'
 ==> Checking that code complies with gofmt requirements...
 /home/evanbrown/dev/golang/bin/stringer
 go generate $(go list ./... | grep -v /vendor/)
 2016/07/02 15:19:36 Generated command/internal_plugin_list.go
 TF_ACC=1 go test ./builtin/providers/google -v -run=TestAccComputeUrlMap -timeout 120m
 === RUN   TestAccComputeUrlMap_basic
 --- PASS: TestAccComputeUrlMap_basic (78.97s)
 === RUN   TestAccComputeUrlMap_update_path_matcher
 --- PASS: TestAccComputeUrlMap_update_path_matcher (158.01s)
 === RUN   TestAccComputeUrlMap_advanced
 --- PASS: TestAccComputeUrlMap_advanced (157.52s)
 PASS
 ok      github.com/hashicorp/terraform/builtin/providers/google 394.608s

The TypeList to TypeSet migration appears to happen automatically.

Using TypeSet allows host entries to be ordered arbitrarily in a manifest.
@evandbrown
Copy link
Contributor Author

Regarding the TypeList to TypeSet migration, here's what happens when I apply with the previous version of this plugin, and then apply again with the version of the provider from this commit:

$ sha1sum /home/evanbrown/dev/go-workspaces/terraform/bin/terraform-provider-google
a1a7bd2105ccec88f564028ad8af3502da13b83a  /home/evanbrown/dev/go-workspaces/terraform/bin/terraform-provider-google
$ terraform apply
[WARN] /home/evanbrown/dev/go-workspaces/terraform/bin/terraform-provider-google overrides an internal plugin for google-provider.
  If you did not expect to see this message you will need to remove the old plugin.
  See https://www.terraform.io/docs/internals/internal-plugins.html
google_compute_http_health_check.default: Refreshing state... (ID: test)
google_compute_http_health_check.default: Creating...
  check_interval_sec:  "" => "1"
  healthy_threshold:   "" => "2"
  name:                "" => "test"
  port:                "" => "80"
  request_path:        "" => "/"
  self_link:           "" => "<computed>"
  timeout_sec:         "" => "1"
  unhealthy_threshold: "" => "2"
google_compute_http_health_check.default: Still creating... (10s elapsed)
google_compute_http_health_check.default: Creation complete
google_compute_backend_service.home: Creating...
  fingerprint:              "" => "<computed>"
  health_checks.#:          "" => "1"
  health_checks.2581756488: "" => "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/httpHealthChecks/test"
  name:                     "" => "home-backend"
  port_name:                "" => "http"
  protocol:                 "" => "HTTP"
  region:                   "" => "us-central1"
  self_link:                "" => "<computed>"
  timeout_sec:              "" => "10"
google_compute_backend_service.home: Still creating... (10s elapsed)
google_compute_backend_service.home: Creation complete
google_compute_url_map.foobar: Creating...
  default_service:                    "" => "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/backendServices/home-backend"
  description:                        "" => "a description"
  fingerprint:                        "" => "<computed>"
  host_rule.#:                        "" => "2"
  host_rule.0.hosts.#:                "" => "1"
  host_rule.0.hosts.0:                "" => "hr1-host1.com"
  host_rule.0.path_matcher:           "" => "pm-1"
  host_rule.1.hosts.#:                "" => "2"
  host_rule.1.hosts.0:                "" => "hr2-host2.com"
  host_rule.1.hosts.1:                "" => "hr2-host1.com"
  host_rule.1.path_matcher:           "" => "pm-2"
  name:                               "" => "urlmap"
  path_matcher.#:                     "" => "2"
  path_matcher.0.default_service:     "" => "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/backendServices/home-backend"
  path_matcher.0.name:                "" => "pm-1"
  path_matcher.0.path_rule.#:         "" => "1"
  path_matcher.0.path_rule.0.paths.#: "" => "1"
  path_matcher.0.path_rule.0.paths.0: "" => "/fooo"
  path_matcher.0.path_rule.0.service: "" => "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/backendServices/home-backend"
  path_matcher.1.default_service:     "" => "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/backendServices/home-backend"
  path_matcher.1.name:                "" => "pm-2"
  path_matcher.1.path_rule.#:         "" => "1"
  path_matcher.1.path_rule.0.paths.#: "" => "1"
  path_matcher.1.path_rule.0.paths.0: "" => "/fooo"
  path_matcher.1.path_rule.0.service: "" => "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/backendServices/home-backend"
  self_link:                          "" => "<computed>"
google_compute_url_map.foobar: Still creating... (10s elapsed)
google_compute_url_map.foobar: Creation complete

Apply complete! Resources: 3 added, 0 changed, 0 destroyed.

The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.

State path: terraform.tfstate
$ cat terraform.tfstate
{
    "version": 3,
    "terraform_version": "0.7.0",
    "serial": 38,
    "modules": [
        {
            "path": [
                "root"
            ],
            "outputs": {},
            "resources": {
                "google_compute_backend_service.home": {
                    "type": "google_compute_backend_service",
                    "depends_on": [
                        "google_compute_http_health_check.default"
                    ],
                    "primary": {
                        "id": "home-backend",
                        "attributes": {
                            "backend.#": "0",
                            "description": "",
                            "fingerprint": "JVUS_002cfs=",
                            "health_checks.#": "1",
                            "health_checks.2581756488": "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/httpHealthChecks/test",
                            "id": "home-backend",
                            "name": "home-backend",
                            "port_name": "http",
                            "protocol": "HTTP",
                            "region": "us-central1",
                            "self_link": "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/backendServices/home-backend",
                            "timeout_sec": "10"
                        }
                    }
                },
                "google_compute_http_health_check.default": {
                    "type": "google_compute_http_health_check",
                    "primary": {
                        "id": "test",
                        "attributes": {
                            "check_interval_sec": "1",
                            "healthy_threshold": "2",
                            "host": "",
                            "id": "test",
                            "name": "test",
                            "port": "80",
                            "request_path": "/",
                            "self_link": "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/httpHealthChecks/test",
                            "timeout_sec": "1",
                            "unhealthy_threshold": "2"
                        }
                    }
                },
                "google_compute_url_map.foobar": {
                    "type": "google_compute_url_map",
                    "depends_on": [
                        "google_compute_backend_service.home"
                    ],
                    "primary": {
                        "id": "urlmap",
                        "attributes": {
                            "default_service": "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/backendServices/home-backend",
                            "description": "a description",
                            "fingerprint": "EXNxpeLF30g=",
                            "host_rule.#": "2",
                            "host_rule.0.description": "",
                            "host_rule.0.hosts.#": "1",
                            "host_rule.0.hosts.0": "hr1-host1.com",
                            "host_rule.0.path_matcher": "pm-1",
                            "host_rule.1.description": "",
                            "host_rule.1.hosts.#": "2",
                            "host_rule.1.hosts.0": "hr2-host2.com",
                            "host_rule.1.hosts.1": "hr2-host1.com",
                            "host_rule.1.path_matcher": "pm-2",
                            "id": "urlmap",
                            "name": "urlmap",
                            "path_matcher.#": "2",
                            "path_matcher.0.default_service": "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/backendServices/home-backend",
                            "path_matcher.0.description": "",
                            "path_matcher.0.name": "pm-1",
                            "path_matcher.0.path_rule.#": "1",
                            "path_matcher.0.path_rule.0.paths.#": "1",
                            "path_matcher.0.path_rule.0.paths.0": "/fooo",
                            "path_matcher.0.path_rule.0.service": "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/backendServices/home-backend",
                            "path_matcher.1.default_service": "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/backendServices/home-backend",
                            "path_matcher.1.description": "",
                            "path_matcher.1.name": "pm-2",
                            "path_matcher.1.path_rule.#": "1",
                            "path_matcher.1.path_rule.0.paths.#": "1",
                            "path_matcher.1.path_rule.0.paths.0": "/fooo",
                            "path_matcher.1.path_rule.0.service": "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/backendServices/home-backend",
                            "self_link": "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/urlMaps/urlmap",
                            "test.#": "0"
                        }
                    }
                }
            }
        }
    ]
}
$ sha1sum /home/evanbrown/dev/go-workspaces/terraform/bin/terraform-provider-google
9856973b1ccf0b64f56d76660d5a3861416847cd  /home/evanbrown/dev/go-workspaces/terraform/bin/terraform-provider-google
$ terraform apply
[WARN] /home/evanbrown/dev/go-workspaces/terraform/bin/terraform-provider-google overrides an internal plugin for google-provider.
  If you did not expect to see this message you will need to remove the old plugin.
  See https://www.terraform.io/docs/internals/internal-plugins.html
google_compute_http_health_check.default: Refreshing state... (ID: test)
google_compute_backend_service.home: Refreshing state... (ID: home-backend)
google_compute_url_map.foobar: Refreshing state... (ID: urlmap)

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
$ cat terraform.tfstate
{
    "version": 3,
    "terraform_version": "0.7.0",
    "serial": 39,
    "modules": [
        {
            "path": [
                "root"
            ],
            "outputs": {},
            "resources": {
                "google_compute_backend_service.home": {
                    "type": "google_compute_backend_service",
                    "depends_on": [
                        "google_compute_http_health_check.default"
                    ],
                    "primary": {
                        "id": "home-backend",
                        "attributes": {
                            "backend.#": "0",
                            "description": "",
                            "fingerprint": "JVUS_002cfs=",
                            "health_checks.#": "1",
                            "health_checks.2581756488": "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/httpHealthChecks/test",
                            "id": "home-backend",
                            "name": "home-backend",
                            "port_name": "http",
                            "protocol": "HTTP",
                            "region": "us-central1",
                            "self_link": "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/backendServices/home-backend",
                            "timeout_sec": "10"
                        }
                    }
                },
                "google_compute_http_health_check.default": {
                    "type": "google_compute_http_health_check",
                    "primary": {
                        "id": "test",
                        "attributes": {
                            "check_interval_sec": "1",
                            "healthy_threshold": "2",
                            "host": "",
                            "id": "test",
                            "name": "test",
                            "port": "80",
                            "request_path": "/",
                            "self_link": "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/httpHealthChecks/test",
                            "timeout_sec": "1",
                            "unhealthy_threshold": "2"
                        }
                    }
                },
                "google_compute_url_map.foobar": {
                    "type": "google_compute_url_map",
                    "depends_on": [
                        "google_compute_backend_service.home"
                    ],
                    "primary": {
                        "id": "urlmap",
                        "attributes": {
                            "default_service": "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/backendServices/home-backend",
                            "description": "a description",
                            "fingerprint": "EXNxpeLF30g=",
                            "host_rule.#": "2",
                            "host_rule.1479341986.description": "",
                            "host_rule.1479341986.hosts.#": "1",
                            "host_rule.1479341986.hosts.0": "hr1-host1.com",
                            "host_rule.1479341986.path_matcher": "pm-1",
                            "host_rule.460693535.description": "",
                            "host_rule.460693535.hosts.#": "2",
                            "host_rule.460693535.hosts.0": "hr2-host2.com",
                            "host_rule.460693535.hosts.1": "hr2-host1.com",
                            "host_rule.460693535.path_matcher": "pm-2",
                            "id": "urlmap",
                            "name": "urlmap",
                            "path_matcher.#": "2",
                            "path_matcher.0.default_service": "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/backendServices/home-backend",
                            "path_matcher.0.description": "",
                            "path_matcher.0.name": "pm-1",
                            "path_matcher.0.path_rule.#": "1",
                            "path_matcher.0.path_rule.0.paths.#": "1",
                            "path_matcher.0.path_rule.0.paths.0": "/fooo",
                            "path_matcher.0.path_rule.0.service": "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/backendServices/home-backend",
                            "path_matcher.1.default_service": "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/backendServices/home-backend",
                            "path_matcher.1.description": "",
                            "path_matcher.1.name": "pm-2",
                            "path_matcher.1.path_rule.#": "1",
                            "path_matcher.1.path_rule.0.paths.#": "1",
                            "path_matcher.1.path_rule.0.paths.0": "/fooo",
                            "path_matcher.1.path_rule.0.service": "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/backendServices/home-backend",
                            "self_link": "https://www.googleapis.com/compute/v1/projects/evandbrown17/global/urlMaps/urlmap",
                            "test.#": "0"
                        }
                    }
                }
            }
        }
    ]
}

@stack72
Copy link
Contributor

stack72 commented Aug 8, 2016

Hi @evandbrown

This LGTM! Thanks :)

% make testacc TEST=./builtin/providers/google TESTARGS='-run=TestAccComputeUrlMap'
==> Checking that code complies with gofmt requirements...
/Users/stacko/Code/go/bin/stringer
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/08/08 12:39:14 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/google -v -run=TestAccComputeUrlMap -timeout 120m
=== RUN   TestAccComputeUrlMap_basic
--- PASS: TestAccComputeUrlMap_basic (88.83s)
=== RUN   TestAccComputeUrlMap_update_path_matcher
--- PASS: TestAccComputeUrlMap_update_path_matcher (173.31s)
=== RUN   TestAccComputeUrlMap_advanced
--- PASS: TestAccComputeUrlMap_advanced (173.78s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/google 435.955s

Paul

@stack72 stack72 merged commit 8f0fdc9 into hashicorp:master Aug 8, 2016
@ghost
Copy link

ghost commented Apr 23, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants