From 1537e73083bc638e7699878f0b943ba371e53c79 Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Tue, 9 Nov 2021 17:23:48 -0500 Subject: [PATCH] rename Identity() to ID() Signed-off-by: Alex Goodman --- internal/formats/syftjson/to_format_model.go | 6 +++--- syft/artifact/id.go | 2 +- syft/pkg/catalog.go | 2 +- syft/pkg/catalog_test.go | 6 +++--- syft/pkg/ownership_by_files_relationship.go | 4 ++-- syft/pkg/ownership_by_files_relationship_test.go | 4 ++-- syft/pkg/package.go | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/internal/formats/syftjson/to_format_model.go b/internal/formats/syftjson/to_format_model.go index 5e2c4f362..8e3e12f4b 100644 --- a/internal/formats/syftjson/to_format_model.go +++ b/internal/formats/syftjson/to_format_model.go @@ -71,7 +71,7 @@ func toPackageModel(p pkg.Package) model.Package { return model.Package{ PackageBasicData: model.PackageBasicData{ - ID: string(p.Identity()), + ID: string(p.ID()), Name: p.Name, Version: p.Version, Type: p.Type, @@ -93,8 +93,8 @@ func toRelationshipModel(relationships []artifact.Relationship) []model.Relation result := make([]model.Relationship, len(relationships)) for i, r := range relationships { result[i] = model.Relationship{ - Parent: string(r.From.Identity()), - Child: string(r.To.Identity()), + Parent: string(r.From.ID()), + Child: string(r.To.ID()), Type: string(r.Type), Metadata: r.Data, } diff --git a/syft/artifact/id.go b/syft/artifact/id.go index 82b1251ed..0a4736f67 100644 --- a/syft/artifact/id.go +++ b/syft/artifact/id.go @@ -4,5 +4,5 @@ package artifact type ID string type Identifiable interface { - Identity() ID + ID() ID } diff --git a/syft/pkg/catalog.go b/syft/pkg/catalog.go index d59a0c4f8..ce3d4c7ba 100644 --- a/syft/pkg/catalog.go +++ b/syft/pkg/catalog.go @@ -76,7 +76,7 @@ func (c *Catalog) Add(p Package) { defer c.lock.Unlock() // 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 c.byID[id] = p diff --git a/syft/pkg/catalog_test.go b/syft/pkg/catalog_test.go index cd88b4a49..14ece77f1 100644 --- a/syft/pkg/catalog_test.go +++ b/syft/pkg/catalog_test.go @@ -45,7 +45,7 @@ type expectedIndexes struct { func TestCatalogAddPopulatesIndex(t *testing.T) { fixtureID := func(i int) string { - return string(catalogAddAndRemoveTestPkgs[i].Identity()) + return string(catalogAddAndRemoveTestPkgs[i].ID()) } tests := []struct { @@ -91,7 +91,7 @@ func assertIndexes(t *testing.T, c *Catalog, expectedIndexes expectedIndexes) { for path, expectedIds := range expectedIndexes.byPath { actualIds := strset.New() for _, p := range c.PackagesByPath(path) { - actualIds.Add(string(p.Identity())) + actualIds.Add(string(p.ID())) } if !expectedIds.IsEqual(actualIds) { @@ -106,7 +106,7 @@ func assertIndexes(t *testing.T, c *Catalog, expectedIndexes expectedIndexes) { for ty, expectedIds := range expectedIndexes.byType { actualIds := strset.New() for p := range c.Enumerate(ty) { - actualIds.Add(string(p.Identity())) + actualIds.Add(string(p.ID())) } if !expectedIds.IsEqual(actualIds) { diff --git a/syft/pkg/ownership_by_files_relationship.go b/syft/pkg/ownership_by_files_relationship.go index 519ae2e27..2527ae0c4 100644 --- a/syft/pkg/ownership_by_files_relationship.go +++ b/syft/pkg/ownership_by_files_relationship.go @@ -51,7 +51,7 @@ func findOwnershipByFilesRelationships(catalog *Catalog) map[artifact.ID]map[art } for _, candidateOwnerPkg := range catalog.Sorted() { - id := candidateOwnerPkg.Identity() + id := candidateOwnerPkg.ID() if candidateOwnerPkg.Metadata == nil { 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 for _, subPackage := range catalog.PackagesByPath(ownedFilePath) { - subID := subPackage.Identity() + subID := subPackage.ID() if subID == id { continue } diff --git a/syft/pkg/ownership_by_files_relationship_test.go b/syft/pkg/ownership_by_files_relationship_test.go index 20b94d551..6720d7af6 100644 --- a/syft/pkg/ownership_by_files_relationship_test.go +++ b/syft/pkg/ownership_by_files_relationship_test.go @@ -172,8 +172,8 @@ func TestOwnershipByFilesRelationship(t *testing.T) { assert.Len(t, relationships, len(expectedRelations)) for idx, expectedRelationship := range expectedRelations { actualRelationship := relationships[idx] - assert.Equal(t, expectedRelationship.From.Identity(), actualRelationship.From.Identity()) - assert.Equal(t, expectedRelationship.To.Identity(), actualRelationship.To.Identity()) + assert.Equal(t, expectedRelationship.From.ID(), actualRelationship.From.ID()) + assert.Equal(t, expectedRelationship.To.ID(), actualRelationship.To.ID()) assert.Equal(t, expectedRelationship.Type, actualRelationship.Type) assert.Equal(t, expectedRelationship.Data, actualRelationship.Data) } diff --git a/syft/pkg/package.go b/syft/pkg/package.go index 15cd04551..f9ace8697 100644 --- a/syft/pkg/package.go +++ b/syft/pkg/package.go @@ -29,7 +29,7 @@ type Package struct { 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() if err != nil { // TODO: what to do in this case?