Skip to content
Snippets Groups Projects
Commit d6fff184 authored by ko_oler's avatar ko_oler
Browse files

- изменено имя метода IsWriteAvailable на IsReadAvailable

- правки в метод IsSpaceAvailable, IsReadAvailable
parent 9880bdec
No related branches found
No related tags found
No related merge requests found
...@@ -50,27 +50,24 @@ type Spaces interface { ...@@ -50,27 +50,24 @@ type Spaces interface {
Move(ctx context.Context, spaceID, orgID string) (err error) Move(ctx context.Context, spaceID, orgID string) (err error)
} }
func IsSpaceAvailable(ctx context.Context, spcs Spaces, spaceId string) error { func IsSpaceAvailable(ctx context.Context, svc Spaces, spaceID string) error {
spc, err := spcs.Get(ctx, spaceId) sp, err := svc.Get(ctx, spaceID)
if err != nil { if err != nil {
return errors.Wrap(err, "space not available") return errors.Wrap(err, "space not available")
} }
if sp.State == StateReady || sp.State == StateNew {
if spc.State != StateReady {
return errors.New("space not available")
}
return nil return nil
} }
return errors.New("space not available")
}
func IsWriteAvailable(ctx context.Context, spcs Spaces, spaceID string) error { func IsReadAvailable(ctx context.Context, svc Spaces, spaceID string) error {
sp, err := spcs.Get(ctx, spaceID) sp, err := svc.Get(ctx, spaceID)
if err != nil { if err != nil {
return errors.Wrap(err, "fail to get space") return errors.Wrap(err, "fail to get space")
} }
if sp.State == StateMigration { if sp.State == StateReady || sp.State == StateNew || sp.State == StateMigration {
return errors.Errorf("space '%s' is migrating, fail to do operation", sp.ID)
}
return nil return nil
} }
return errors.Errorf("space '%s' is migrating, fail to do operation", sp.ID)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment