Skip to content

Commit

Permalink
Fix splitting artifact name property (#4379)
Browse files Browse the repository at this point in the history
If the artifact name had contained a slash, we would have failed to
parse it. Treat the owner as what's up to the first slash and the rest
as the artifact name.
  • Loading branch information
jhrozek authored Sep 5, 2024
1 parent c8c9c1d commit b496555
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions internal/providers/github/properties/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,20 @@ func getNameFromParams(owner, name string) string {
}

func parseArtifactName(name string) (string, string, string, error) {
parts := strings.Split(name, "/")
if len(parts) == 2 {
return parts[0], parts[1], string(verifyif.ArtifactTypeContainer), nil
} else if len(parts) == 1 {
return "", parts[0], string(verifyif.ArtifactTypeContainer), nil
index := strings.Index(name, "/")
if index == -1 {
// No slash found, treat the entire name as the artifact name
return "", name, string(verifyif.ArtifactTypeContainer), nil
}

return "", "", "", fmt.Errorf("invalid name format")
owner := name[:index]
artifactName := name[index+1:]

if owner == "" || artifactName == "" {
return "", "", "", fmt.Errorf("invalid name format")
}

return owner, artifactName, string(verifyif.ArtifactTypeContainer), nil
}

func getArtifactWrapper(
Expand All @@ -126,7 +132,6 @@ func getArtifactWrapper(
if err != nil {
return nil, fmt.Errorf("failed to get artifact properties: %w", err)
}
fmt.Println(owner, name, pkgType)

var fetchErr error
var pkg *go_github.Package
Expand Down

0 comments on commit b496555

Please sign in to comment.