Skip to content

Commit

Permalink
feat: Add simple inconsistency on missing dependency
Browse files Browse the repository at this point in the history
Signed-off-by: Víctor Cuadrado Juan <[email protected]>
  • Loading branch information
viccuad committed Jun 29, 2021
1 parent 2cc8cd8 commit 16b40e2
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 4 deletions.
14 changes: 12 additions & 2 deletions internal/solver/solver.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type PkgResultSet struct {
ToInstall []*pkg.Pkg
ToRemove []*pkg.Pkg
Status string
//Incosistencies []
Inconsistencies []string
}

type OutputMode int
Expand All @@ -76,10 +76,12 @@ const (

// New creates a new Solver, initializing its database.
func New() (s *Solver) {
return &Solver{
s = &Solver{
PkgDB: CreatePkgDBInstance(),
pkgResultSet: PkgResultSet{},
}
s.pkgResultSet.Inconsistencies = []string{}
return s
}

// BuildWorldMock fills the database with pkgs instead of releases, charts from
Expand Down Expand Up @@ -269,6 +271,14 @@ func (s *Solver) buildConstraintRelations(p *pkg.Pkg) (constr []gsolver.PBConstr
matchingVersionIDs = append(matchingVersionIDs, depID)
}
}
if len(matchingVersionIDs) == 0 {
// there are no packages that match the version we depend on, add
// that to inconsistencies
// TODO create acyclic graph of result instead
incos := fmt.Sprintf("Package %s depends on %s, semver %s, but nothing satisfies it\n",
p.GetFingerPrint(), deprel.BaseFingerprint, deprel.SemverRange)
s.pkgResultSet.Inconsistencies = append(s.pkgResultSet.Inconsistencies, incos)
}

// A depends on all valid versions of B.
// Pseudo-Boolean equation:
Expand Down
2 changes: 1 addition & 1 deletion internal/solver/testdata/output/format-empty-json.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"PresentUnchanged":[],"ToInstall":[],"ToRemove":[],"Status":"SAT"}
{"PresentUnchanged":[],"ToInstall":[],"ToRemove":[],"Status":"SAT","Inconsistencies":[]}
1 change: 1 addition & 0 deletions internal/solver/testdata/output/format-empty-yaml.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ presentunchanged: []
toinstall: []
toremove: []
status: SAT
inconsistencies: []
2 changes: 1 addition & 1 deletion internal/solver/testdata/output/format-unsat-json.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"PresentUnchanged":[{"Name":"bar","Version":"1.0.0","ChartHash":0,"Namespace":"targetns","DependsRel":null,"DependsOptionalRel":null,"CurrentState":1,"DesiredState":1,"Chart":null}],"ToInstall":[{"Name":"baz","Version":"1.0.0","ChartHash":0,"Namespace":"targetns","DependsRel":null,"DependsOptionalRel":null,"CurrentState":2,"DesiredState":1,"Chart":null}],"ToRemove":[{"Name":"foo","Version":"1.0.0","ChartHash":0,"Namespace":"targetns","DependsRel":null,"DependsOptionalRel":null,"CurrentState":1,"DesiredState":2,"Chart":null}],"Status":"SAT"}
{"PresentUnchanged":[{"Name":"bar","Version":"1.0.0","ChartHash":0,"Namespace":"targetns","DependsRel":null,"DependsOptionalRel":null,"CurrentState":1,"DesiredState":1,"Chart":null}],"ToInstall":[{"Name":"baz","Version":"1.0.0","ChartHash":0,"Namespace":"targetns","DependsRel":null,"DependsOptionalRel":null,"CurrentState":2,"DesiredState":1,"Chart":null}],"ToRemove":[{"Name":"foo","Version":"1.0.0","ChartHash":0,"Namespace":"targetns","DependsRel":null,"DependsOptionalRel":null,"CurrentState":1,"DesiredState":2,"Chart":null}],"Status":"SAT","Inconsistencies":[]}
1 change: 1 addition & 0 deletions internal/solver/testdata/output/format-unsat-yaml.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ toremove:
desiredstate: 2
chart: null
status: SAT
inconsistencies: []
1 change: 1 addition & 0 deletions internal/solver/testdata/output/solve-empty.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ presentunchanged: []
toinstall: []
toremove: []
status: SAT
inconsistencies: []
1 change: 1 addition & 0 deletions internal/solver/testdata/output/solve-main.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ toinstall:
chart: null
toremove: []
status: SAT
inconsistencies: []
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ toinstall:
chart: null
toremove: []
status: SAT
inconsistencies: []
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ toinstall:
chart: null
toremove: []
status: SAT
inconsistencies: []
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ toinstall:
chart: null
toremove: []
status: SAT
inconsistencies: []
1 change: 1 addition & 0 deletions internal/solver/testdata/output/solve-sat-loop-deps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ toinstall:
chart: null
toremove: []
status: SAT
inconsistencies: []
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ toremove:
desiredstate: 2
chart: null
status: SAT
inconsistencies: []
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ presentunchanged: []
toinstall: []
toremove: []
status: UNSAT
inconsistencies:
- |
Package wantedbaz-1.0.0-0-wantedbazns depends on myawesomedep-myawesomedeptargetns, semver ^1.0.0, but nothing satisfies it
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ presentunchanged: []
toinstall: []
toremove: []
status: UNSAT
inconsistencies:
- |
Package wantedbaz-1.0.0-0-wantedbazns depends on myawesomedep-myawesomedeptargetns, semver ^1.0.0, but nothing satisfies it
1 change: 1 addition & 0 deletions internal/solver/testdata/output/solve-unsat-remove-dep.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ presentunchanged: []
toinstall: []
toremove: []
status: UNSAT
inconsistencies: []

0 comments on commit 16b40e2

Please sign in to comment.