From 6631a700e48c51560cc5b90b6a555c0933e1abc6 Mon Sep 17 00:00:00 2001 From: faiq Date: Thu, 10 Sep 2020 11:43:47 -0700 Subject: [PATCH] set defualt value to empty string --- .goreleaser.yml | 45 +++++++++++++++++++++++ Makefile | 3 ++ aws/resource_aws_spot_instance_request.go | 14 +++---- 3 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 .goreleaser.yml diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 000000000..98031074c --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,45 @@ +# Visit https://goreleaser.com for documentation on how to customize this +# behavior. +builds: +- env: + # goreleaser does not work with CGO, it could also complicate + # usage by users in CI/CD systems like Terraform Cloud where + # they are unable to install libraries. + - CGO_ENABLED=0 + mod_timestamp: '{{ .CommitTimestamp }}' + flags: + - -trimpath + ldflags: + - '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}' + goos: + - linux + - darwin + goarch: + - amd64 + ignore: + - goos: darwin + goarch: '386' + binary: '{{ .ProjectName }}_v{{ .Version }}' +archives: +- format: zip + name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}' +checksum: + name_template: '{{ .ProjectName }}_v{{ .Version }}_SHA256SUMS' + algorithm: sha256 +signs: + - artifacts: checksum + args: + # if you are using this is a GitHub action or some other automated pipeline, you + # need to pass the batch flag to indicate its not interactive. + - "--batch" + - "--local-user" + - "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key + - "--output" + - "${signature}" + - "--detach-sign" + - "${artifact}" +release: + # If you want to manually examine the release before its live, uncomment this line: + # draft: true +changelog: + skip: true diff --git a/Makefile b/Makefile index 04e510286..fb62065a2 100644 --- a/Makefile +++ b/Makefile @@ -16,3 +16,6 @@ fmtcheck: gencheck: .PHONY: build gen fmt fmtcheck + +terraform-provider-aws-spot-instance: + go build diff --git a/aws/resource_aws_spot_instance_request.go b/aws/resource_aws_spot_instance_request.go index 33df297ad..16936a542 100644 --- a/aws/resource_aws_spot_instance_request.go +++ b/aws/resource_aws_spot_instance_request.go @@ -235,11 +235,11 @@ func resourceAwsSpotInstanceRequestCreate(d *schema.ResourceData, meta interface return fmt.Errorf("Error while waiting for spot request (%s) to resolve: %s", sir, err) } else if err != nil && allowUnfulfilled { log.Printf("[Error] Error while waiting for spot request (%s) to resolve: %s", sir, err) - d.Set("spot_instance_id", "unfulfilled") - d.Set("public_dns", "unfulfilled") - d.Set("public_ip", "unfulfilled") - d.Set("private_dns", "unfulfilled") - d.Set("private_ip", "unfulfilled") + d.Set("spot_instance_id", "") + d.Set("public_dns", "") + d.Set("public_ip", "") + d.Set("private_dns", "") + d.Set("private_ip", "") } } @@ -317,7 +317,7 @@ func readInstance(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).ec2conn instanceID := d.Get("spot_instance_id").(string) // if the request is unfulfilled we don't need to go pull instance data - if instanceID == "unfulfilled" { + if instanceID == "" { return nil } instance, err := resourceAwsInstanceFindByID(conn, instanceID) @@ -429,7 +429,7 @@ func resourceAwsSpotInstanceRequestDelete(d *schema.ResourceData, meta interface return fmt.Errorf("Error cancelling spot request (%s): %s", d.Id(), err) } - if instanceId := d.Get("spot_instance_id").(string); instanceId != "" && instanceId != "unfulfilled" { + if instanceId := d.Get("spot_instance_id").(string); instanceId != "" { log.Printf("[INFO] Terminating instance: %s", instanceId) if err := awsTerminateInstance(conn, instanceId, d.Timeout(schema.TimeoutDelete)); err != nil { return fmt.Errorf("Error terminating spot instance: %s", err)