diff --git a/pkg/spaces/service.go b/pkg/spaces/service.go index 9d4b75a69b54eea4c0fc58a1c17ec5130ac9e88a..2c17dbfaa22ddeff6cc5cc7f6efd6b9ff4c119b5 100644 --- a/pkg/spaces/service.go +++ b/pkg/spaces/service.go @@ -50,27 +50,24 @@ type Spaces interface { Move(ctx context.Context, spaceID, orgID string) (err error) } -func IsSpaceAvailable(ctx context.Context, spcs Spaces, spaceId string) error { - spc, err := spcs.Get(ctx, spaceId) - +func IsSpaceAvailable(ctx context.Context, svc Spaces, spaceID string) error { + sp, err := svc.Get(ctx, spaceID) if err != nil { return errors.Wrap(err, "space not available") } - - if spc.State != StateReady { - return errors.New("space not available") + if sp.State == StateReady || sp.State == StateNew { + return nil } - - return nil + return errors.New("space not available") } -func IsWriteAvailable(ctx context.Context, spcs Spaces, spaceID string) error { - sp, err := spcs.Get(ctx, spaceID) +func IsReadAvailable(ctx context.Context, svc Spaces, spaceID string) error { + sp, err := svc.Get(ctx, spaceID) if err != nil { return errors.Wrap(err, "fail to get space") } - if sp.State == StateMigration { - return errors.Errorf("space '%s' is migrating, fail to do operation", sp.ID) + if sp.State == StateReady || sp.State == StateNew || sp.State == StateMigration { + return nil } - return nil + return errors.Errorf("space '%s' is migrating, fail to do operation", sp.ID) }