Skip to content

Commit

Permalink
make method not exported
Browse files Browse the repository at this point in the history
  • Loading branch information
kian99 committed Aug 28, 2024
1 parent 7cb33ed commit 1645376
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/jimm/applicationoffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (j *JIMM) Offer(ctx context.Context, user *openfga.User, offer AddApplicati
zap.String("application-offer", doc.UUID))
}

if err := j.EveryoneUser().SetApplicationOfferAccess(ctx, doc.ResourceTag(), ofganames.ReaderRelation); err != nil {
if err := j.everyoneUser().SetApplicationOfferAccess(ctx, doc.ResourceTag(), ofganames.ReaderRelation); err != nil {
zapctx.Error(
ctx,
"failed relation between user and application offer",
Expand Down
2 changes: 1 addition & 1 deletion internal/jimm/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func (j *JIMM) AddController(ctx context.Context, user *openfga.User, ctl *dbmod
// If this cloud is the one used by the controller model then
// it is available to all users. Other clouds require `juju grant-cloud` to add permissions.
if cloud.ResourceTag().String() == modelSummary.CloudTag {
if err := j.EveryoneUser().SetCloudAccess(ctx, cloud.ResourceTag(), ofganames.CanAddModelRelation); err != nil {
if err := j.everyoneUser().SetCloudAccess(ctx, cloud.ResourceTag(), ofganames.CanAddModelRelation); err != nil {
zapctx.Error(ctx, "failed to grant everyone add-model access", zap.Error(err))
}
}
Expand Down
4 changes: 4 additions & 0 deletions internal/jimm/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@ func (j *JIMM) GetUser(ctx context.Context, identifier string) (*openfga.User, e
func (j *JIMM) UpdateUserLastLogin(ctx context.Context, identifier string) error {
return j.updateUserLastLogin(ctx, identifier)
}

func (j *JIMM) EveryoneUser() *openfga.User {
return j.everyoneUser()
}
4 changes: 2 additions & 2 deletions internal/jimm/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
* Authorisation utilities
**/

// EveryoneUser is a convenience method to retrieve the "everyone" user
// everyoneUser is a convenience method to retrieve the "everyone" user
// whose permissions will translate into granting all users with access.
func (j *JIMM) EveryoneUser() *openfga.User {
func (j *JIMM) everyoneUser() *openfga.User {
everyoneIdentity := &dbmodel.Identity{Name: ofganames.EveryoneUser}
return openfga.NewUser(everyoneIdentity, j.OpenFGAClient)
}
Expand Down

0 comments on commit 1645376

Please sign in to comment.