-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flexible File Filtering Feature for Blobfuse Mounting (#1435)
* Implemented 1st step that is parsing of filter string given by user
- Loading branch information
1 parent
a68cace
commit 8fb1141
Showing
17 changed files
with
670 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package filter | ||
|
||
import ( | ||
"errors" | ||
"strings" | ||
|
||
"github.com/Azure/azure-storage-fuse/v2/internal" | ||
) | ||
|
||
const lenTier = len(tier) | ||
|
||
type AccessTierFilter struct { | ||
opr bool // true means equal to , false means not equal to | ||
tier string | ||
} | ||
|
||
func (filter AccessTierFilter) Apply(fileInfo *internal.ObjAttr) bool { | ||
// fmt.Println("AccessTier filter ", filter, " file name ", (*fileInfo).Name) DEBUG PRINT | ||
return (filter.opr == (filter.tier == strings.ToLower(fileInfo.Tier))) //if both are same then return true | ||
} | ||
|
||
// used for dynamic creation of AccessTierFilter | ||
func newAccessTierFilter(args ...interface{}) Filter { | ||
return AccessTierFilter{ | ||
opr: args[0].(bool), | ||
tier: args[1].(string), | ||
} | ||
} | ||
|
||
func giveAccessTierFilterObj(singleFilter *string) (Filter, error) { | ||
(*singleFilter) = strings.Map(StringConv, (*singleFilter)) //remove all spaces and make all upperCase to lowerCase | ||
sinChk := (*singleFilter)[lenTier : lenTier+1] //single char after tier (ex- tier=hot , here sinChk will be "=") | ||
doubChk := (*singleFilter)[lenTier : lenTier+2] //2 chars after tier (ex- tier != cold , here doubChk will be "!=") | ||
erro := errors.New("invalid accesstier filter, no files passed") | ||
if !((sinChk == "=") || (doubChk == "!=")) { | ||
return nil, erro | ||
} | ||
if (doubChk == "!=") && (len(*singleFilter) > lenTier+2) { | ||
value := (*singleFilter)[lenTier+2:] // len(tier) + 2 = 4 and + 2 | ||
return newAccessTierFilter(false, value), nil | ||
} else if (sinChk == "=") && (len(*singleFilter) > lenTier+1) { | ||
value := (*singleFilter)[lenTier+1:] // len(tier) + 1 = 4 and + 1 | ||
return newAccessTierFilter(true, value), nil | ||
} else { | ||
return nil, erro | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package filter | ||
|
||
import ( | ||
"errors" | ||
"strings" | ||
|
||
"github.com/Azure/azure-storage-fuse/v2/internal" | ||
) | ||
|
||
const lenTag = len(tag) | ||
|
||
type BlobTagFilter struct { | ||
key string | ||
value string | ||
} | ||
|
||
func (filter BlobTagFilter) Apply(fileInfo *internal.ObjAttr) bool { | ||
// fmt.Println("BlobTag filter ", filter, " file name ", (*fileInfo).Name) DEBUG PRINT | ||
if val, ok := fileInfo.Tags[filter.key]; ok { | ||
return (filter.value == strings.ToLower(val)) | ||
} | ||
return false | ||
} | ||
|
||
// used for dynamic creation of BlobTagFilter | ||
func newBlobTagFilter(args ...interface{}) Filter { | ||
return BlobTagFilter{ | ||
key: args[0].(string), | ||
value: args[1].(string), | ||
} | ||
} | ||
|
||
func giveBlobTagFilterObj(singleFilter *string) (Filter, error) { | ||
(*singleFilter) = strings.Map(StringConv, (*singleFilter)) //remove all spaces and make all upperCase to lowerCase | ||
sinChk := (*singleFilter)[lenTag : lenTag+1] //single char after tag (ex- tag=hot:yes , here sinChk will be "=") | ||
erro := errors.New("invalid blobtag filter, no files passed") | ||
if !(sinChk == "=") { | ||
return nil, erro | ||
} | ||
splitEq := strings.Split(*singleFilter, "=") | ||
if len(splitEq) == 2 { | ||
splitCol := strings.Split(splitEq[1], ":") | ||
if len(splitCol) == 2 { | ||
tagKey := splitCol[0] | ||
tagVal := splitCol[1] | ||
return newBlobTagFilter(tagKey, tagVal), nil | ||
} else { | ||
return nil, erro | ||
} | ||
} else { | ||
return nil, erro | ||
} | ||
} |
Oops, something went wrong.