func manifestScanned(ctx context.Context, db *sqlx.DB, hash claircore.Digest, scnrs indexer.VersionedScanners) (bool, error) {
	const (
		selectScanner = `
		SELECT id
		FROM scanner
		WHERE name = $1
		  AND version = $2
		  AND kind = $3;
		`
		selectScanned = `
		SELECT scanner_id
		FROM scanned_manifest
				 JOIN manifest ON scanned_manifest.manifest_id = manifest.id
		WHERE manifest.hash = $1;
		`
	)

	// TODO Use passed-in Context.
	// get the ids of the scanners we are testing for.
	var expectedIDs []int64
	for _, scnr := range scnrs {
		var id int64
		row := db.QueryRowx(selectScanner, scnr.Name(), scnr.Version(), scnr.Kind())
		err := row.Scan(&id)
		if err != nil {
			return false, fmt.Errorf("store:manifestScanned failed to retrieve expected scanner id for scnr %v: %v", scnr, err)
		}
		expectedIDs = append(expectedIDs, id)
	}

	// get a map of the found ids which have scanned this package
	var temp = []int64{}
	var foundIDs = map[int64]struct{}{}
	err := db.Select(&temp, selectScanned, hash)
	if err != nil {
		return false, fmt.Errorf("store:manifestScanned failed to select scanner IDs for manifest: %v", err)
	}

	// if we are unable to find any scanner ids for this manifest hash, we have
	// never scanned this manifest.
	if len(temp) == 0 {
		return false, nil
	}

	// create foundIDs map from temporary array
	for _, id := range temp {
		foundIDs[id] = struct{}{}
	}

	// compare the expectedIDs array with our foundIDs. if we get a lookup
	// miss we can say the manifest has not been scanned by all the layers provided
	for _, id := range expectedIDs {
		if _, ok := foundIDs[id]; !ok {
			return false, nil
		}
	}

	return true, nil
}
// manifestScanned determines if a manifest has been scanned by ALL the provided
// scnrs.
manifestScanned determines if a manifest has been scanned by ALL the provided
scnrs.
// manifestScanned determines if a manifest has been scanned by ALL the provided // scnrs .
func manifestScanned(ctx context.Context, db *sqlx.DB, hash claircore.Digest, scnrs indexer.VersionedScanners) (bool, error) {
	const (
		selectScanner = `
		SELECT id
		FROM scanner
		WHERE name = $1
		  AND version = $2
		  AND kind = $3;
		`
		selectScanned = `
		SELECT scanner_id
		FROM scanned_manifest
				 JOIN manifest ON scanned_manifest.manifest_id = manifest.id
		WHERE manifest.hash = $1;
		`
	)
	var expectedIDs []int64
	for _, scnr := range scnrs {
		var id int64
		row := db.QueryRowx(selectScanner, scnr.Name(), scnr.Version(), scnr.Kind())
		err := row.Scan(&id)
		if err != nil {
			return false, fmt.Errorf("store:manifestScanned failed to retrieve expected scanner id for scnr %v: %v", scnr, err)
		}
		expectedIDs = append(expectedIDs, id)
	}
	var temp = []int64{}
	var foundIDs = map[int64]struct{}{}
	err := db.Select(&temp, selectScanned, hash)
	if err != nil {
		return false, fmt.Errorf("store:manifestScanned failed to select scanner IDs for manifest: %v", err)
	}
	if len(temp) == 0 {
		return false, nil
	}
	for _, id := range temp {
		foundIDs[id] = struct{}{}
	}
	for _, id := range expectedIDs {
		if _, ok := foundIDs[id]; !ok {
			return false, nil
		}
	}
	return true, nil
}
func manifestScanned ( ctx context . Context , db * sqlx . DB , hash claircore . Digest , scnrs indexer . VersionedScanners ) ( bool , error ) { const ( selectScanner = `
		SELECT id
		FROM scanner
		WHERE name = $1
		  AND version = $2
		  AND kind = $3;
		` selectScanned = `
		SELECT scanner_id
		FROM scanned_manifest
				 JOIN manifest ON scanned_manifest.manifest_id = manifest.id
		WHERE manifest.hash = $1;
		` ) var expectedIDs [ ] int64 for _ , scnr := range scnrs { var id int64 row := db . QueryRowx ( selectScanner , scnr . Name ( ) , scnr . Version ( ) , scnr . Kind ( ) ) err := row . Scan ( & id ) if err != nil { return false , fmt . Errorf ( " " , scnr , err ) } expectedIDs = append ( expectedIDs , id ) } var temp = [ ] int64 { } var foundIDs = map [ int64 ] struct { } { } err := db . Select ( & temp , selectScanned , hash ) if err != nil { return false , fmt . Errorf ( " " , err ) } if len ( temp ) == 0 { return false , nil } for _ , id := range temp { foundIDs [ id ] = struct { } { } } for _ , id := range expectedIDs { if _ , ok := foundIDs [ id ] ; ! ok { return false , nil } } return true , nil }
manifestScanned determines if a manifest has been scanned by ALL the provided
scnrs.
manifestScanned determines if a manifest has been scanned by ALL the provided scnrs .
// TODO Use passed-in Context. // get the ids of the scanners we are testing for. // get a map of the found ids which have scanned this package // if we are unable to find any scanner ids for this manifest hash, we have // never scanned this manifest. // create foundIDs map from temporary array // compare the expectedIDs array with our foundIDs. if we get a lookup // miss we can say the manifest has not been scanned by all the layers provided