Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
set defualt value to empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
faiq committed Oct 20, 2020
1 parent 7083824 commit 068869c
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 7 deletions.
45 changes: 45 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -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 }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
checksum:
name_template: '{{ .ProjectName }}_{{ .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
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ fmtcheck:

gencheck:
.PHONY: build gen fmt fmtcheck

terraform-provider-aws-spot-instance:
go build
14 changes: 7 additions & 7 deletions aws/resource_aws_spot_instance_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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", "")
}
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 068869c

Please sign in to comment.