From ce023dd09ff513ccdd8573258e16c4571fc84157 Mon Sep 17 00:00:00 2001 From: Joseph Phillips Date: Tue, 26 Nov 2024 14:24:42 +0100 Subject: [PATCH] *** WIP. ROLL BACK. *** --- .../client/modelmanager/modelmanager.go | 20 +++++++++---------- domain/model/service/modelservice.go | 1 - 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/apiserver/facades/client/modelmanager/modelmanager.go b/apiserver/facades/client/modelmanager/modelmanager.go index cf4aa832454..7e7b98992b9 100644 --- a/apiserver/facades/client/modelmanager/modelmanager.go +++ b/apiserver/facades/client/modelmanager/modelmanager.go @@ -216,7 +216,7 @@ func (m *ModelManagerAPI) createModelNew( // we will try and apply the defaults where authorisation allows us to. defaultCloudName, _, err := m.modelService.DefaultModelCloudNameAndCredential(ctx) if errors.Is(err, modelerrors.NotFound) { - return coremodel.UUID(""), errors.New("failed to find default model cloud and credential for controller") + return "", errors.New("failed to find default model cloud and credential for controller") } var cloudTag names.CloudTag @@ -224,7 +224,7 @@ func (m *ModelManagerAPI) createModelNew( var err error cloudTag, err = names.ParseCloudTag(args.CloudTag) if err != nil { - return coremodel.UUID(""), errors.Trace(err) + return "", errors.Trace(err) } } else { cloudTag = names.NewCloudTag(defaultCloudName) @@ -233,33 +233,33 @@ func (m *ModelManagerAPI) createModelNew( err = m.authorizer.HasPermission(ctx, permission.SuperuserAccess, m.state.ControllerTag()) if err != nil && !errors.Is(err, authentication.ErrorEntityMissingPermission) { - return coremodel.UUID(""), errors.Trace(err) + return "", errors.Trace(err) } if err != nil { canAddModel, err := m.checkAddModelPermission(ctx, cloudTag.Id(), m.apiUser) if err != nil { - return coremodel.UUID(""), errors.Trace(err) + return "", errors.Trace(err) } if !canAddModel { - return coremodel.UUID(""), apiservererrors.ErrPerm + return "", apiservererrors.ErrPerm } } ownerTag, err := names.ParseUserTag(args.OwnerTag) if err != nil { - return coremodel.UUID(""), errors.Trace(err) + return "", errors.Trace(err) } // a special case of ErrPerm will happen if the user has add-model permission but is trying to // create a model for another person, which is not yet supported. if !m.isAdmin && ownerTag != m.apiUser { - return coremodel.UUID(""), errors.Annotatef(apiservererrors.ErrPerm, "%q permission does not permit creation of models for different owners", permission.AddModelAccess) + return "", errors.Annotatef(apiservererrors.ErrPerm, "%q permission does not permit creation of models for different owners", permission.AddModelAccess) } user, err := m.accessService.GetUserByName(ctx, user.NameFromTag(ownerTag)) if err != nil { // TODO handle error properly - return coremodel.UUID(""), errors.Trace(err) + return "", errors.Trace(err) } creationArgs.Owner = user.UUID @@ -268,7 +268,7 @@ func (m *ModelManagerAPI) createModelNew( var err error cloudCredentialTag, err = names.ParseCloudCredentialTag(args.CloudCredentialTag) if err != nil { - return coremodel.UUID(""), errors.Trace(err) + return "", errors.Trace(err) } creationArgs.Credential = credential.KeyFromTag(cloudCredentialTag) @@ -277,7 +277,7 @@ func (m *ModelManagerAPI) createModelNew( // Create the model in the controller database. modelID, activator, err := m.modelService.CreateModel(ctx, creationArgs) if err != nil { - return coremodel.UUID(""), errors.Annotatef(err, "failed to create model %q", modelID) + return "", errors.Annotatef(err, "failed to create model %q", modelID) } // We need to get the model domain services from the newly created model diff --git a/domain/model/service/modelservice.go b/domain/model/service/modelservice.go index 9a71701da43..edbf7d7795f 100644 --- a/domain/model/service/modelservice.go +++ b/domain/model/service/modelservice.go @@ -83,7 +83,6 @@ func (s *ModelService) CreateModel( args := model.ReadOnlyModelCreationArgs{ UUID: m.UUID, - AgentVersion: m.AgentVersion, ControllerUUID: controllerUUID, Name: m.Name, Type: m.ModelType,