Skip to content

Commit 0ed58c9

Browse files
committed
chore(data_source_github_release_asset): use download_file/file attributes
Replace `download_body` argument and `body` attributes w/ `download_file`/`file`, respectively, towards the goal of improving the data source interface. This addresses code review feedback from @stevehipwell: #2514 (comment) Signed-off-by: Mike Ball <mikedball@gmail.com>
1 parent 5439872 commit 0ed58c9

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

github/data_source_github_release_asset.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ func dataSourceGithubReleaseAsset() *schema.Resource {
3232
Required: true,
3333
Description: "Name of the repository to retrieve the release asset from",
3434
},
35-
"download_body": {
35+
"download_file": {
3636
Type: schema.TypeBool,
3737
Optional: true,
3838
Default: false,
39-
Description: "Whether to download the asset content into the body attribute",
39+
Description: "Whether to download the asset content into the file attribute",
4040
},
41-
"body": {
41+
"file": {
4242
Type: schema.TypeString,
4343
Computed: true,
44-
Description: "The release asset body (requires download_body to be 'true'",
44+
Description: "The release asset file contents (requires `download_file` to be `true`",
4545
},
4646
"url": {
4747
Type: schema.TypeString,
@@ -134,7 +134,7 @@ func dataSourceGithubReleaseAssetRead(ctx context.Context, d *schema.ResourceDat
134134
return diag.FromErr(err)
135135
}
136136

137-
if !d.Get("download_body").(bool) {
137+
if !d.Get("download_file").(bool) {
138138
return nil
139139
}
140140

@@ -162,7 +162,7 @@ func dataSourceGithubReleaseAssetRead(ctx context.Context, d *schema.ResourceDat
162162
return diag.FromErr(err)
163163
}
164164

165-
if err := d.Set("body", buf.String()); err != nil {
165+
if err := d.Set("file", buf.String()); err != nil {
166166
return diag.FromErr(err)
167167
}
168168

github/data_source_github_release_asset_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func TestAccGithubReleaseAssetDataSource(t *testing.T) {
2121
repository = "%s"
2222
owner = "%s"
2323
asset_id = "%s"
24-
download_body = true
24+
download_file = true
2525
}
2626
`, testReleaseRepository, testRepositoryOwner, testReleaseAssetID)
2727

@@ -38,7 +38,7 @@ func TestAccGithubReleaseAssetDataSource(t *testing.T) {
3838
"data.github_release_asset.test", "name", testReleaseAssetName,
3939
),
4040
resource.TestCheckResourceAttr(
41-
"data.github_release_asset.test", "body", testReleaseAssetContent,
41+
"data.github_release_asset.test", "file", testReleaseAssetContent,
4242
),
4343
),
4444
},
@@ -68,7 +68,7 @@ func TestAccGithubReleaseAssetDataSource(t *testing.T) {
6868
"data.github_release_asset.test", "name", testReleaseAssetName,
6969
),
7070
resource.TestCheckNoResourceAttr(
71-
"data.github_release_asset.test", "body",
71+
"data.github_release_asset.test", "file",
7272
),
7373
),
7474
},

website/docs/d/release_asset.html.markdown

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ data "github_release_asset" "example" {
2020
}
2121
```
2222

23-
To retrieve a specific release asset from a repository, and download its body
24-
into a `body` attribute on the data source:
23+
To retrieve a specific release asset from a repository, and download the file
24+
into a `file` attribute on the data source:
2525

2626
```hcl
2727
data "github_release_asset" "example" {
2828
repository = "example-repository"
2929
owner = "example-owner"
3030
asset_id = 12345
31-
download_body = true
31+
download_file = true
3232
}
3333
```
3434

@@ -71,7 +71,7 @@ data "github_release_asset" "example" {
7171
* `repository` - (Required) Name of the repository to retrieve the release from
7272
* `owner` - (Required) Owner of the repository
7373
* `asset_id` - (Required) ID of the release asset to retrieve
74-
* `download_body` - (Optional) If `true`, download the release asset to the `body` attribute. Defaults to `false`.
74+
* `download_file` - (Optional) Whether to download the asset content into the file attribute. Defaults to `false`.
7575

7676
## Attributes Reference
7777

@@ -85,4 +85,4 @@ data "github_release_asset" "example" {
8585
* `created_at` - Date the asset was created
8686
* `updated_at` - Date the asset was last updated
8787
* `browser_download_url` - Browser URL from which the release asset can be downloaded
88-
* `body` - The release asset body (requires `download_body` to be `true`)
88+
* `file` - The release asset file contents (requires `download_file` to be `true`)

0 commit comments

Comments
 (0)