github.com/quay/claircore@v1.5.28/test/postgres/distribution.go (about) 1 package postgres 2 3 import ( 4 "context" 5 "fmt" 6 7 "github.com/jackc/pgx/v4/pgxpool" 8 9 "github.com/quay/claircore" 10 ) 11 12 func InsertDistributions(ctx context.Context, pool *pgxpool.Pool, dists []*claircore.Distribution) error { 13 for _, dist := range dists { 14 _, err := pool.Exec(ctx, `INSERT INTO dist 15 (id, name, did, version, version_code_name, version_id, arch, cpe, pretty_name) 16 VALUES 17 ($1, $2, $3, $4, $5, $6, $7, $8, $9)`, 18 &dist.ID, &dist.Name, &dist.DID, &dist.Version, &dist.VersionCodeName, &dist.VersionID, &dist.Arch, &dist.CPE, &dist.PrettyName) 19 if err != nil { 20 return fmt.Errorf("failed to insert test distribution %v: %v", dist, err) 21 } 22 } 23 return nil 24 }