Skip to content
Draft

wip #473

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions crawler/crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,17 +525,11 @@ func validateFile(publisher common.Publisher, parsed publiccode.PublicCodeV0, fi
}
}

// When the publisher id is a UUID, it means that the Publisher didn't originally
// have an explicit AlternativeId, which in turn means that the Publisher
// is not an Italian Public Administration, since those are registered in
// the API with an alternativeId set to their iPA code (Italian PA code).
//
// When a publisher has an alternativeId, it takes precedence over the
// autogenerated one and it's exposed as publisher.ID.
// When a Publisher has an alternativeId, it takes precedence over the
// autogenerated UUID one and it's exposed as publisher.ID.
//
// //nolint:godox
// TODO: This is not ideal and also an Italian-specific check
// (https://github.com/italia/publiccode-crawler/issues/298)
// TODO:: What if some catalogs want to have UUIDs as alternativeIDs?
idIsUUID, _ := regexp.MatchString("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", publisher.ID)

var organisationURI string
Expand All @@ -544,12 +538,12 @@ func validateFile(publisher common.Publisher, parsed publiccode.PublicCodeV0, fi
}

if !idIsUUID && !strings.EqualFold(
strings.TrimSpace("urn:x-italian-pa:"+publisher.ID),
strings.TrimSpace(publisher.ID),
strings.TrimSpace(organisationURI),
) {
return fmt.Errorf(
"organisation is '%s', but 'urn:x-italian-pa:%s' was expected for '%s' in %s. "+
"Set organisation.uri to 'urn:x-italian-pa:%s'",
"organisation is '%s', but '%s' was expected for '%s' in %s. "+
"Set organisation.uri to '%s'",
organisationURI,
publisher.ID,
publisher.Name,
Expand Down