-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cue/load: use modpkgload to resolve dependencies
This uses exactly the same logic as `cue mod tidy` to resolve all the dependencies for `cue/load`. It's not hugely efficient as we end up doing a redundant scan through all the imports, but fixing that would require a much more significant refactor of `cue/load` which we'd like to avoid for now. It does expose some deficiencies in the current test data: the dependency resolution will now fail if a dependency isn't explicitly mentioned in the main module - something that's easily remedied by running `cue mod tidy`. We also implement a rule for defaulting the major version of the main module: - if there's no major version in the module path in the module.cue file, we assume @v0. - the default major version for the main module is always that specified in the `module:` declaration (and we reject a module file that tried to specify default major version for a different major version of the main module) Signed-off-by: Roger Peppe <[email protected]> Change-Id: I8ce8719d834ad1449097c17846f35445991bf36b Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1175995 Reviewed-by: Daniel Martí <[email protected]> Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
- Loading branch information
Showing
17 changed files
with
184 additions
and
80 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -10,8 +10,7 @@ env CUE_MODCACHE=$WORK/.tmp/different-cache | |
env-fill dockerconfig/badpassword.json | ||
cp dockerconfig/badpassword.json dockerconfig/config.json | ||
! exec cue export . | ||
stderr 'instance: cannot resolve dependencies: example.com/[email protected]: module example.com/[email protected]: error response: 401 Unauthorized; body: "invalid credentials' | ||
|
||
stderr 'import failed: cannot find package "example.com/e": cannot fetch example.com/[email protected]: module example.com/[email protected]: error response: 401 Unauthorized; body: "invalid credentials' | ||
-- dockerconfig/config.json -- | ||
{ | ||
"auths": { | ||
|
This file contains 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 |
---|---|---|
|
@@ -12,8 +12,7 @@ cmp stdout expect-stdout | |
cp OTHER/main.cue main.cue | ||
cp OTHER/cue.mod/module.cue cue.mod/module.cue | ||
! exec cue export . | ||
stderr 'instance: cannot resolve dependencies: example.com/[email protected]: module example.com/[email protected]: cannot make client: cannot load OCI auth configuration: invalid config file ".*config.json": decode failed: .*' | ||
|
||
stderr '^import failed: cannot find package "example.com/e": cannot fetch example.com/[email protected]: module example.com/[email protected]: cannot make client: cannot load OCI auth configuration: invalid config file ".*config.json": decode failed: .*' | ||
-- dockerconfig/config.json -- | ||
should be JSON but isn't | ||
-- expect-stdout -- | ||
|
This file contains 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 |
---|---|---|
|
@@ -5,7 +5,8 @@ | |
cmp stderr expect-stderr | ||
|
||
-- expect-stderr -- | ||
instance: cannot resolve dependencies: example.com/[email protected]: module example.com/[email protected]: module not found | ||
import failed: cannot find package "example.com/e": cannot fetch example.com/[email protected]: module example.com/[email protected]: module not found: | ||
./main.cue:2:8 | ||
-- main.cue -- | ||
package main | ||
import "example.com/e" | ||
|
@@ -18,5 +19,5 @@ deps: "example.com/e": v: "v0.0.2" | |
-- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- | ||
module: "example.com/e@v0" | ||
|
||
-- main.cue -- | ||
-- _registry/example.com_e_v0.0.1/main.cue -- | ||
package e |
This file contains 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 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 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 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 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 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 |
---|---|---|
|
@@ -3,7 +3,8 @@ env CUE_REGISTRY=$DEBUG_REGISTRY_HOST/something+insecure | |
cmp stderr expect-stderr | ||
|
||
-- expect-stderr -- | ||
instance: cannot resolve dependencies: example.com/[email protected]: module example.com/[email protected]: 404 Not Found: name unknown: repository name not known to registry | ||
import failed: cannot find package "example.com/e": cannot fetch example.com/[email protected]: module example.com/[email protected]: 404 Not Found: name unknown: repository name not known to registry: | ||
./main.cue:2:8 | ||
-- main.cue -- | ||
package main | ||
import "example.com/e" | ||
|
@@ -16,5 +17,7 @@ deps: "example.com/e": v: "v0.0.1" | |
-- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- | ||
module: "example.com/e@v0" | ||
|
||
-- main.cue -- | ||
-- _registry/example.com_e_v0.0.1/main.cue -- | ||
package e | ||
|
||
foo: "blah" |
This file contains 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 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 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.