Skip to content

Commit

Permalink
fix permv2 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
franzmueller committed Nov 26, 2024
1 parent 2312735 commit 854ff80
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package controller

import (
"context"
"net/http"
"time"

deviceRepo "github.com/SENERGY-Platform/device-repository/lib/client"
Expand Down Expand Up @@ -68,10 +69,17 @@ func (this *Controller) Migrate() error {
return err
}
for _, importType := range importTypes {
resource, err, _ := this.permV2Client.GetResource(permV2.InternalAdminToken, PermV2Topic, importType.Id)
if err != nil {
resource, err, code := this.permV2Client.GetResource(permV2.InternalAdminToken, PermV2Topic, importType.Id)
if err != nil && code != http.StatusNotFound {
return err
}
if code == http.StatusNotFound {
resource = permV2.Resource{
ResourcePermissions: permV2.ResourcePermissions{
UserPermissions: map[string]permV2.PermissionsMap{},
},
}
}
resource.UserPermissions[importType.Owner] = permV2.PermissionsMap{
Read: true,
Write: true,
Expand Down

0 comments on commit 854ff80

Please sign in to comment.