Skip to content

Commit

Permalink
Merge pull request #58 from omazin/fix-test-approach
Browse files Browse the repository at this point in the history
Fix testing approach. Update examples, tests.
  • Loading branch information
morgante authored Dec 26, 2019
2 parents cc9ee9c + 55241dc commit 48a9b07
Show file tree
Hide file tree
Showing 92 changed files with 219 additions and 1,169 deletions.
3 changes: 1 addition & 2 deletions examples/compute_instance/simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ This is a simple, minimal example of how to use the compute_instance module

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| credentials\_path | The path to the GCP credentials JSON file | string | n/a | yes |
| num\_instances | Number of instances to create | string | n/a | yes |
| project\_id | The GCP project to use for integration tests | string | n/a | yes |
| region | The GCP region to create and test resources in | string | n/a | yes |
| region | The GCP region to create and test resources in | string | `"us-central1"` | no |
| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no |
| subnetwork | The subnetwork to host the compute instances in | string | n/a | yes |

Expand Down
8 changes: 4 additions & 4 deletions examples/compute_instance/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/

provider "google" {
credentials = file(var.credentials_path)
project = var.project_id
region = var.region
version = "~> 2.7.0"

project = var.project_id
region = var.region
version = "~> 2.7.0"
}

module "instance_template" {
Expand Down
11 changes: 7 additions & 4 deletions examples/compute_instance/simple/variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018 Google LLC
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,16 +14,17 @@
* limitations under the License.
*/

variable "credentials_path" {
description = "The path to the GCP credentials JSON file"
}


variable "project_id" {
description = "The GCP project to use for integration tests"
type = string
}

variable "region" {
description = "The GCP region to create and test resources in"
type = string
default = "us-central1"
}

variable "subnetwork" {
Expand All @@ -34,6 +35,8 @@ variable "num_instances" {
description = "Number of instances to create"
}



variable "service_account" {
default = null
type = object({
Expand Down
3 changes: 1 addition & 2 deletions examples/instance_template/additional_disks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ instance templates with additional persistent disks.

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| credentials\_path | The path to the GCP credentials JSON file | string | n/a | yes |
| project\_id | The GCP project to use for integration tests | string | n/a | yes |
| region | The GCP region to create and test resources in | string | n/a | yes |
| region | The GCP region to create and test resources in | string | `"us-central1"` | no |
| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no |
| subnetwork | The name of the subnetwork create this instance in. | string | `""` | no |

Expand Down
8 changes: 4 additions & 4 deletions examples/instance_template/additional_disks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/

provider "google" {
credentials = file(var.credentials_path)
project = var.project_id
region = var.region
version = "~> 2.7.0"

project = var.project_id
region = var.region
version = "~> 2.7.0"
}

module "instance_template" {
Expand Down
9 changes: 5 additions & 4 deletions examples/instance_template/additional_disks/variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018 Google LLC
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,16 +14,17 @@
* limitations under the License.
*/

variable "credentials_path" {
description = "The path to the GCP credentials JSON file"
}


variable "project_id" {
description = "The GCP project to use for integration tests"
type = string
}

variable "region" {
description = "The GCP region to create and test resources in"
type = string
default = "us-central1"
}

variable "subnetwork" {
Expand Down
3 changes: 1 addition & 2 deletions examples/instance_template/simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ This is a simple, minimal example of how to use the instance_template module.

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| credentials\_path | The path to the GCP credentials JSON file | string | n/a | yes |
| labels | Labels, provided as a map | map(string) | n/a | yes |
| project\_id | The GCP project to use for integration tests | string | n/a | yes |
| region | The GCP region to create and test resources in | string | n/a | yes |
| region | The GCP region to create and test resources in | string | `"us-central1"` | no |
| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no |
| subnetwork | The name of the subnetwork create this instance in. | string | `""` | no |
| tags | Network tags, provided as a list | list(string) | n/a | yes |
Expand Down
8 changes: 4 additions & 4 deletions examples/instance_template/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/

provider "google" {
credentials = file(var.credentials_path)
project = var.project_id
region = var.region
version = "~> 2.7.0"

project = var.project_id
region = var.region
version = "~> 2.7.0"
}

resource "google_compute_address" "ip_address" {
Expand Down
9 changes: 5 additions & 4 deletions examples/instance_template/simple/variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018 Google LLC
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,16 +14,17 @@
* limitations under the License.
*/

variable "credentials_path" {
description = "The path to the GCP credentials JSON file"
}


variable "project_id" {
description = "The GCP project to use for integration tests"
type = string
}

variable "region" {
description = "The GCP region to create and test resources in"
type = string
default = "us-central1"
}

variable "subnetwork" {
Expand Down
4 changes: 2 additions & 2 deletions examples/mig/autoscaler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ group with an autoscaler.
|------|-------------|:----:|:-----:|:-----:|
| autoscaling\_cpu | Autoscaling, cpu utilization policy block as single element array. https://www.terraform.io/docs/providers/google/r/compute_autoscaler.html#cpu_utilization | list(map(number)) | n/a | yes |
| autoscaling\_enabled | Creates an autoscaler for the managed instance group | string | n/a | yes |
| credentials\_path | The path to the GCP credentials JSON file | string | n/a | yes |
| min\_replicas | The minimum number of replicas that the autoscaler can scale down to. This cannot be less than 0. | string | n/a | yes |
| project\_id | The GCP project to use for integration tests | string | n/a | yes |
| region | The GCP region to create and test resources in | string | n/a | yes |
| region | The GCP region to create and test resources in | string | `"us-central1"` | no |
| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no |
| subnetwork | The subnetwork to host the compute instances in | string | n/a | yes |

Expand All @@ -23,5 +22,6 @@ group with an autoscaler.
|------|-------------|
| instance\_template\_self\_link | Self-link of instance template |
| mig\_self\_link | Self-link for managed instance group |
| region | The GCP region to create and test resources in |

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
16 changes: 8 additions & 8 deletions examples/mig/autoscaler/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
*/

provider "google" {
credentials = file(var.credentials_path)
project = var.project_id
region = var.region
version = "~> 2.7.0"

project = var.project_id
region = var.region
version = "~> 2.7.0"
}

provider "google-beta" {
credentials = file(var.credentials_path)
project = var.project_id
region = var.region
version = "~> 2.7.0"

project = var.project_id
region = var.region
version = "~> 2.7.0"
}

module "instance_template" {
Expand Down
4 changes: 4 additions & 0 deletions examples/mig/autoscaler/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ output "mig_self_link" {
value = module.mig.self_link
}

output "region" {
description = "The GCP region to create and test resources in"
value = var.region
}
9 changes: 5 additions & 4 deletions examples/mig/autoscaler/variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018 Google LLC
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,16 +14,17 @@
* limitations under the License.
*/

variable "credentials_path" {
description = "The path to the GCP credentials JSON file"
}


variable "project_id" {
description = "The GCP project to use for integration tests"
type = string
}

variable "region" {
description = "The GCP region to create and test resources in"
type = string
default = "us-central1"
}

variable "subnetwork" {
Expand Down
16 changes: 8 additions & 8 deletions examples/mig/full/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
*/

provider "google" {
credentials = file(var.credentials_path)
project = var.project_id
region = var.region
version = "~> 2.7.0"

project = var.project_id
region = var.region
version = "~> 2.7.0"
}

provider "google-beta" {
credentials = file(var.credentials_path)
project = var.project_id
region = var.region
version = "~> 2.7.0"

project = var.project_id
region = var.region
version = "~> 2.7.0"
}

module "instance_template" {
Expand Down
10 changes: 5 additions & 5 deletions examples/mig/full/variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018 Google LLC
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,6 +25,8 @@ variable "hostname" {

variable "region" {
description = "The GCP region where instances will be deployed."
type = string
default = "us-central1"
}

variable "network" {
Expand All @@ -39,12 +41,10 @@ variable "subnetwork" {

variable "project_id" {
description = "The GCP project to use for integration tests"
type = string
}

variable "credentials_path" {
description = "The path to the GCP credentials JSON file"
default = ""
}


variable "subnetwork_project" {
description = "The project that subnetwork belongs to"
Expand Down
4 changes: 2 additions & 2 deletions examples/mig/simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ managed instance group.

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| credentials\_path | The path to the GCP credentials JSON file | string | n/a | yes |
| project\_id | The GCP project to use for integration tests | string | n/a | yes |
| region | The GCP region to create and test resources in | string | n/a | yes |
| region | The GCP region to create and test resources in | string | `"us-central1"` | no |
| service\_account | Service account to attach to the instance. See https://www.terraform.io/docs/providers/google/r/compute_instance_template.html#service_account. | object | `"null"` | no |
| subnetwork | The subnetwork to host the compute instances in | string | n/a | yes |
| target\_size | The target number of running instances for this managed instance group. This value should always be explicitly set unless this resource is attached to an autoscaler, in which case it should never be set. | string | n/a | yes |
Expand All @@ -19,6 +18,7 @@ managed instance group.

| Name | Description |
|------|-------------|
| region | The GCP region to create and test resources in |
| self\_link | Self-link of the managed instance group |

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
12 changes: 6 additions & 6 deletions examples/mig/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
*/

provider "google" {
credentials = file(var.credentials_path)
region = var.region
version = "~> 2.7.0"

region = var.region
version = "~> 2.7.0"
}

provider "google-beta" {
credentials = file(var.credentials_path)
region = var.region
version = "~> 2.7.0"

region = var.region
version = "~> 2.7.0"
}

module "instance_template" {
Expand Down
4 changes: 4 additions & 0 deletions examples/mig/simple/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ output "self_link" {
value = module.mig.self_link
}

output "region" {
description = "The GCP region to create and test resources in"
value = var.region
}
9 changes: 5 additions & 4 deletions examples/mig/simple/variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018 Google LLC
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,16 +14,17 @@
* limitations under the License.
*/

variable "credentials_path" {
description = "The path to the GCP credentials JSON file"
}


variable "project_id" {
description = "The GCP project to use for integration tests"
type = string
}

variable "region" {
description = "The GCP region to create and test resources in"
type = string
default = "us-central1"
}

variable "subnetwork" {
Expand Down
Loading

0 comments on commit 48a9b07

Please sign in to comment.