This repository has been archived by the owner on Sep 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make importers error tolerant (#1474)
* make importers error tolerant - root_analyzer.go: Log a warning on encountering an unrecoverable error during import of external config and proceed with the import for other packages. Do not return error from private func `importManifestAndLock`. internal/importers: - base/importer.go: - `loadPackages`: Do not return error. If `SourceManager.DeduceProjectRoot` fails to determine the project root, log a warning and continue with the rest of the imported packages. - `ImportPackages`: Do not return error. When constraint resolution from the lock hint fails, only log a warning. - Importer implementations: - Return an error from `Import` only for catastrophic failures(ex: yaml parsing failed). - `load`: Make it more error tolerant. Log warnings only for any of the following scenarios: - When and if a lock file, separate from the dependency file is present, like, in the case of glide, and parsing fails. Continue with the import as if the lock file was not present. - If import packages are parsed line by line like in the case of glock, and one of the line could not be parsed. - `convert`: Do not return an error. Log warnings only for any of the following scenarios: - Expected field, such as `package` for an entry in `glide.yaml>imports` is not present. - Package was specified but the contraint could not be found. * update importer tests * improve importer warning msgs Address feedback from @carolynvs * add tests for importer failure scenarios - internal/importers/base/importer_test.go: - Check for warning when an invalid project is present whose project root cannot be parsed. - Check for warning when lock hint cannot be resolved correctly and the constraint cannot be applied. - Integration test for malformed external config(glide.yaml) * tweak importer warnings - {package => project} - Improve warning message when no constraint is found for the package being imported. * update changelog
- Loading branch information
1 parent
73e9c75
commit 7bf4611
Showing
26 changed files
with
297 additions
and
144 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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
Ignore glide config if glide.yaml is malformed and cannot be parsed correctly. |
21 changes: 21 additions & 0 deletions
21
cmd/dep/testdata/harness_tests/init/glide/case4/final/Gopkg.lock
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
cmd/dep/testdata/harness_tests/init/glide/case4/final/Gopkg.toml
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
[[constraint]] | ||
name = "github.com/sdboyer/deptestdos" | ||
version = "2.0.0" |
20 changes: 20 additions & 0 deletions
20
cmd/dep/testdata/harness_tests/init/glide/case4/initial/glide.yaml
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'package: github.com/golang/notexist | ||
homepage: http://example.com | ||
license: MIT | ||
owners: | ||
- name: Sam Boyer | ||
email: [email protected] | ||
homepage: http://sdboyer.io | ||
ignore: | ||
- github.com/sdboyer/dep-test | ||
excludeDirs: | ||
- samples | ||
import: | ||
- package: github.com/sdboyer/deptest # This is a transitive dep and will be ignored | ||
repo: https://github.com/sdboyer/deptest.git | ||
vcs: git | ||
version: v1.0.0 | ||
- package: github.com/sdboyer/deptestdos | ||
version: v2.0.0 | ||
testImport: | ||
- package: github.com/golang/lint |
16 changes: 16 additions & 0 deletions
16
cmd/dep/testdata/harness_tests/init/glide/case4/initial/main.go
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2017 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/sdboyer/deptestdos" | ||
) | ||
|
||
func main() { | ||
var x deptestdos.Bar | ||
fmt.Println(x) | ||
} |
14 changes: 14 additions & 0 deletions
14
cmd/dep/testdata/harness_tests/init/glide/case4/testcase.json
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"commands": [ | ||
["init", "-no-examples"] | ||
], | ||
"error-expected": "", | ||
"gopath-initial": { | ||
"github.com/sdboyer/deptest": "3f4c3bea144e112a69bbe5d8d01c1b09a544253f", | ||
"github.com/sdboyer/deptestdos": "5c607206be5decd28e6263ffffdcee067266015e" | ||
}, | ||
"vendor-final": [ | ||
"github.com/sdboyer/deptest", | ||
"github.com/sdboyer/deptestdos" | ||
] | ||
} |
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
Oops, something went wrong.