lxd/db/images.go
func (c *Cluster) ImagesGet(project string, public bool) ([]string, error) {
	err := c.Transaction(func(tx *ClusterTx) error {
		enabled, err := tx.ProjectHasImages(project)
		if err != nil {
			return errors.Wrap(err, "Check if project has images")
		}
		if !enabled {
			project = "default"
		}
		return nil
	})
	if err != nil {
		return nil, err
	}

	q := `
SELECT fingerprint
  FROM images
  JOIN projects ON projects.id = images.project_id
 WHERE projects.name = ?
`
	if public == true {
		q += " AND public=1"
	}

	var fp string
	inargs := []interface{}{project}
	outfmt := []interface{}{fp}
	dbResults, err := queryScan(c.db, q, inargs, outfmt)
	if err != nil {
		return []string{}, err
	}

	results := []string{}
	for _, r := range dbResults {
		results = append(results, r[0].(string))
	}

	return results, nil
}
func (c *Cluster) ImagesGet(project string, public bool) ([]string, error) {
	err := c.Transaction(func(tx *ClusterTx) error {
		enabled, err := tx.ProjectHasImages(project)
		if err != nil {
			return errors.Wrap(err, "Check if project has images")
		}
		if !enabled {
			project = "default"
		}
		return nil
	})
	if err != nil {
		return nil, err
	}

	q := `
SELECT fingerprint
  FROM images
  JOIN projects ON projects.id = images.project_id
 WHERE projects.name = ?
`
	if public == true {
		q += " AND public=1"
	}

	var fp string
	inargs := []interface{}{project}
	outfmt := []interface{}{fp}
	dbResults, err := queryScan(c.db, q, inargs, outfmt)
	if err != nil {
		return []string{}, err
	}

	results := []string{}
	for _, r := range dbResults {
		results = append(results, r[0].(string))
	}

	return results, nil
}
func ( c * Cluster ) ImagesGet ( project string , public bool ) ( [ ] string , error ) { err := c . Transaction ( func ( tx * ClusterTx ) error { enabled , err := tx . ProjectHasImages ( project ) if err != nil { return errors . Wrap ( err , " " ) } if ! enabled { project = " " } return nil } ) if err != nil { return nil , err } q := `
SELECT fingerprint
  FROM images
  JOIN projects ON projects.id = images.project_id
 WHERE projects.name = ?
` if public == true { q += " " } var fp string inargs := [ ] interface { } { project } outfmt := [ ] interface { } { fp } dbResults , err := queryScan ( c . db , q , inargs , outfmt ) if err != nil { return [ ] string { } , err } results := [ ] string { } for _ , r := range dbResults { results = append ( results , r [ 0 ] . ( string ) ) } return results , nil }
// ImagesGet returns the names of all images (optionally only the public ones).
ImagesGet returns the names of all images ( optionally only the public ones ) .