Skip to content

Commit

Permalink
Use default storage namespace in local settings (#5373)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyaug authored Mar 5, 2023
1 parent 28d7267 commit 1ec065e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
6 changes: 5 additions & 1 deletion pkg/api/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1280,11 +1280,15 @@ func (c *Controller) GetStorageConfig(w http.ResponseWriter, r *http.Request) {
return
}
info := c.BlockAdapter.GetStorageNamespaceInfo()
defaultNamespacePrefix := swag.String(info.DefaultNamespacePrefix)
if c.Config.Blockstore.DefaultNamespacePrefix != nil {
defaultNamespacePrefix = c.Config.Blockstore.DefaultNamespacePrefix
}
response := StorageConfig{
BlockstoreType: c.Config.BlockstoreType(),
BlockstoreNamespaceValidityRegex: info.ValidityRegex,
BlockstoreNamespaceExample: info.Example,
DefaultNamespacePrefix: swag.String(c.Config.Blockstore.DefaultNamespacePrefix),
DefaultNamespacePrefix: defaultNamespacePrefix,
PreSignSupport: info.PreSignSupport,
ImportSupport: info.ImportSupport,
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/block/local/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ type Adapter struct {
importEnabled bool
}

const (
DefaultNamespacePrefix = "local:/"
)

var (
ErrPathNotWritable = errors.New("path provided is not writable")
ErrInventoryNotSupported = errors.New("inventory feature not implemented for local storage adapter")
Expand Down Expand Up @@ -480,6 +484,7 @@ func (l *Adapter) BlockstoreType() string {
func (l *Adapter) GetStorageNamespaceInfo() block.StorageNamespaceInfo {
info := block.DefaultStorageNamespaceInfo(block.BlockstoreTypeLocal)
info.PreSignSupport = false
info.DefaultNamespacePrefix = DefaultNamespacePrefix
info.ImportSupport = l.importEnabled
return info
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/block/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ func (s StorageType) Scheme() string {
}

type StorageNamespaceInfo struct {
ValidityRegex string // regex pattern that could be used to validate the namespace
Example string // example of a valid namespace
PreSignSupport bool
ImportSupport bool
ValidityRegex string // regex pattern that could be used to validate the namespace
Example string // example of a valid namespace
DefaultNamespacePrefix string // when a repo is created from the UI, suggest a default storage namespace under this prefix
PreSignSupport bool
ImportSupport bool
}

type QualifiedKey struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ type Config struct {
} `mapstructure:"ui_config"`
}
Blockstore struct {
Type string `mapstructure:"type" validate:"required"`
DefaultNamespacePrefix string `mapstructure:"default_namespace_prefix"`
Type string `mapstructure:"type" validate:"required"`
DefaultNamespacePrefix *string `mapstructure:"default_namespace_prefix"`
Local *struct {
Path string `mapstructure:"path"`
ImportEnabled bool `mapstructure:"import_enabled"`
Expand Down

0 comments on commit 1ec065e

Please sign in to comment.