Skip to content

fix: DownloadReleaseAsset handles renamed repository#3392

Merged
gmlewis merged 3 commits intogoogle:masterfrom
mdb:mdb/download-release-asset-in-renamed-repo
Dec 22, 2024
Merged

fix: DownloadReleaseAsset handles renamed repository#3392
gmlewis merged 3 commits intogoogle:masterfrom
mdb:mdb/download-release-asset-in-renamed-repo

Conversation

@mdb
Copy link
Copy Markdown
Contributor

@mdb mdb commented Dec 17, 2024

This fixes issue #3081, such that Repositories.DownloadReleaseAsset correctly handles scenarios where a non-nil followRedirectsClient argument has been passed, and the specified repository has been renamed to a new name.

Previously, in such scenarios...

  1. The initial GET /repos/<OWNER>/<REPO>/releases/assets/<ASSET ID> responds 301 w/ a Location: <GH API HOST>/repositories/<REPO ID>/releases/assets/<ASSET ID>.
  2. The followRedirectsClient issues a GET <GH API HOST>/repositories/<REPO ID>/releases/assets/<ASSET ID> with a Accept: */* header.
  3. GET <GH API HOST>/repositories/<REPO ID>/releases/assets/<ASSET ID> responds 200 with a JSON response body (rather than 302 w/ a Location: <MEDIA SERVER ASSET URL> header) due to the presence of the Accept: */* header (and the absence of a Accept: application/octet-stream header) from step 2.

The following curl offers an example of correct redirect follows & correct Accept: application/octet-stream-preservation in this scenario:

curl \
  --verbose \
  --location \
  --header "Accept: application/octet-stream" \
  https://api.github.com/repos/mterwill/go-github-issue-demo/releases/assets/151970555

Now, as per this change:

  1. The initial GET /repos/<OWNER>/<REPO>/releases/assets/<ASSET ID> responds 301 w/ a Location: <GH API HOST>/repositories/<REPO ID>/releases/assets/<ASSET ID>.
  2. The followRedirectsClient issues a GET <GH API HOST>/repositories/<REPO ID>/releases/assets/<ASSET ID> with a Accept: application/octet-stream header as required by the GH API.
  3. GET <GH API HOST>/repositories/<REPO ID>/releases/assets/<ASSET ID> responds 302 w/ a Location: <MEDIA SERVER ASSET URL>.
  4. The followRedirectsClient follows the redirects to GET <MEDIA SERVER ASSET URL> w/ a Accept: application/octet-stream header, and GET <MEDIA SERVER ASSET URL> responds 200 w/ the asset contents.

This fixes issue google#3081, such that `Repositories.DownloadReleaseAsset`
correctly handles scenarios where a non-`nil` `followRedirectsClient` argument
has been passed, but the specified repository has been renamed to a new name.

Previously, in such scenarios...

1. The initial `GET /repos/<OWNER>/<REPO>/releases/assets/<ASSET ID>`
   responds 301 w/ a `Location: <GH API HOST>/repositories/<REPO ID>/releases/assets/<ASSET ID>`.
2. The `followRedirectsClient` issues a `GET <GH API HOST>/repositories/<REPO ID>/releases/assets/<ASSET ID>`
   with a `Accept: */*` header.
3. `GET <GH API HOST>/repositories/<REPO ID>/releases/assets/<ASSET ID>`
   responds 200 with a JSON response body (rather than 302 w/ a
   `Location: <MEDIA SERVER ASSET URL>` header) due to the presence of
   the `Accept: */*` header (and the absence of a `Accept:
   application/octet-stream` header)`from step 2.

The following `curl` offers an example of correct redirect follows &
correct `Accept: application/octet-stream`-preservation in this scenario:

```
curl \
  --verbose \
  --location \
  --header "Accept: application/octet-stream" \
  https://api.github.com/repos/mterwill/go-github-issue-demo/releases/assets/151970555
```

Now, as per this change:

1. The initial `GET /repos/<OWNER>/<REPO>/releases/assets/<ASSET ID>`
   responds 301 w/ a `Location: <GH API HOST>/repositories/<REPO ID>/releases/assets/<ASSET ID>`.
2. The `followRedirectsClient` issues a `GET <GH API HOST>/repositories/<REPO ID>/releases/assets/<ASSET ID>`
   with a `Accept: application/octet-stream` header [as required by the GH API](https://docs.github.com/en/enterprise-cloud@latest/rest/releases/assets?apiVersion=2022-11-28)
3. `GET <GH API HOST>/repositories/<REPO ID>/releases/assets/<ASSET ID>`
   responds 302 w/ a `Location: <MEDIA SERVER ASSET URL>`.
4. The `followRedirectsClient` follows the redirects to `GET <MEDIA SERVER ASSET URL>`
   w/ a `Accept: application/octet-stream` header, and `GET <MEDIA SERVER
   ASSET URL>` responds 200 w/ the asset contents.

Signed-off-by: Mike Ball <mikedball@gmail.com>
@google-cla
Copy link
Copy Markdown

google-cla bot commented Dec 17, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.21%. Comparing base (2b8c7fa) to head (94578ef).
Report is 203 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3392      +/-   ##
==========================================
- Coverage   97.72%   92.21%   -5.51%     
==========================================
  Files         153      173      +20     
  Lines       13390    14770    +1380     
==========================================
+ Hits        13085    13620     +535     
- Misses        215     1060     +845     
  Partials       90       90              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @mdb !
LGTM.

Awaiting second LGTM+Approval from any other contributor to this repo before merging.

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Dec 17, 2024
This improves `RepositoriesService.DownloadReleaseAsset` documentation
to be a bit more specific and accurate, as per: google#3081 (comment)

Signed-off-by: Mike Ball <mikedball@gmail.com>
@mdb mdb requested a review from gmlewis December 17, 2024 13:58
Copy link
Copy Markdown
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Awaiting second LGTM+Approval from any other contributor to this repo before merging.

Copy link
Copy Markdown
Contributor

@tomfeigin tomfeigin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gmlewis gmlewis removed the NeedsReview PR is awaiting a review before merging. label Dec 22, 2024
@gmlewis
Copy link
Copy Markdown
Collaborator

gmlewis commented Dec 22, 2024

Thank you, @tomfeigin !
Merging.

@gmlewis gmlewis merged commit b0a5e60 into google:master Dec 22, 2024
@mdb mdb deleted the mdb/download-release-asset-in-renamed-repo branch December 26, 2024 11:40
mdb added a commit to mdb/terraform-provider-github that referenced this pull request Dec 21, 2025
Per request of @deiga (integrations#2514 (comment)),
this adds tests for previewHeaderInjectorTransport.RoundTrip logic
around application/octest-stream header handling.

See google/go-github#3392 for context.

Signed-off-by: Mike Ball <mikedball@gmail.com>
mdb added a commit to mdb/terraform-provider-github that referenced this pull request Jan 8, 2026
Per request of @deiga (integrations#2514 (comment)),
this adds tests for previewHeaderInjectorTransport.RoundTrip logic
around application/octest-stream header handling.

See google/go-github#3392 for context.

Signed-off-by: Mike Ball <mikedball@gmail.com>
mdb added a commit to mdb/terraform-provider-github that referenced this pull request Jan 8, 2026
Per request of @deiga (integrations#2514 (comment)),
this adds tests for previewHeaderInjectorTransport.RoundTrip logic
around application/octest-stream header handling.

See google/go-github#3392 for context.

Signed-off-by: Mike Ball <mikedball@gmail.com>
mdb added a commit to mdb/terraform-provider-github that referenced this pull request Jan 9, 2026
Per request of @deiga (integrations#2514 (comment)),
this adds tests for previewHeaderInjectorTransport.RoundTrip logic
around application/octest-stream header handling.

See google/go-github#3392 for context.

Signed-off-by: Mike Ball <mikedball@gmail.com>
mdb added a commit to mdb/terraform-provider-github that referenced this pull request Jan 12, 2026
Per request of @deiga (integrations#2514 (comment)),
this adds tests for previewHeaderInjectorTransport.RoundTrip logic
around application/octest-stream header handling.

See google/go-github#3392 for context.

Signed-off-by: Mike Ball <mikedball@gmail.com>
mdb added a commit to mdb/terraform-provider-github that referenced this pull request Jan 16, 2026
Per request of @deiga (integrations#2514 (comment)),
this adds tests for previewHeaderInjectorTransport.RoundTrip logic
around application/octest-stream header handling.

See google/go-github#3392 for context.

Signed-off-by: Mike Ball <mikedball@gmail.com>
mdb added a commit to mdb/terraform-provider-github that referenced this pull request Jan 16, 2026
Per request of @deiga (integrations#2514 (comment)),
this adds tests for previewHeaderInjectorTransport.RoundTrip logic
around application/octest-stream header handling.

See google/go-github#3392 for context.

Signed-off-by: Mike Ball <mikedball@gmail.com>
mdb added a commit to mdb/terraform-provider-github that referenced this pull request Jan 21, 2026
Per request of @deiga (integrations#2514 (comment)),
this adds tests for previewHeaderInjectorTransport.RoundTrip logic
around application/octest-stream header handling.

See google/go-github#3392 for context.

Signed-off-by: Mike Ball <mikedball@gmail.com>
mdb added a commit to mdb/terraform-provider-github that referenced this pull request Jan 29, 2026
Per request of @deiga (integrations#2514 (comment)),
this adds tests for previewHeaderInjectorTransport.RoundTrip logic
around application/octest-stream header handling.

See google/go-github#3392 for context.

Signed-off-by: Mike Ball <mikedball@gmail.com>
stevehipwell pushed a commit to integrations/terraform-provider-github that referenced this pull request Jan 29, 2026
* feat: add github_release_asset data source

This addresses issue #2513 and adds support for a `github_release_asset`
data source.

Example of passing acceptance tests:

```
GITHUB_ORGANIZATION=mterwill \
GITHUB_OWNER=mterwill \
TF_ACC=1 \
  go test -v ./... -run ^TestAccGithubReleaseAssetDataSource
?       github.com/integrations/terraform-provider-github/v6    [no test files]
=== RUN   TestAccGithubReleaseAssetDataSource
=== RUN   TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID
=== RUN   TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID/with_an_anonymous_account
    provider_utils.go:51: GITHUB_TOKEN environment variable should be empty
    provider_utils.go:74: Skipping TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID/with_an_anonymous_account which requires anonymous mode
=== RUN   TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID/with_an_individual_account
=== RUN   TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID/with_an_organization_account
--- PASS: TestAccGithubReleaseAssetDataSource (11.65s)
    --- PASS: TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID (11.65s)
        --- SKIP: TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID/with_an_anonymous_account (0.00s)
        --- PASS: TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID/with_an_individual_account (8.90s)
        --- PASS: TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID/with_an_organization_account (2.75s)
PASS
ok      github.com/integrations/terraform-provider-github/v6/github     12.434s
```

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(config): test previewHeaderInjectorTransport.RoundTrip

Per request of @deiga (#2514 (comment)),
this adds tests for previewHeaderInjectorTransport.RoundTrip logic
around application/octest-stream header handling.

See google/go-github#3392 for context.

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore: github_release_asset data source tests use new test patterns

Per code review feedback from @deiga (#2514 (comment)),
this updates the github_release_asset data source tests to use the new
testing patterns implemented in #2986

This was tested via:

```
$ TF_ACC=1 \
  go test -v ./... -run ^TestAccGithubReleaseAssetDataSource
?       github.com/integrations/terraform-provider-github/v6    [no test files]
=== RUN   TestAccGithubReleaseAssetDataSource
=== RUN   TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID
--- PASS: TestAccGithubReleaseAssetDataSource (5.91s)
    --- PASS: TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID (5.91s)
PASS
ok      github.com/integrations/terraform-provider-github/v6/github     6.788s
```

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(data_source_github_release_asset): use if err := ...; err != nil pattern

Per code review feedback (#2514 (comment)) from @stevehipwell, this tweaks the
`data_source_github_release_asset` to use the `if err := ...; err != nil` pattern
towards the goal of improving readability.

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(data_source_github_release_asset): improve terseness

Use idiomatic `:=` pattern over `var`-pre-defined variables, per
code review feedback from @stevehipwell:

#2514 (comment)

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(data_source_github_release_asset_test): inline ComposeTestCheckFunc

This inlines `resource.ComposeTestCheckFunc` to improve readability
(rather than define it as a variable), per code review feedback from @stevehipwell:

#2514 (comment)

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(data_source_github_release_asset): source config from acc_test.go

Per code review feedback from @stevehipwell, this simplifies test
configuration:

- source test configuration from `testAccConf`, as done elsewhere
- remove the ability to override test configuration via `GH_TEST_*` env vars;
  this is arguably premature optimization and can be added to `acc_test.go` if
  it's needed in the future

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(data_source_github_release_asset): remove unnecessary TestCase.Providers

Per code review feedback from @deiga, this removes unnecessary Providers
configuration from the data_source_github_release_asset tests.

#2514 (comment)

Signed-off-by: Mike Ball <mikedball@gmail.com>

* fix(data_source_github_release_asset): use composite ID

To protect against the possibility that release asset IDs are not
globally unique across GitHub, this configures the use of a 3-part
composite ID when tracking `data_source_github_release_asset` instances
in TF state.

This addresses code review feedback from @deiga:

#2514 (comment)

Signed-off-by: Mike Ball <mikedball@gmail.com>

* fix(data_source_github_release_asset): avoid client mutation

Per code review feedback from @stevehipwell (#2514 (comment)),
this avoids the use of `client.Repositories.DownloadReleaseAsset` out of
concern the function modifies the GitHub client state which could cause
unexpected behaviour in Terraform.

Signed-off-by: Mike Ball <mikedball@gmail.com>

* fix(data_source_github_release_asset): properly set updated_at

This fixes a copy/paste bug; updated_at is now correctly set on the data source.

Signed-off-by: Mike Ball <mikedball@gmail.com>

* feat(data_source_github_release_asset): make download configurable

Per code review feedback from @stevehipwell (#2514 (review)),
this makes the release asset download optional, controlled by a `download_body`
attribute, and off by default.

Signed-off-by: Mike Ball <mikedball@gmail.com>

* 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>

* fix(data_source_github_release_asset): base64 encode `file`

Per code review feedback from @stevehipwell
(#2514 (comment)),
this ensures `file` is base64-encoded.

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(data_source_github_release_asset): adjust file contents attributes

Per code review feedback from @stevehipwell, this changes `download_file`/`file`
to `download_file_contents`/`file_contents`, respectively:
#2514 (comment)

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(data_source_github_release_asset): improve acc test

This improves the `data_source_github_release_asset` acceptance tests to
be more TF-focused via use of the `base64decode` function, per code
review request of @stevehipwell: #2514 (comment)

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(data_source_github_release_asset_test): appease linting

This commits the result of `gofumpt`, as per lint failures in:
https://github.com/integrations/terraform-provider-github/actions/runs/21232219897/job/61621068985?pr=2514

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(config_test): appease lint errors

This appeases lint warnings in `github/config_test.go`:

https://github.com/integrations/terraform-provider-github/actions/runs/21232219897/job/61621068985?pr=2514

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(config): address staticcheck errors

This addresses the following staticcheck error (seen in https://github.com/integrations/terraform-provider-github/actions/runs/21232219897/job/61621068985?pr=2514):

```
Error: github/config.go:196:13: QF1001: could apply De Morgan's law (staticcheck)
```

Signed-off-by: Mike Ball <mikedball@gmail.com>

* fix(config_test): use canonical HTTP header names in expectedHeaders

Go's http.Header canonicalizes header names (e.g., X-GitHub-Api-Version
becomes X-Github-Api-Version). The test's unexpected header check was
failing because it compared canonical names against non-canonical keys
in the expectedHeaders map.

Signed-off-by: Mike Ball <mikedball@gmail.com>

---------

Signed-off-by: Mike Ball <mikedball@gmail.com>
deiga pushed a commit to F-Secure-web/terraform-provider-github that referenced this pull request Jan 29, 2026
* feat: add github_release_asset data source

This addresses issue integrations#2513 and adds support for a `github_release_asset`
data source.

Example of passing acceptance tests:

```
GITHUB_ORGANIZATION=mterwill \
GITHUB_OWNER=mterwill \
TF_ACC=1 \
  go test -v ./... -run ^TestAccGithubReleaseAssetDataSource
?       github.com/integrations/terraform-provider-github/v6    [no test files]
=== RUN   TestAccGithubReleaseAssetDataSource
=== RUN   TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID
=== RUN   TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID/with_an_anonymous_account
    provider_utils.go:51: GITHUB_TOKEN environment variable should be empty
    provider_utils.go:74: Skipping TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID/with_an_anonymous_account which requires anonymous mode
=== RUN   TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID/with_an_individual_account
=== RUN   TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID/with_an_organization_account
--- PASS: TestAccGithubReleaseAssetDataSource (11.65s)
    --- PASS: TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID (11.65s)
        --- SKIP: TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID/with_an_anonymous_account (0.00s)
        --- PASS: TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID/with_an_individual_account (8.90s)
        --- PASS: TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID/with_an_organization_account (2.75s)
PASS
ok      github.com/integrations/terraform-provider-github/v6/github     12.434s
```

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(config): test previewHeaderInjectorTransport.RoundTrip

Per request of @deiga (integrations#2514 (comment)),
this adds tests for previewHeaderInjectorTransport.RoundTrip logic
around application/octest-stream header handling.

See google/go-github#3392 for context.

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore: github_release_asset data source tests use new test patterns

Per code review feedback from @deiga (integrations#2514 (comment)),
this updates the github_release_asset data source tests to use the new
testing patterns implemented in integrations#2986

This was tested via:

```
$ TF_ACC=1 \
  go test -v ./... -run ^TestAccGithubReleaseAssetDataSource
?       github.com/integrations/terraform-provider-github/v6    [no test files]
=== RUN   TestAccGithubReleaseAssetDataSource
=== RUN   TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID
--- PASS: TestAccGithubReleaseAssetDataSource (5.91s)
    --- PASS: TestAccGithubReleaseAssetDataSource/queries_specified_asset_ID (5.91s)
PASS
ok      github.com/integrations/terraform-provider-github/v6/github     6.788s
```

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(data_source_github_release_asset): use if err := ...; err != nil pattern

Per code review feedback (integrations#2514 (comment)) from @stevehipwell, this tweaks the
`data_source_github_release_asset` to use the `if err := ...; err != nil` pattern
towards the goal of improving readability.

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(data_source_github_release_asset): improve terseness

Use idiomatic `:=` pattern over `var`-pre-defined variables, per
code review feedback from @stevehipwell:

integrations#2514 (comment)

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(data_source_github_release_asset_test): inline ComposeTestCheckFunc

This inlines `resource.ComposeTestCheckFunc` to improve readability
(rather than define it as a variable), per code review feedback from @stevehipwell:

integrations#2514 (comment)

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(data_source_github_release_asset): source config from acc_test.go

Per code review feedback from @stevehipwell, this simplifies test
configuration:

- source test configuration from `testAccConf`, as done elsewhere
- remove the ability to override test configuration via `GH_TEST_*` env vars;
  this is arguably premature optimization and can be added to `acc_test.go` if
  it's needed in the future

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(data_source_github_release_asset): remove unnecessary TestCase.Providers

Per code review feedback from @deiga, this removes unnecessary Providers
configuration from the data_source_github_release_asset tests.

integrations#2514 (comment)

Signed-off-by: Mike Ball <mikedball@gmail.com>

* fix(data_source_github_release_asset): use composite ID

To protect against the possibility that release asset IDs are not
globally unique across GitHub, this configures the use of a 3-part
composite ID when tracking `data_source_github_release_asset` instances
in TF state.

This addresses code review feedback from @deiga:

integrations#2514 (comment)

Signed-off-by: Mike Ball <mikedball@gmail.com>

* fix(data_source_github_release_asset): avoid client mutation

Per code review feedback from @stevehipwell (integrations#2514 (comment)),
this avoids the use of `client.Repositories.DownloadReleaseAsset` out of
concern the function modifies the GitHub client state which could cause
unexpected behaviour in Terraform.

Signed-off-by: Mike Ball <mikedball@gmail.com>

* fix(data_source_github_release_asset): properly set updated_at

This fixes a copy/paste bug; updated_at is now correctly set on the data source.

Signed-off-by: Mike Ball <mikedball@gmail.com>

* feat(data_source_github_release_asset): make download configurable

Per code review feedback from @stevehipwell (integrations#2514 (review)),
this makes the release asset download optional, controlled by a `download_body`
attribute, and off by default.

Signed-off-by: Mike Ball <mikedball@gmail.com>

* 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:
integrations#2514 (comment)

Signed-off-by: Mike Ball <mikedball@gmail.com>

* fix(data_source_github_release_asset): base64 encode `file`

Per code review feedback from @stevehipwell
(integrations#2514 (comment)),
this ensures `file` is base64-encoded.

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(data_source_github_release_asset): adjust file contents attributes

Per code review feedback from @stevehipwell, this changes `download_file`/`file`
to `download_file_contents`/`file_contents`, respectively:
integrations#2514 (comment)

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(data_source_github_release_asset): improve acc test

This improves the `data_source_github_release_asset` acceptance tests to
be more TF-focused via use of the `base64decode` function, per code
review request of @stevehipwell: integrations#2514 (comment)

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(data_source_github_release_asset_test): appease linting

This commits the result of `gofumpt`, as per lint failures in:
https://github.com/integrations/terraform-provider-github/actions/runs/21232219897/job/61621068985?pr=2514

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(config_test): appease lint errors

This appeases lint warnings in `github/config_test.go`:

https://github.com/integrations/terraform-provider-github/actions/runs/21232219897/job/61621068985?pr=2514

Signed-off-by: Mike Ball <mikedball@gmail.com>

* chore(config): address staticcheck errors

This addresses the following staticcheck error (seen in https://github.com/integrations/terraform-provider-github/actions/runs/21232219897/job/61621068985?pr=2514):

```
Error: github/config.go:196:13: QF1001: could apply De Morgan's law (staticcheck)
```

Signed-off-by: Mike Ball <mikedball@gmail.com>

* fix(config_test): use canonical HTTP header names in expectedHeaders

Go's http.Header canonicalizes header names (e.g., X-GitHub-Api-Version
becomes X-Github-Api-Version). The test's unexpected header check was
failing because it compared canonical names against non-canonical keys
in the expectedHeaders map.

Signed-off-by: Mike Ball <mikedball@gmail.com>

---------

Signed-off-by: Mike Ball <mikedball@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants