Commit Graph

20 Commits

Author SHA1 Message Date
The Magician
4f7decf1e0 Changes ancillary to supporting the Terraform mapper. (#3177)
Signed-off-by: Modular Magician <magic-modules@google.com>
2019-03-04 12:56:25 -08:00
The Magician
23db6b0c12 Fix golangci-lint errors (#3059)
Signed-off-by: Modular Magician <magic-modules@google.com>
2019-02-14 16:00:35 -08:00
The Magician
6779f4dbf4 Ci test fixes (#2925)
<!-- This change is generated by MagicModules. -->
/cc @chrisst
2019-01-24 13:22:22 -08:00
Chris Stephens
c4db896d39 Test failures (#2250)
fix disk encrypt tests
fxing compute instance data source tests
fixing the compute instance migration tests
2018-12-20 17:22:22 -08:00
The Magician
eafe197070 Remove deprecated raw_key convenience property (#2209)
Removing disk_encryption_key_sha256 and disk_encryption_key_raw and removing the custom diff logic associated with them.

<!-- This change is generated by MagicModules. -->
/cc @chrisst
2018-12-20 17:22:22 -08:00
Paddy Carver
010c0f3288 Update README and run fmt. 2018-09-05 15:24:22 -07:00
Paddy Carver
bfcb07bdfb Fix migration tests. 2018-08-15 13:30:24 -07:00
Nic Cope
94a405d179 Add Alias IP and Guest Accelerator support to Instance Templates (#639)
* Move AliasIpRange helpers into utils

To reflect the fact they'll be used by multiple resources.

* Pass Config to build helpers, not meta

It's the only thing meta is used for.

* Refactor getNetwork util methods to return early for the happy path.

* Update compute APIs

compute.Instance.MinCpuPlatform is now GA.

* Fix panic in TestComputeInstanceMigrateState

This seemed to be a pre-existing issue, i.e. I could repro it in master.

--- FAIL: TestComputeInstanceMigrateState (0.00s)
panic: interface conversion: interface {} is nil, not *google.Config [recovered]
        panic: interface conversion: interface {} is nil, not *google.Config

goroutine 85 [running]:
testing.tRunner.func1(0xc4205d60f0)
        /usr/local/Cellar/go/1.9.1/libexec/src/testing/testing.go:711 +0x2d2
panic(0x203acc0, 0xc4205d2080)
        /usr/local/Cellar/go/1.9.1/libexec/src/runtime/panic.go:491 +0x283
github.com/terraform-providers/terraform-provider-google/google.migrateStateV3toV4(0xc4205f2000, 0x0, 0x0, 0x0, 0x48, 0xc4205f2000)
        /Users/negz/control/go/src/github.com/terraform-providers/terraform-provider-google/google/resource_compute_instance_migrate.go:182 +0x2405
github.com/terraform-providers/terraform-provider-google/google.resourceComputeInstanceMigrateState(0x2, 0xc4205f2000, 0x0, 0x0, 0x0, 0x0, 0xe0000000000)
        /Users/negz/control/go/src/github.com/terraform-providers/terraform-provider-google/google/resource_compute_instance_migrate.go:48 +0x21a
github.com/terraform-providers/terraform-provider-google/google.runInstanceMigrateTest(0xc4205d60f0, 0x2260816, 0x8, 0x227d23a, 0x20, 0x2, 0xc4205ec0f0, 0xc4205ec120, 0x0,
 0x0)
        /Users/negz/control/go/src/github.com/terraform-providers/terraform-provider-google/google/resource_compute_instance_migrate_test.go:803 +0xc1
github.com/terraform-providers/terraform-provider-google/google.TestComputeInstanceMigrateState(0xc4205d60f0)
        /Users/negz/control/go/src/github.com/terraform-providers/terraform-provider-google/google/resource_compute_instance_migrate_test.go:71 +0xc84
testing.tRunner(0xc4205d60f0, 0x22d81c0)
        /usr/local/Cellar/go/1.9.1/libexec/src/testing/testing.go:746 +0xd0
created by testing.(*T).Run
        /usr/local/Cellar/go/1.9.1/libexec/src/testing/testing.go:789 +0x2de
FAIL    github.com/terraform-providers/terraform-provider-google/google 0.035s

* Use only the v1 API for resource_compute_instance

Alias IP ranges, Accelerators, and min CPU platform are now GA.

* Move common instance code into utils.go

Methods used by both resource_compute_instance and
resource_compute_instance_template are currently spread between their respective
files, and utils.go.

This commit moves them all into utils.go for the sake of consistency. It may be
worth considering an instance_common.go file or similar.

* Unify compute_instance and compute_instance_template network_interface and service_account code

This has the side effect of enabling Alias IP range support for
compute_instance_templates.

* Add tests for compute instance template Alias IP ranges

* Mark instance template region as computed

We compute it from the subnet its network interfaces are in. Note this
is not new behaviour - I believe it was erroneously missing the computed
flag.

* Support guest accelerators for instance templates

Since most of the code is already there.

* Add a test for using 'address' rather than 'network_ip' for instance templates

* Don't mark assigned_nat_ip as deprecated

* Remove network_interface schema fields that don't make sense for a compute instance template

* Add newline after count in instance template docs

* Don't try to dedupe guest accelerator expansion code

The API calls to Google to create guest accelerators take different values
for instances and instance templates. Instance templates don't have a zone
and can thus *only* be passed a guest accelerator name.

* Use ParseNetworkFieldValue instead of getNetworkLink

* Add support for parsing regional fields, and subnetworks specifically

Currently unused because subnetworks may have a separate project from that
of the instance using them, which complicates looking up the project field.

* Fall back to provider region when parsing regional field values

Also slightly refactors getXFromSchema field helper functions for readability.

* Revert to assigned_nat_ip in compute instance docs

* Add beta scaffolding to compute instance and compute instance template

Note these resources don't currently use beta features - this is futureproofing.

* Fix indentation in comment about instance template alias IP ranges

* Consolidate metadata helper functions in metadata.go

* Move compute instance (and template) related helpers into their own file
2017-11-28 10:01:27 -08:00
Vincent Roseberry
a9fd5fddcb
Detect changes to cloud storage object when using source field. (#789)
* Detect server or local changes to bucket object when using source field

* Improve tests by removing global err and tf vars

* Address Dana's comments
2017-11-27 16:25:32 -08:00
Vincent Roseberry
0c0caee7ba
Standardize on test env var for region, creds and project (#770) 2017-11-21 09:34:32 -08:00
Dana Hoffman
f68765f5cd
Fix bug with empty initialize_params block (#664)
* fix initialize params bug

* make sure all init params are deleted, not just #
2017-11-03 15:25:54 -07:00
Dana Hoffman
081e675d3d migrate boot disk initialize params (#592) 2017-10-20 09:45:05 -07:00
Joe Selman
2765290724 Add label support to google_compute_snapshot (#570)
* Add label support to google_compute_snapshot
* Refactor operation polling code to use client directly
2017-10-13 15:36:03 -07:00
Joe Selman
4b77dca918 Revert "Revert "Add t.Parallel to all acceptance tests (#558)""
This reverts commit 8ab9d96d25 and revives
the original commit that adds t.Parallel to all acceptance tests. It
turns out test failures were unrelated to this change (rather, they were
related to quota issues).
2017-10-12 15:07:29 -07:00
Joe Selman
8ab9d96d25 Revert "Add t.Parallel to all acceptance tests (#558)"
This reverts commit 42de44592f. It appears
there might be thread-safety issues as panics have started occuring when
parallism is ramped up. Reverting for now while investigating.
2017-10-10 17:55:34 -07:00
Joe Selman
42de44592f Add t.Parallel to all acceptance tests (#558) 2017-10-10 16:28:00 -07:00
Paddy
33b526aa10 Skip migrations if we're not running acc tests. 2017-10-02 12:49:49 -07:00
Paddy
300bae3244 Fix compute_instance migration bug.
`compute_instance`'s StateVersion was set to 2. Then we released a
migration to v3, but never updated the StateVersion to 3, meaning the
migration was never run. When we added the migration for disks, we
bumped to 4, bypassing 3 altogher. In theory, this is fine, and is
expected; after all, some people may have state in version 0 and need to
upgrade all the way to 4, so our schema migration function is supposed
to support this.

Unfortunately, for migrations to v2, v3, and v4 of our schema, the
migration _returned_ after each migration, instead of falling through.
This meant that (in this case), version 2 would see it needs to be
version 4, run the state migration to version 3, then _return_, setting
its StateVersion to _4_, which means the migration from 3->4 got skipped
entirely.

This PR bumps the version to 5, and adds a migration from 4->5 such that
if there are still disks in state after 4, re-run 4. This will fix
things for people that upgraded to 1.0.0 and had their StateVersion
updated without the migration running.

I also updated the tests @danawillow wrote to start from state version 2
instead of state version 3, as the state would never be in version 3.

I also duplicated those tests, but started them from state version 4
(assuming the migration hadn't run) and verifying that the migration
from 4->5 would correct that.
2017-10-02 12:34:09 -07:00
Dana Hoffman
6d947cd20e Add state migration from disk to boot_disk/scratch_disk/attached_disk (#329)
* Add state migration from disk to boot_disk/scratch_disk/attached_disk

* get rid of test for now

* update schema version

* add tests for migration

* fix travis errors

* actually fix travis errors

* fix logic when project is set, also remove some log statements

* add tests for reading based on encryption key and image

* use as much of the image URL as we can for matching on image

* read project from config if it wasn't set in the attribute

* update resolveImage call
2017-09-28 14:37:03 -07:00
Jake Champlin
66029ac431
Transfer google provider 2017-06-06 11:58:51 -04:00