mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-06 16:25:21 -04:00
bazel-deps-mirror: upgrade command (#1617)
* bazel-deps-mirror: upgrade command This command can be used to upgrade a dependency. Users are supposed to replace any upstream URLs and run the upgrade command. It replaces the expected hash and uploads the new dep to the mirror.
This commit is contained in:
parent
69de06dd1f
commit
0ece41c146
13 changed files with 476 additions and 29 deletions
|
@ -448,3 +448,54 @@ http_archive(
|
|||
_, err = GetHash(rules[1])
|
||||
assert.Error(err)
|
||||
}
|
||||
|
||||
func TestPrepareUpgrade(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
require := require.New(t)
|
||||
|
||||
rule := `
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
http_archive(
|
||||
name = "foo_archive",
|
||||
sha256 = "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae",
|
||||
urls = [
|
||||
"https://cdn.confidential.cloud/constellation/cas/sha256/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae",
|
||||
"https://mirror.bazel.build/example.com/foo.tar.gz",
|
||||
"https://example.com/foo.tar.gz",
|
||||
],
|
||||
type = "tar.gz",
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "bar_archive",
|
||||
sha256 = "2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae",
|
||||
urls = [
|
||||
"https://cdn.confidential.cloud/constellation/cas/sha256/2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae",
|
||||
"https://mirror.bazel.build/example.com/foo.tar.gz",
|
||||
],
|
||||
type = "tar.gz",
|
||||
)
|
||||
`
|
||||
bf, err := build.Parse("foo.bzl", []byte(rule))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rules := Rules(bf, SupportedRules)
|
||||
require.Len(rules, 2)
|
||||
|
||||
changed, err := PrepareUpgrade(rules[0])
|
||||
assert.NoError(err)
|
||||
assert.True(changed)
|
||||
|
||||
urls := GetURLs(rules[0])
|
||||
assert.Equal(1, len(urls))
|
||||
assert.Equal("https://example.com/foo.tar.gz", urls[0])
|
||||
hash, err := GetHash(rules[0])
|
||||
assert.Empty(hash)
|
||||
assert.Error(err)
|
||||
|
||||
changed, err = PrepareUpgrade(rules[1])
|
||||
assert.ErrorIs(err, ErrNoUpstreamURL)
|
||||
assert.False(changed)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue