Skip to content

Commit

Permalink
Remove no longer needed bootstrap code (#5057)
Browse files Browse the repository at this point in the history
This we moved the settings service to the metadata storage with its
own gateway and permissions service, we no longer need the hardcoded
initial replies in order to bootstrap the role assignments.

This fixes a panic in the settings service when the first request to
the service is a read request on anything else but an existing role or
assignment.
  • Loading branch information
rhafer authored Nov 15, 2022
1 parent 6b13cea commit 4971330
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions services/settings/pkg/store/metadata/bundles.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,10 @@ import (

"github.com/gofrs/uuid"
settingsmsg "github.com/owncloud/ocis/v2/protogen/gen/ocis/messages/settings/v0"
"github.com/owncloud/ocis/v2/services/settings/pkg/store/defaults"
)

// ListBundles returns all bundles in the dataPath folder that match the given type.
func (s *Store) ListBundles(bundleType settingsmsg.Bundle_Type, bundleIDs []string) ([]*settingsmsg.Bundle, error) {
// TODO: this is needed for initialization - we need to find a better way to fix this
if s.mdc == nil && len(bundleIDs) == 1 {
return defaultBundle(bundleType, bundleIDs[0]), nil
}
s.Init()
ctx := context.TODO()

Expand Down Expand Up @@ -52,9 +47,6 @@ func (s *Store) ListBundles(bundleType settingsmsg.Bundle_Type, bundleIDs []stri

// ReadBundle tries to find a bundle by the given id from the metadata service
func (s *Store) ReadBundle(bundleID string) (*settingsmsg.Bundle, error) {
if s.mdc == nil {
return defaultBundle(settingsmsg.Bundle_TYPE_ROLE, bundleID)[0], nil
}
s.Init()
ctx := context.TODO()
b, err := s.mdc.SimpleDownload(ctx, bundlePath(bundleID))
Expand Down Expand Up @@ -134,13 +126,3 @@ func (s *Store) RemoveSettingFromBundle(bundleID string, settingID string) error
func bundlePath(id string) string {
return fmt.Sprintf("%s/%s", bundleFolderLocation, id)
}

func defaultBundle(bundleType settingsmsg.Bundle_Type, bundleID string) []*settingsmsg.Bundle {
var bundles []*settingsmsg.Bundle
for _, b := range defaults.GenerateBundlesDefaultRoles() {
if b.Type == bundleType && b.Id == bundleID {
bundles = append(bundles, b)
}
}
return bundles
}

0 comments on commit 4971330

Please sign in to comment.