-
Notifications
You must be signed in to change notification settings - Fork 160
Pin Alpine image digest and add SHA256 verification for TF provider #4849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9b3aed6
Pin Alpine image digest and add SHA256 verification for TF provider d…
shreyas-goenka fc48e0d
Auto-fetch provider checksums during codegen instead of hardcoding
shreyas-goenka cbbc9a3
Skip checksum download tests in short mode
shreyas-goenka cf17652
Move provider checksum verification from unit test to codegen sanity …
shreyas-goenka 54b9d8a
Revert changes to pkg_test.go
shreyas-goenka faf0949
Verify both linux_amd64 and linux_arm64 provider checksums during cod…
shreyas-goenka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| package schema | ||
|
|
||
| import ( | ||
| "bufio" | ||
| "fmt" | ||
| "net/http" | ||
| "strings" | ||
| ) | ||
|
|
||
| // ProviderChecksums holds the SHA256 checksums for the Databricks Terraform | ||
| // provider archive for supported Linux architectures. | ||
| type ProviderChecksums struct { | ||
| LinuxAmd64 string | ||
| LinuxArm64 string | ||
| } | ||
|
|
||
| // FetchProviderChecksums downloads the SHA256SUMS file from the GitHub release | ||
| // for the given provider version and extracts checksums for the linux_amd64 and | ||
| // linux_arm64 archives. | ||
| // https://github.com/databricks/terraform-provider-databricks/releases | ||
| func FetchProviderChecksums(version string) (*ProviderChecksums, error) { | ||
| url := fmt.Sprintf( | ||
| "https://github.com/databricks/terraform-provider-databricks/releases/download/v%s/terraform-provider-databricks_%s_SHA256SUMS", | ||
| version, version, | ||
| ) | ||
|
|
||
| resp, err := http.Get(url) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("downloading SHA256SUMS for provider v%s: %w", version, err) | ||
| } | ||
| defer resp.Body.Close() | ||
|
|
||
| if resp.StatusCode != http.StatusOK { | ||
| return nil, fmt.Errorf("downloading SHA256SUMS for provider v%s: HTTP %s", version, resp.Status) | ||
| } | ||
|
|
||
| checksums := &ProviderChecksums{} | ||
| amd64Suffix := fmt.Sprintf("terraform-provider-databricks_%s_linux_amd64.zip", version) | ||
| arm64Suffix := fmt.Sprintf("terraform-provider-databricks_%s_linux_arm64.zip", version) | ||
|
|
||
| scanner := bufio.NewScanner(resp.Body) | ||
| for scanner.Scan() { | ||
| line := scanner.Text() | ||
| parts := strings.Fields(line) | ||
| if len(parts) != 2 { | ||
| continue | ||
| } | ||
| switch parts[1] { | ||
| case amd64Suffix: | ||
| checksums.LinuxAmd64 = parts[0] | ||
| case arm64Suffix: | ||
| checksums.LinuxArm64 = parts[0] | ||
| } | ||
| } | ||
| if err := scanner.Err(); err != nil { | ||
| return nil, fmt.Errorf("reading SHA256SUMS for provider v%s: %w", version, err) | ||
| } | ||
|
|
||
| if checksums.LinuxAmd64 == "" { | ||
| return nil, fmt.Errorf("checksum not found for %s in SHA256SUMS", amd64Suffix) | ||
| } | ||
| if checksums.LinuxArm64 == "" { | ||
| return nil, fmt.Errorf("checksum not found for %s in SHA256SUMS", arm64Suffix) | ||
| } | ||
|
|
||
| return checksums, nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.