Skip to content
Snippets Groups Projects
Commit 9cbe930e authored by Pavel Antonov's avatar Pavel Antonov :asterisk:
Browse files

Merge branch 'feature/PRXS-2156-SpaceMigrate' into 'master'

Исправлена ошибка, при которой доступ на чтение к пространству в состоянии 'StateMigrationScheduled' был ограничен

See merge request perxis/perxis-go!238
parents 087edb39 4d1dcb56
No related branches found
Tags v0.25.0
No related merge requests found
...@@ -2,6 +2,7 @@ package spaces ...@@ -2,6 +2,7 @@ package spaces
import ( import (
"context" "context"
"slices"
"time" "time"
"git.perx.ru/perxis/perxis-go/pkg/errors" "git.perx.ru/perxis/perxis-go/pkg/errors"
...@@ -71,10 +72,10 @@ func IsSpaceAvailable(ctx context.Context, svc Spaces, spaceID string) error { ...@@ -71,10 +72,10 @@ func IsSpaceAvailable(ctx context.Context, svc Spaces, spaceID string) error {
if err != nil { if err != nil {
return errors.Wrap(err, "fail to get space") return errors.Wrap(err, "fail to get space")
} }
if sp.StateInfo == nil || sp.StateInfo != nil && (sp.StateInfo.State == StateNew || sp.StateInfo.State == StateReady) { if sp.StateInfo == nil || slices.Contains(WriteAllowedStates, sp.StateInfo.State) {
return nil return nil
} }
return ErrSpaceNotAvailable return errors.WithContext(ErrSpaceNotAvailable, "state", sp.StateInfo.State)
} }
func IsSpaceReadable(ctx context.Context, svc Spaces, spaceID string) error { func IsSpaceReadable(ctx context.Context, svc Spaces, spaceID string) error {
...@@ -82,7 +83,7 @@ func IsSpaceReadable(ctx context.Context, svc Spaces, spaceID string) error { ...@@ -82,7 +83,7 @@ func IsSpaceReadable(ctx context.Context, svc Spaces, spaceID string) error {
if err != nil { if err != nil {
return errors.Wrap(err, "fail to get space") return errors.Wrap(err, "fail to get space")
} }
if sp.StateInfo == nil || sp.StateInfo != nil && sp.StateInfo.State == StateNew || sp.StateInfo.State == StateReady || sp.StateInfo.State == StateMigration { if sp.StateInfo == nil || slices.Contains(ReadAllowedStates, sp.StateInfo.State) {
return nil return nil
} }
return errors.WithContext(ErrSpaceNotAvailable, "state", sp.StateInfo.State) return errors.WithContext(ErrSpaceNotAvailable, "state", sp.StateInfo.State)
......
...@@ -46,6 +46,20 @@ func (s State) String() string { ...@@ -46,6 +46,20 @@ func (s State) String() string {
} }
} }
var (
ReadAllowedStates = []State{
StateNew,
StateReady,
StateMigrationScheduled,
StateMigration,
}
WriteAllowedStates = []State{
StateNew,
StateReady,
}
)
type Config struct { type Config struct {
Features []string // Deprecated Возможности используемые пространством Features []string // Deprecated Возможности используемые пространством
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment