The functionality of checking whether the lock file is out-of-date or not is
quite important to end-users. But digest comparison is not an answer for it.
This commit implements it in an alternative way, which compares names, repos,
and version resolutions in each pair of Chart.yaml and Chart.lock dependencies.
Signed-off-by: Hang Park <hangpark@kaist.ac.kr>
// Filter dependencies in Chart.yaml which is not in Chart.lock.
for_,cd:=rangechartDeps{
ifcd.Repository==""{
// Don't care about local subcharts during building dependencies.
continue
}
// Chart.yaml can have SemVer range.
constraint,err:=semver.NewConstraint(cd.Version)
iferr!=nil{
returnerrors.Wrapf(err,"dependency %q in Chart.yaml has an invalid version/constraint format",cd.Name)
}
found:=false
for_,ld:=rangelSorted{
ifcd.Name!=ld.Name||cd.Repository!=ld.Repository{
continue
}
ldVer,err:=semver.NewVersion(ld.Version)
iferr!=nil{
returnerrors.Wrapf(err,"dependency %q in Chart.lock has an invalid version format",ld.Name)
}elseifconstraint.Check(ldVer){
// Lock dependencies are sorted, so the matched version is the highest version among available candidates.
found=true
lm[ld]=true
break
}
}
if!found{
cMissing=append(cMissing,cd.Name)
}
}
iflen(cMissing)>0{
returnerrors.Errorf("dependencies %s in Chart.yaml don't have a valid version resolution in Chart.lock. Try updating Chart.lock",strings.Join(cMissing,", "))
}
// All Chart.yaml dependencies are resolved in Chart.lock.
// But we should check whether all Chart.lock dependencies are needed by Chart.yaml.
for_,ld:=rangelSorted{
if_,ok:=lm[ld];!ok{
lMissing=append(lMissing,ld.Name)
}
}
iflen(lMissing)>0{
returnerrors.Errorf("dependencies %s in Chart.lock are not required by Chart.yaml. Try updating Chart.lock",strings.Join(lMissing,", "))