[lxc-devel] [lxd/master] lxd/db: Add missing query
randombenj on Github
lxc-bot at linuxcontainers.org
Mon Jun 22 15:27:57 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 312 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200622/1d3452e9/attachment.bin>
-------------- next part --------------
From 7811fc0b5bc6d87253521639cdf991ee305d9db6 Mon Sep 17 00:00:00 2001
From: Benj Fassbind <randombenj at gmail.com>
Date: Mon, 22 Jun 2020 17:23:06 +0200
Subject: [PATCH] lxd/db: Add missing query
Signed-off-by: Benj Fassbind <randombenj at gmail.com>
---
lxd/db/images.mapper.go | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/lxd/db/images.mapper.go b/lxd/db/images.mapper.go
index 8eb456837d..02b35847ca 100644
--- a/lxd/db/images.mapper.go
+++ b/lxd/db/images.mapper.go
@@ -27,6 +27,12 @@ SELECT images.id, projects.name AS project, images.fingerprint, images.type, ima
WHERE project = ? ORDER BY projects.id, images.fingerprint
`)
+var imageObjectsByProjectAndFingerprintAndPublic = cluster.RegisterStmt(`
+SELECT images.id, projects.name AS project, images.fingerprint, images.type, images.filename, images.size, images.public, images.architecture, images.creation_date, images.expiry_date, images.upload_date, images.cached, images.last_use_date, images.auto_update
+ FROM images JOIN projects ON images.project_id = projects.id
+ WHERE project = ? AND images.fingerprint LIKE ? AND images.public = ? ORDER BY projects.id, images.fingerprint
+`)
+
var imageObjectsByProjectAndPublic = cluster.RegisterStmt(`
SELECT images.id, projects.name AS project, images.fingerprint, images.type, images.filename, images.size, images.public, images.architecture, images.creation_date, images.expiry_date, images.upload_date, images.cached, images.last_use_date, images.auto_update
FROM images JOIN projects ON images.project_id = projects.id
@@ -75,7 +81,14 @@ func (c *ClusterTx) GetImages(filter ImageFilter) ([]Image, error) {
var stmt *sql.Stmt
var args []interface{}
- if criteria["Project"] != nil && criteria["Public"] != nil {
+ if criteria["Project"] != nil && criteria["Public"] != nil && criteria["Fingerprint"] != nil {
+ stmt = c.stmt(imageObjectsByProjectAndFingerprintAndPublic)
+ args = []interface{}{
+ filter.Project,
+ filter.Fingerprint,
+ filter.Public,
+ }
+ } else if criteria["Project"] != nil && criteria["Public"] != nil {
stmt = c.stmt(imageObjectsByProjectAndPublic)
args = []interface{}{
filter.Project,
More information about the lxc-devel
mailing list