Skip to content

Commit

Permalink
Rename user to identity
Browse files Browse the repository at this point in the history
  • Loading branch information
kian99 committed Jan 17, 2024
1 parent 4f4d9e8 commit ac99084
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions internal/jimmtest/jimm_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type JIMM struct {
GrantModelAccess_ func(ctx context.Context, user *openfga.User, mt names.ModelTag, ut names.UserTag, access jujuparams.UserAccessPermission) error
GrantOfferAccess_ func(ctx context.Context, u *openfga.User, offerURL string, ut names.UserTag, access jujuparams.OfferAccessPermission) error
ImportModel_ func(ctx context.Context, user *openfga.User, controllerName string, modelTag names.ModelTag, newOwner string) error
IdentityModelDefaults_ func(ctx context.Context, user *dbmodel.Identity) (map[string]interface{}, error)
InitiateMigration_ func(ctx context.Context, user *openfga.User, spec jujuparams.MigrationSpec, targetControllerID uint) (jujuparams.InitiateMigrationResult, error)
InitiateInternalMigration_ func(ctx context.Context, user *openfga.User, modelTag names.ModelTag, targetController string) (jujuparams.InitiateMigrationResult, error)
ListApplicationOffers_ func(ctx context.Context, user *openfga.User, filters ...jujuparams.OfferFilter) ([]jujuparams.ApplicationOfferAdminDetails, error)
Expand All @@ -88,14 +89,13 @@ type JIMM struct {
SetControllerConfig_ func(ctx context.Context, u *openfga.User, args jujuparams.ControllerConfigSet) error
SetControllerDeprecated_ func(ctx context.Context, user *openfga.User, controllerName string, deprecated bool) error
SetModelDefaults_ func(ctx context.Context, user *dbmodel.Identity, cloudTag names.CloudTag, region string, configs map[string]interface{}) error
SetUserModelDefaults_ func(ctx context.Context, user *dbmodel.Identity, configs map[string]interface{}) error
SetIdentityModelDefaults_ func(ctx context.Context, user *dbmodel.Identity, configs map[string]interface{}) error
UnsetModelDefaults_ func(ctx context.Context, user *dbmodel.Identity, cloudTag names.CloudTag, region string, keys []string) error
UpdateApplicationOffer_ func(ctx context.Context, controller *dbmodel.Controller, offerUUID string, removed bool) error
UpdateCloud_ func(ctx context.Context, u *openfga.User, ct names.CloudTag, cloud jujuparams.Cloud) error
UpdateCloudCredential_ func(ctx context.Context, u *openfga.User, args jimm.UpdateCloudCredentialArgs) ([]jujuparams.UpdateCredentialModelResult, error)
UpdateMigratedModel_ func(ctx context.Context, user *openfga.User, modelTag names.ModelTag, targetControllerName string) error
UpdateServiceAccountCredentials_ func()
UserModelDefaults_ func(ctx context.Context, user *dbmodel.Identity) (map[string]interface{}, error)
ValidateModelUpgrade_ func(ctx context.Context, u *openfga.User, mt names.ModelTag, force bool) error
WatchAllModelSummaries_ func(ctx context.Context, controller *dbmodel.Controller) (_ func() error, err error)
}
Expand Down Expand Up @@ -474,11 +474,11 @@ func (j *JIMM) SetModelDefaults(ctx context.Context, user *dbmodel.Identity, clo
}
return j.SetModelDefaults_(ctx, user, cloudTag, region, configs)
}
func (j *JIMM) SetUserModelDefaults(ctx context.Context, user *dbmodel.Identity, configs map[string]interface{}) error {
if j.SetUserModelDefaults_ == nil {
func (j *JIMM) SetIdentityModelDefaults(ctx context.Context, user *dbmodel.Identity, configs map[string]interface{}) error {
if j.SetIdentityModelDefaults_ == nil {
return errors.E(errors.CodeNotImplemented)
}
return j.SetUserModelDefaults_(ctx, user, configs)
return j.SetIdentityModelDefaults_(ctx, user, configs)
}
func (j *JIMM) UnsetModelDefaults(ctx context.Context, user *dbmodel.Identity, cloudTag names.CloudTag, region string, keys []string) error {
if j.UnsetModelDefaults_ == nil {
Expand Down Expand Up @@ -510,11 +510,11 @@ func (j *JIMM) UpdateMigratedModel(ctx context.Context, user *openfga.User, mode
}
return j.UpdateMigratedModel_(ctx, user, modelTag, targetControllerName)
}
func (j *JIMM) UserModelDefaults(ctx context.Context, user *dbmodel.Identity) (map[string]interface{}, error) {
if j.UserModelDefaults_ == nil {
func (j *JIMM) IdentityModelDefaults(ctx context.Context, user *dbmodel.Identity) (map[string]interface{}, error) {
if j.IdentityModelDefaults_ == nil {
return nil, errors.E(errors.CodeNotImplemented)
}
return j.UserModelDefaults_(ctx, user)
return j.IdentityModelDefaults_(ctx, user)
}
func (j *JIMM) ValidateModelUpgrade(ctx context.Context, u *openfga.User, mt names.ModelTag, force bool) error {
if j.ValidateModelUpgrade_ == nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/jujuapi/service_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ func (r *controllerRoot) UpdateServiceAccountCredentials(ctx context.Context, re
return jujuparams.UpdateCredentialResults{}, errors.E(op, errors.CodeUnauthorized, "unauthorized")
}

var targetUserModel dbmodel.User
var targetUserModel dbmodel.Identity
targetUserModel.SetTag(names.NewUserTag(req.ClientID))
if err := r.jimm.DB().GetUser(ctx, &targetUserModel); err != nil {
if err := r.jimm.DB().GetIdentity(ctx, &targetUserModel); err != nil {
return jujuparams.UpdateCredentialResults{}, errors.E(op, err)
}
targetUser := openfga.NewUser(&targetUserModel, r.jimm.AuthorizationClient())
Expand Down
2 changes: 1 addition & 1 deletion internal/jujuapi/service_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func TestUpdateServiceAccountCredentials(t *testing.T) {
UpdateCloudCredential_: test.updateCloudCredential,
DB_: func() *db.Database { return &pgDb },
}
var u dbmodel.User
var u dbmodel.Identity
u.SetTag(names.NewUserTag(test.username))
user := openfga.NewUser(&u, ofgaClient)
cr := jujuapi.NewControllerRoot(jimm, jujuapi.Params{})
Expand Down

0 comments on commit ac99084

Please sign in to comment.