mirror of
https://github.com/lxc/incus
synced 2026-08-02 05:26:46 +00:00
incusd/db/cluster: Add referenced profile query helpers
Signed-off-by: Stéphane Graber <stgraber@stgraber.org> Sponsored-by: https://webdock.io
This commit is contained in:
parent
8d761ba9f9
commit
25706fb75c
@ -172,3 +172,23 @@ func GetAllProfileConfigs(ctx context.Context, tx *sql.Tx) (map[int]map[string]s
|
||||
func GetAllProfileDevices(ctx context.Context, tx *sql.Tx) (map[int][]Device, error) {
|
||||
return GetDevices(ctx, tx, "profiles", "profile")
|
||||
}
|
||||
|
||||
// GetReferencedProfileConfigs returns a map of the given profiles' configurations, keyed by database ID.
|
||||
func GetReferencedProfileConfigs(ctx context.Context, tx *sql.Tx, profiles []Profile) (map[int]map[string]string, error) {
|
||||
profileIDs := make([]int, 0, len(profiles))
|
||||
for _, profile := range profiles {
|
||||
profileIDs = append(profileIDs, profile.ID)
|
||||
}
|
||||
|
||||
return GetConfig(ctx, tx, "profiles", "profile", ConfigFilter{ReferenceID: profileIDs})
|
||||
}
|
||||
|
||||
// GetReferencedProfileDevices returns a map of the given profiles' devices, keyed by database ID.
|
||||
func GetReferencedProfileDevices(ctx context.Context, tx *sql.Tx, profiles []Profile) (map[int][]Device, error) {
|
||||
profileIDs := make([]int, 0, len(profiles))
|
||||
for _, profile := range profiles {
|
||||
profileIDs = append(profileIDs, profile.ID)
|
||||
}
|
||||
|
||||
return GetDevices(ctx, tx, "profiles", "profile", DeviceFilter{ReferenceID: profileIDs})
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user