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

Initial addition of generated Image to Terraform. #1121

Merged
merged 8 commits into from
Jan 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/terraform
2 changes: 1 addition & 1 deletion build/terraform-beta
4 changes: 4 additions & 0 deletions products/compute/ansible.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ overrides: !ruby/object:Provider::ResourceOverrides
timeoutSec: !ruby/object:Provider::Ansible::PropertyOverride
aliases:
- timeout_seconds
Image: !ruby/object:Provider::Ansible::ResourceOverride
properties:
labels: !ruby/object:Provider::Ansible::PropertyOverride
version_added: '2.8'
InstanceGroup: !ruby/object:Provider::Ansible::ResourceOverride
properties:
instances: !ruby/object:Provider::Ansible::PropertyOverride
Expand Down
21 changes: 21 additions & 0 deletions products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1639,9 +1639,17 @@ objects:
name: 'Image'
kind: 'compute#image'
base_url: projects/{{project}}/global/images
input: true
exports:
- !ruby/object:Api::Type::SelfLink
name: 'selfLink'
collection_url_response: !ruby/object:Api::Resource::ResponseList
kind: 'compute#imageList'
items: 'items'
references: !ruby/object:Api::Resource::ReferenceLinks
guides:
'Official Documentation': 'https://cloud.google.com/compute/docs/images'
api: 'https://cloud.google.com/compute/docs/reference/latest/images'
description: |
Represents an Image resource.

Expand Down Expand Up @@ -1795,6 +1803,18 @@ objects:
min_version: beta
description: |
The name of the encryption key that is stored in Google Cloud KMS.
- !ruby/object:Api::Type::KeyValuePairs
name: 'labels'
description: Labels to apply to this Image.
update_verb: :POST
update_url: 'projects/{{project}}/global/images/{{name}}/setLabels'
- !ruby/object:Api::Type::Fingerprint
name: 'labelFingerprint'
description: |
The fingerprint used for optimistic locking of this resource. Used
internally during updates.
update_url: 'projects/{{project}}/global/images/{{name}}/setLabels'
update_verb: :POST
# TODO(alexstephen): Change to ResourceRef with array support
- !ruby/object:Api::Type::Array
name: 'licenses'
Expand Down Expand Up @@ -1832,6 +1852,7 @@ objects:
# TODO(alexstephen): Figure out cross-module ResourceRefs
- !ruby/object:Api::Type::String
name: 'source'
required: true
description: |
The full Google Cloud Storage URL where disk storage is stored
You must provide either this property or the sourceDisk property
Expand Down
18 changes: 15 additions & 3 deletions products/compute/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -392,26 +392,38 @@ overrides: !ruby/object:Provider::ResourceOverrides
sslHealthCheck.port: !ruby/object:Provider::Terraform::PropertyOverride
default_value: 443
Image: !ruby/object:Provider::Terraform::ResourceOverride
exclude: true
example:
- !ruby/object:Provider::Terraform::Examples
name: "image_basic"
primary_resource_id: "example"
version: <%= version_name %>
vars:
image_name: "example-image"
properties:
id: !ruby/object:Provider::Terraform::PropertyOverride
exclude: true
diskSizeGb: !ruby/object:Provider::Terraform::PropertyOverride
default_from_api: true
deprecated: !ruby/object:Provider::Terraform::PropertyOverride
exclude: true
guestOsFeatures: !ruby/object:Provider::Terraform::PropertyOverride
exclude: true
imageEncryptionKey: !ruby/object:Provider::Terraform::PropertyOverride
exclude: true
licenses: !ruby/object:Provider::Terraform::PropertyOverride
default_from_api: true
rawDisk.sha1Checksum: !ruby/object:Provider::Terraform::PropertyOverride
name: 'sha1'
rawDisk.containerType: !ruby/object:Provider::Terraform::PropertyOverride
default_value: "TAR"
rawDisk: !ruby/object:Provider::Terraform::PropertyOverride
ignore_read: true
sourceDiskEncryptionKey: !ruby/object:Provider::Terraform::PropertyOverride
exclude: true
sourceDiskId: !ruby/object:Provider::Terraform::PropertyOverride
exclude: true
sourceType: !ruby/object:Provider::Terraform::PropertyOverride
exclude: true
licenses: !ruby/object:Provider::Terraform::PropertyOverride
exclude: true
Instance: !ruby/object:Provider::Terraform::ResourceOverride
exclude: true
InstanceGroup: !ruby/object:Provider::Terraform::ResourceOverride
Expand Down
5 changes: 4 additions & 1 deletion templates/terraform/examples/base_configs/test_file.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ func testAcc<%= test_slug -%>(val string) string {
<%- end %>

func testAccCheck<%= resource_name -%>Destroy(s *terraform.State) error {
for _, rs := range s.RootModule().Resources {
for name, rs := range s.RootModule().Resources {
if rs.Type != "<%= terraform_name -%>" {
continue
}
if strings.HasPrefix(name, "data.") {
continue
}

config := testAccProvider.Meta().(*Config)

Expand Down
7 changes: 7 additions & 0 deletions templates/terraform/examples/image_basic.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "google_compute_image" "example" {
name = "<%= ctx[:vars]['image_name'] %>"

raw_disk {
source = "https://storage.googleapis.com/bosh-cpi-artifacts/bosh-stemcell-3262.4-google-kvm-ubuntu-trusty-go_agent-raw.tar.gz"
}
}
Loading