Skip to content

Commit

Permalink
ec_extension: fix upload request wrapper to use filePath variable
Browse files Browse the repository at this point in the history
  • Loading branch information
snowhork committed Jan 4, 2021
1 parent 31a44fb commit 73dfb89
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ec/ecresource/extensionresource/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,15 @@ func deleteRequest(client *api.API, d *schema.ResourceData) error {
}

func uploadRequest(client *api.API, d *schema.ResourceData) error {
reader, err := os.Open(d.Get("file_path").(string))
filePath := d.Get("file_path").(string)
reader, err := os.Open(filePath)
if err != nil {
return multierror.NewPrefixed("failed open file", err)
}

if _, err := client.V1API.Extensions.UploadExtension(
extensions.NewUploadExtensionParams().WithExtensionID(d.Id()).
WithFile(runtime.NamedReader(d.Get("file_path").(string), reader)),
WithFile(runtime.NamedReader(filePath, reader)),
client.AuthWriter); err != nil {
return apierror.Wrap(err)
}
Expand Down

0 comments on commit 73dfb89

Please sign in to comment.