mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-24 06:28:13 +01:00
Add option to skip notification at the very first analysis of an image (#10)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
@@ -53,6 +54,23 @@ func (c *Client) Close() error {
|
||||
return c.DB.Close()
|
||||
}
|
||||
|
||||
// First checks if a Docker image has ever been analyzed
|
||||
func (c *Client) First(image registry.Image) (bool, error) {
|
||||
found := false
|
||||
|
||||
err := c.View(func(tx *bolt.Tx) error {
|
||||
c := tx.Bucket([]byte(bucket)).Cursor()
|
||||
name := []byte(image.Name())
|
||||
for k, _ := c.Seek(name); k != nil && bytes.HasPrefix(k, name); k, _ = c.Next() {
|
||||
found = true
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
return !found, err
|
||||
}
|
||||
|
||||
// GetManifest returns Docker image manifest
|
||||
func (c *Client) GetManifest(image registry.Image) (docker.Manifest, error) {
|
||||
var manifest docker.Manifest
|
||||
|
||||
Reference in New Issue
Block a user