working commit
This commit is contained in:
+24
-3
@@ -209,7 +209,7 @@ func (cli *Client) DeleteFile(ctx context.Context, fileuri string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (cli *Client) ListFiles(ctx context.Context, catalogURI string) ([]descr.File, error) {
|
||||
func (cli *Client) ListFiles(ctx context.Context, catalogURI string, usePathAs terms.PathUsage) ([]descr.File, error) {
|
||||
var err error
|
||||
res := make([]descr.File, 0)
|
||||
|
||||
@@ -221,6 +221,16 @@ func (cli *Client) ListFiles(ctx context.Context, catalogURI string) ([]descr.Fi
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
// Add values
|
||||
values := url.Values{}
|
||||
if usePathAs != "" {
|
||||
values.Add("pathAs", string(usePathAs))
|
||||
}
|
||||
encodedValues := values.Encode()
|
||||
if encodedValues != "" {
|
||||
catalogURI = catalogURI + "?" + encodedValues
|
||||
}
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, catalogURI, nil)
|
||||
if err != nil {
|
||||
return res, err
|
||||
@@ -267,7 +277,7 @@ func (cli *Client) ListFiles(ctx context.Context, catalogURI string) ([]descr.Fi
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (cli *Client) ListCollections(ctx context.Context, catalogURI string) ([]string, error) {
|
||||
func (cli *Client) ListCollections(ctx context.Context, catalogURI string, usePathAs terms.PathUsage) ([]string, error) {
|
||||
var err error
|
||||
res := make([]string, 0)
|
||||
|
||||
@@ -279,6 +289,17 @@ func (cli *Client) ListCollections(ctx context.Context, catalogURI string) ([]st
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
// Add values
|
||||
values := url.Values{}
|
||||
if usePathAs != "" {
|
||||
values.Add("pathAs", string(usePathAs))
|
||||
}
|
||||
encodedValues := values.Encode()
|
||||
if encodedValues != "" {
|
||||
catalogURI = catalogURI + "?" + encodedValues
|
||||
}
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, catalogURI, nil)
|
||||
if err != nil {
|
||||
return res, err
|
||||
@@ -325,7 +346,7 @@ func (cli *Client) ListCollections(ctx context.Context, catalogURI string) ([]st
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (cli *Client) DeleteCollection(ctx context.Context, catalogURI string, usePathAs terms.PathAs, dryRun bool) ([]descr.File, error) {
|
||||
func (cli *Client) DeleteCollection(ctx context.Context, catalogURI string, usePathAs terms.PathUsage, dryRun bool) ([]descr.File, error) {
|
||||
var err error
|
||||
res := make([]descr.File, 0)
|
||||
|
||||
|
||||
+8
-10
@@ -10,12 +10,12 @@
|
||||
|
||||
package terms
|
||||
|
||||
type PathAs string
|
||||
type PathUsage string
|
||||
|
||||
const (
|
||||
AsFinePath PathAs = "asFinePath"
|
||||
AsPrefix PathAs = "asPrefix"
|
||||
AsRegexp PathAs = "asRegexp"
|
||||
AsFinePath PathUsage = "asFinePath"
|
||||
AsPrefix PathUsage = "asPrefix"
|
||||
AsRegexp PathUsage = "asRegexp"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -32,10 +32,8 @@ const (
|
||||
// Accounts, grants
|
||||
RightReadAccounts = "readAccounts" // GetAccount, ListAccounts
|
||||
RightWriteAccounts = "writeAccounts" // CreateAccount, UpdateAccount, DeleteAccount
|
||||
// Files
|
||||
RightWriteFiles = "writeFiles" // FileInfo, GetFile, ListFiles
|
||||
RightReadFiles = "readFiles" // PutFile, DeleteFile
|
||||
// Images: manifests, layers
|
||||
RightReadImages = "readImages" // ManifestInfo, GetManifest, BlobInfo, GetBlob
|
||||
RightWriteImages = "writeImages" // other opearion
|
||||
RightWriteFiles = "writeFiles" // FileInfo, GetFile, ListFiles
|
||||
RightReadFiles = "readFiles" // PutFile, DeleteFile
|
||||
RightReadImages = "readImages" // ManifestInfo, GetManifest, BlobInfo, GetBlob
|
||||
RightWriteImages = "writeImages" // other opearion
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user