Skip to content

Commit

Permalink
incusd/cluster/profiles: Fix import shadowing
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
Sponsored-by: https://webdock.io
  • Loading branch information
stgraber committed Oct 17, 2024
1 parent 8f46ded commit 8261a78
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions internal/server/db/cluster/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,28 @@ type ProfileFilter struct {
func (p *Profile) ToAPI(ctx context.Context, tx *sql.Tx, profileConfigs map[int]map[string]string, profileDevices map[int][]Device) (*api.Profile, error) {
var err error

var config map[string]string
var dbConfig map[string]string
if profileConfigs != nil {
config = profileConfigs[p.ID]
if config == nil {
config = map[string]string{}
dbConfig = profileConfigs[p.ID]
if dbConfig == nil {
dbConfig = map[string]string{}
}
} else {
config, err = GetProfileConfig(ctx, tx, p.ID)
dbConfig, err = GetProfileConfig(ctx, tx, p.ID)
if err != nil {
return nil, err
}
}

var devices map[string]Device
var dbDevices map[string]Device
if profileDevices != nil {
devices = map[string]Device{}
dbDevices = map[string]Device{}

for _, dev := range profileDevices[p.ID] {
devices[dev.Name] = dev
dbDevices[dev.Name] = dev
}
} else {
devices, err = GetProfileDevices(ctx, tx, p.ID)
dbDevices, err = GetProfileDevices(ctx, tx, p.ID)
if err != nil {
return nil, err
}
Expand All @@ -86,8 +86,8 @@ func (p *Profile) ToAPI(ctx context.Context, tx *sql.Tx, profileConfigs map[int]
Name: p.Name,
ProfilePut: api.ProfilePut{
Description: p.Description,
Config: config,
Devices: DevicesToAPI(devices),
Config: dbConfig,
Devices: DevicesToAPI(dbDevices),
},
Project: p.Project,
}
Expand Down

0 comments on commit 8261a78

Please sign in to comment.