From ac99084db2d5fe2c6df7935b39508647d4c9318c Mon Sep 17 00:00:00 2001 From: Kian Parvin Date: Wed, 17 Jan 2024 09:15:27 -0800 Subject: [PATCH] Rename user to identity --- internal/jimmtest/jimm_mock.go | 16 ++++++++-------- internal/jujuapi/service_account.go | 4 ++-- internal/jujuapi/service_account_test.go | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/jimmtest/jimm_mock.go b/internal/jimmtest/jimm_mock.go index 19b91ef2c..f5587c0d9 100644 --- a/internal/jimmtest/jimm_mock.go +++ b/internal/jimmtest/jimm_mock.go @@ -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) @@ -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) } @@ -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 { @@ -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 { diff --git a/internal/jujuapi/service_account.go b/internal/jujuapi/service_account.go index d36b53e28..e9ecc1b6c 100644 --- a/internal/jujuapi/service_account.go +++ b/internal/jujuapi/service_account.go @@ -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()) diff --git a/internal/jujuapi/service_account_test.go b/internal/jujuapi/service_account_test.go index 6f7abc97e..e9bd1b339 100644 --- a/internal/jujuapi/service_account_test.go +++ b/internal/jujuapi/service_account_test.go @@ -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{})