Revert "feat: modify metadata structure for providers' pull date (#1795)" (#1846)

This reverts commit 4584423321.

Signed-off-by: Arvind Somya <arvind.somya@anchore.com>
This commit is contained in:
Arvind Somya 2024-05-06 15:39:40 -04:00 committed by GitHub
parent c6bbb6ba2c
commit 88b6139c69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 51 deletions

View file

@ -18,23 +18,16 @@ const MetadataFileName = "metadata.json"
// Metadata represents the basic identifying information of a database flat file (built/version) and a way to
// verify the contents (checksum).
type Metadata struct {
Built time.Time
Version int
Checksum string
Providers []Provider
}
type Provider struct {
Name string `json:"name"`
LastSuccessfulRun time.Time `json:"lastSuccessfulRun"`
Built time.Time
Version int
Checksum string
}
// MetadataJSON is a helper struct for parsing and assembling Metadata objects to and from JSON.
type MetadataJSON struct {
Built string `json:"built"` // RFC 3339
Version int `json:"version"`
Checksum string `json:"checksum"`
Providers []Provider `json:"providers,omitempty"`
Built string `json:"built"` // RFC 3339
Version int `json:"version"`
Checksum string `json:"checksum"`
}
// ToMetadata converts a MetadataJSON object to a Metadata object.
@ -45,10 +38,9 @@ func (m MetadataJSON) ToMetadata() (Metadata, error) {
}
metadata := Metadata{
Built: build.UTC(),
Version: m.Version,
Checksum: m.Checksum,
Providers: m.Providers,
Built: build.UTC(),
Version: m.Version,
Checksum: m.Checksum,
}
return metadata, nil
@ -127,10 +119,9 @@ func (m Metadata) String() string {
// Write out a Metadata object to the given path.
func (m Metadata) Write(toPath string) error {
metadata := MetadataJSON{
Built: m.Built.UTC().Format(time.RFC3339),
Version: m.Version,
Checksum: m.Checksum,
Providers: m.Providers,
Built: m.Built.UTC().Format(time.RFC3339),
Version: m.Version,
Checksum: m.Checksum,
}
contents, err := json.MarshalIndent(&metadata, "", " ")

View file

@ -20,16 +20,6 @@ func TestMetadataParse(t *testing.T) {
Built: time.Date(2020, 06, 15, 14, 02, 36, 0, time.UTC),
Version: 2,
Checksum: "sha256:dcd6a285c839a7c65939e20c251202912f64826be68609dfc6e48df7f853ddc8",
Providers: []Provider{
{
Name: "nvd",
LastSuccessfulRun: time.Date(2020, 05, 15, 12, 02, 45, 0, time.UTC),
},
{
Name: "alpine",
LastSuccessfulRun: time.Date(2020, 05, 15, 13, 02, 55, 0, time.UTC),
},
},
},
},
{
@ -38,16 +28,6 @@ func TestMetadataParse(t *testing.T) {
Built: time.Date(2020, 06, 15, 18, 02, 36, 0, time.UTC),
Version: 2,
Checksum: "sha256:dcd6a285c839a7c65939e20c251202912f64826be68609dfc6e48df7f853ddc8",
Providers: []Provider{
{
Name: "nvd",
LastSuccessfulRun: time.Date(2020, 05, 15, 12, 02, 45, 0, time.UTC),
},
{
Name: "alpine",
LastSuccessfulRun: time.Date(2020, 05, 15, 13, 02, 55, 0, time.UTC),
},
},
},
},
{

View file

@ -3,9 +3,5 @@
"updated": "2020-06-15T14:02:36-04:00",
"last-check": "2020-06-15T14:02:36-04:00",
"version": 2,
"checksum": "sha256:dcd6a285c839a7c65939e20c251202912f64826be68609dfc6e48df7f853ddc8",
"providers": [
{"name": "nvd", "lastSuccessfulRun": "2020-05-15T12:02:45Z"},
{"name": "alpine", "lastSuccessfulRun": "2020-05-15T13:02:55Z"}
]
"checksum": "sha256:dcd6a285c839a7c65939e20c251202912f64826be68609dfc6e48df7f853ddc8"
}

View file

@ -1,9 +1,5 @@
{
"built": "2020-06-15T14:02:36Z",
"version": 2,
"checksum": "sha256:dcd6a285c839a7c65939e20c251202912f64826be68609dfc6e48df7f853ddc8",
"providers": [
{"name": "nvd", "lastSuccessfulRun": "2020-05-15T12:02:45Z"},
{"name": "alpine", "lastSuccessfulRun": "2020-05-15T13:02:55Z"}
]
"checksum": "sha256:dcd6a285c839a7c65939e20c251202912f64826be68609dfc6e48df7f853ddc8"
}