github.com/quay/claircore@v1.5.28/test/postgres/repository.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 InsertRepositories(ctx context.Context, pool *pgxpool.Pool, repos []*claircore.Repository) error { 13 for _, repo := range repos { 14 _, err := pool.Exec(ctx, `INSERT INTO repo 15 (id, name, key, uri) 16 VALUES 17 ($1, $2, $3, $4);`, 18 &repo.ID, &repo.Name, &repo.Key, &repo.URI) 19 if err != nil { 20 return fmt.Errorf("failed to insert test repository %v: %v", repo, err) 21 } 22 } 23 return nil 24 }