mirror of
https://github.com/anchore/syft.git
synced 2025-11-18 08:53:15 +01:00
rename Identity() to ID()
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
parent
52adfcbd44
commit
1537e73083
@ -71,7 +71,7 @@ func toPackageModel(p pkg.Package) model.Package {
|
|||||||
|
|
||||||
return model.Package{
|
return model.Package{
|
||||||
PackageBasicData: model.PackageBasicData{
|
PackageBasicData: model.PackageBasicData{
|
||||||
ID: string(p.Identity()),
|
ID: string(p.ID()),
|
||||||
Name: p.Name,
|
Name: p.Name,
|
||||||
Version: p.Version,
|
Version: p.Version,
|
||||||
Type: p.Type,
|
Type: p.Type,
|
||||||
@ -93,8 +93,8 @@ func toRelationshipModel(relationships []artifact.Relationship) []model.Relation
|
|||||||
result := make([]model.Relationship, len(relationships))
|
result := make([]model.Relationship, len(relationships))
|
||||||
for i, r := range relationships {
|
for i, r := range relationships {
|
||||||
result[i] = model.Relationship{
|
result[i] = model.Relationship{
|
||||||
Parent: string(r.From.Identity()),
|
Parent: string(r.From.ID()),
|
||||||
Child: string(r.To.Identity()),
|
Child: string(r.To.ID()),
|
||||||
Type: string(r.Type),
|
Type: string(r.Type),
|
||||||
Metadata: r.Data,
|
Metadata: r.Data,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,5 +4,5 @@ package artifact
|
|||||||
type ID string
|
type ID string
|
||||||
|
|
||||||
type Identifiable interface {
|
type Identifiable interface {
|
||||||
Identity() ID
|
ID() ID
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,7 +76,7 @@ func (c *Catalog) Add(p Package) {
|
|||||||
defer c.lock.Unlock()
|
defer c.lock.Unlock()
|
||||||
|
|
||||||
// note: since we are capturing the ID, we cannot modify the package being added from this point forward
|
// note: since we are capturing the ID, we cannot modify the package being added from this point forward
|
||||||
id := p.Identity()
|
id := p.ID()
|
||||||
|
|
||||||
// store by package ID
|
// store by package ID
|
||||||
c.byID[id] = p
|
c.byID[id] = p
|
||||||
|
|||||||
@ -45,7 +45,7 @@ type expectedIndexes struct {
|
|||||||
func TestCatalogAddPopulatesIndex(t *testing.T) {
|
func TestCatalogAddPopulatesIndex(t *testing.T) {
|
||||||
|
|
||||||
fixtureID := func(i int) string {
|
fixtureID := func(i int) string {
|
||||||
return string(catalogAddAndRemoveTestPkgs[i].Identity())
|
return string(catalogAddAndRemoveTestPkgs[i].ID())
|
||||||
}
|
}
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
@ -91,7 +91,7 @@ func assertIndexes(t *testing.T, c *Catalog, expectedIndexes expectedIndexes) {
|
|||||||
for path, expectedIds := range expectedIndexes.byPath {
|
for path, expectedIds := range expectedIndexes.byPath {
|
||||||
actualIds := strset.New()
|
actualIds := strset.New()
|
||||||
for _, p := range c.PackagesByPath(path) {
|
for _, p := range c.PackagesByPath(path) {
|
||||||
actualIds.Add(string(p.Identity()))
|
actualIds.Add(string(p.ID()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if !expectedIds.IsEqual(actualIds) {
|
if !expectedIds.IsEqual(actualIds) {
|
||||||
@ -106,7 +106,7 @@ func assertIndexes(t *testing.T, c *Catalog, expectedIndexes expectedIndexes) {
|
|||||||
for ty, expectedIds := range expectedIndexes.byType {
|
for ty, expectedIds := range expectedIndexes.byType {
|
||||||
actualIds := strset.New()
|
actualIds := strset.New()
|
||||||
for p := range c.Enumerate(ty) {
|
for p := range c.Enumerate(ty) {
|
||||||
actualIds.Add(string(p.Identity()))
|
actualIds.Add(string(p.ID()))
|
||||||
}
|
}
|
||||||
|
|
||||||
if !expectedIds.IsEqual(actualIds) {
|
if !expectedIds.IsEqual(actualIds) {
|
||||||
|
|||||||
@ -51,7 +51,7 @@ func findOwnershipByFilesRelationships(catalog *Catalog) map[artifact.ID]map[art
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, candidateOwnerPkg := range catalog.Sorted() {
|
for _, candidateOwnerPkg := range catalog.Sorted() {
|
||||||
id := candidateOwnerPkg.Identity()
|
id := candidateOwnerPkg.ID()
|
||||||
if candidateOwnerPkg.Metadata == nil {
|
if candidateOwnerPkg.Metadata == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ func findOwnershipByFilesRelationships(catalog *Catalog) map[artifact.ID]map[art
|
|||||||
|
|
||||||
// look for package(s) in the catalog that may be owned by this package and mark the relationship
|
// look for package(s) in the catalog that may be owned by this package and mark the relationship
|
||||||
for _, subPackage := range catalog.PackagesByPath(ownedFilePath) {
|
for _, subPackage := range catalog.PackagesByPath(ownedFilePath) {
|
||||||
subID := subPackage.Identity()
|
subID := subPackage.ID()
|
||||||
if subID == id {
|
if subID == id {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@ -172,8 +172,8 @@ func TestOwnershipByFilesRelationship(t *testing.T) {
|
|||||||
assert.Len(t, relationships, len(expectedRelations))
|
assert.Len(t, relationships, len(expectedRelations))
|
||||||
for idx, expectedRelationship := range expectedRelations {
|
for idx, expectedRelationship := range expectedRelations {
|
||||||
actualRelationship := relationships[idx]
|
actualRelationship := relationships[idx]
|
||||||
assert.Equal(t, expectedRelationship.From.Identity(), actualRelationship.From.Identity())
|
assert.Equal(t, expectedRelationship.From.ID(), actualRelationship.From.ID())
|
||||||
assert.Equal(t, expectedRelationship.To.Identity(), actualRelationship.To.Identity())
|
assert.Equal(t, expectedRelationship.To.ID(), actualRelationship.To.ID())
|
||||||
assert.Equal(t, expectedRelationship.Type, actualRelationship.Type)
|
assert.Equal(t, expectedRelationship.Type, actualRelationship.Type)
|
||||||
assert.Equal(t, expectedRelationship.Data, actualRelationship.Data)
|
assert.Equal(t, expectedRelationship.Data, actualRelationship.Data)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,7 @@ type Package struct {
|
|||||||
Metadata interface{} // additional data found while parsing the package source
|
Metadata interface{} // additional data found while parsing the package source
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Package) Identity() artifact.ID {
|
func (p Package) ID() artifact.ID {
|
||||||
f, err := p.Fingerprint()
|
f, err := p.Fingerprint()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: what to do in this case?
|
// TODO: what to do in this case?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user