Skip to content

Commit

Permalink
Fix: UI ADLS import validity regex (#6509)
Browse files Browse the repository at this point in the history
* Fix: UI ADLS import validity regex

* Fix: UI ADLS import validity regex

* Fixes 2

* Fixes 2

* Update pkg/block/azure/adapter.go

Co-authored-by: Barak Amar <[email protected]>

---------

Co-authored-by: Barak Amar <[email protected]>
  • Loading branch information
N-o-Z and nopcoder authored Aug 29, 2023
1 parent 1149f79 commit 18562f6
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 12 deletions.
3 changes: 3 additions & 0 deletions api/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,7 @@ components:
- pre_sign_support
- pre_sign_support_ui
- import_support
- import_validity_regex
properties:
blockstore_type:
type: string
Expand All @@ -1042,6 +1043,8 @@ components:
type: boolean
import_support:
type: boolean
import_validity_regex:
type: string

VersionConfig:
type: object
Expand Down
4 changes: 4 additions & 0 deletions clients/java/api/openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions clients/java/docs/StorageConfig.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions clients/python/docs/StorageConfig.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions clients/python/lakefs_client/model/storage_config.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/assets/js/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,7 @@ components:
- pre_sign_support
- pre_sign_support_ui
- import_support
- import_validity_regex
properties:
blockstore_type:
type: string
Expand All @@ -1042,6 +1043,8 @@ components:
type: boolean
import_support:
type: boolean
import_validity_regex:
type: string

VersionConfig:
type: object
Expand Down
1 change: 1 addition & 0 deletions pkg/api/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,7 @@ func (c *Controller) GetStorageConfig(w http.ResponseWriter, r *http.Request) {
PreSignSupport: info.PreSignSupport,
PreSignSupportUi: info.PreSignSupportUI,
ImportSupport: info.ImportSupport,
ImportValidityRegex: info.ImportValidityRegex,
}
writeResponse(w, r, http.StatusOK, response)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/block/azure/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,8 @@ func (a *Adapter) CompleteMultiPartUpload(ctx context.Context, obj block.ObjectP

func (a *Adapter) GetStorageNamespaceInfo() block.StorageNamespaceInfo {
info := block.DefaultStorageNamespaceInfo(block.BlockstoreTypeAzure)
info.ValidityRegex = `^https?://[a-z,0-9]+\.blob\.core\.windows\.net`
info.ImportValidityRegex = `^https?://[a-z0-9_-]+\.(blob|adls)\.core\.windows\.net` // added adls for import hint validation in UI
info.ValidityRegex = `^https?://[a-z0-9_-]+\.blob\.core\.windows\.net`
info.Example = "https://mystorageaccount.blob.core.windows.net/mycontainer/"
if a.disablePreSigned {
info.PreSignSupport = false
Expand Down
10 changes: 6 additions & 4 deletions pkg/block/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type StorageNamespaceInfo struct {
PreSignSupport bool
PreSignSupportUI bool
ImportSupport bool
ImportValidityRegex string
}

type QualifiedKey interface {
Expand Down Expand Up @@ -189,9 +190,10 @@ func DefaultValidationRegex(scheme string) string {

func DefaultStorageNamespaceInfo(scheme string) StorageNamespaceInfo {
return StorageNamespaceInfo{
ValidityRegex: DefaultValidationRegex(scheme),
Example: DefaultExample(scheme),
PreSignSupport: true,
ImportSupport: true,
ValidityRegex: DefaultValidationRegex(scheme),
Example: DefaultExample(scheme),
PreSignSupport: true,
ImportSupport: true,
ImportValidityRegex: DefaultValidationRegex(scheme),
}
}
2 changes: 2 additions & 0 deletions webui/src/lib/hooks/storageConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type StorageConfigContextType = {
blockstore_type: string | null;
default_namespace_prefix: string | null;
import_support: boolean;
import_validity_regex: string | null;
pre_sign_support: boolean;
pre_sign_support_ui: boolean;
};
Expand All @@ -28,6 +29,7 @@ const storageConfigInitialState: StorageConfigContextType = {
blockstore_type: null,
default_namespace_prefix: null,
import_support: false,
import_validity_regex: null,
pre_sign_support: false,
pre_sign_support_ui: false,
};
Expand Down
6 changes: 3 additions & 3 deletions webui/src/pages/repositories/services/import_data.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ const ImportForm = ({

}) => {
const [isSourceValid, setIsSourceValid] = useState(true);
const storageNamespaceValidityRegexStr = config.blockstore_namespace_ValidityRegex;
const storageNamespaceValidityRegex = RegExp(storageNamespaceValidityRegexStr);
const importValidityRegexStr = config.import_validity_regex;
const storageNamespaceValidityRegex = RegExp(importValidityRegexStr);
const updateSourceURLValidity = () => {
if (!sourceRef.current.value) {
updateSrcValidity(true);
Expand All @@ -124,7 +124,7 @@ const ImportForm = ({
onChange={updateSourceURLValidity}/>
{isSourceValid === false &&
<Form.Text className="text-danger">
{`Import source should match the following pattern: "${storageNamespaceValidityRegexStr}"`}
{`Import source should match the following pattern: "${importValidityRegexStr}"`}
</Form.Text>
}
{isSourceValid &&
Expand Down

0 comments on commit 18562f6

Please sign in to comment.