Skip to content

Commit

Permalink
Correct usage of bytes, add ref url
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Manuel Leflet Estrada <[email protected]>
  • Loading branch information
jmle committed Feb 8, 2024
1 parent 5af5aac commit 373d80d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions provider/internal/java/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,24 +427,27 @@ func (p *javaServiceClient) parseDepString(dep, localRepoPath, pomPath string) (
// resolveDepFilepath tries to extract a valid filepath for the dependency with either JAR or POM packaging
func resolveDepFilepath(dep *provider.Dep, p *javaServiceClient, group string, artifact string, localRepoPath string) string {
groupPath := strings.Replace(group, ".", "/", -1)

// Try jar packaging
fp := getFilepathForPackaging(dep, localRepoPath, groupPath, artifact, "jar")
b, err := os.ReadFile(fp)
if err != nil {
// Try pom packaging
// Try pom packaging (see https://www.baeldung.com/maven-packaging-types#4-pom)
fp := getFilepathForPackaging(dep, localRepoPath, groupPath, artifact, "pom")
b, err = os.ReadFile(fp)
if err != nil {
// Log the error and continue with the next dependency.
p.log.V(5).Error(err, "error reading SHA hash file for dependency", "dep", dep.Name)
// Set some default or empty resolved identifier for the dependency.
dep.ResolvedIdentifier = ""
}
}

if err != nil {
// Log the error and continue with the next dependency.
p.log.V(5).Error(err, "error reading SHA hash file for dependency", "dep", dep.Name)
// Set some default or empty resolved identifier for the dependency.
dep.ResolvedIdentifier = ""
} else {
// sometimes sha file contains name of the jar followed by the actual sha
sha, _, _ := strings.Cut(string(b), " ")
dep.ResolvedIdentifier = sha
}

return fp
}

Expand Down

0 comments on commit 373d80d

Please sign in to comment.