Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for more powerful filtering for the --props and --exclude-props parameters #2581

Open
PM-JoakimGustavsson opened this issue Jun 20, 2024 · 0 comments
Labels
feature request New feature or request

Comments

@PM-JoakimGustavsson
Copy link

Problem

Many of the generic file commands support the --props and --exclude-props parameters to filter the results based on the values of specific properties. These parameters are quite limited currently for the following reasons:

  • --props supports wildcards in the form of *, however --exclude-props yields an error when passing a wildcard.
joagus@PML220657-L0 ~ $ jf rt s "dreg-backup-docker-local/**/manifest.json" --exclude-props "retention_policy=*"
15:33:20 [🔵Info] Searching artifacts...
15:33:20 [🔵Info] Trace ID for JFrog Platform logs: 0e70d0e27e9e2e03
15:33:20 [🚨Error] server response: 400
Failed to parse query: items.find({"$or":[{"@retention_policy":{"$ne":{"$match":"*"}}}],"path":{"$ne":"."},"$or":[{"$and":[{"repo":"dreg-backup-docker-local","path":{"$match":"**"},"name":"manifest.json"}]}]}).include("name","repo","path","actual_md5","actual_sha1","sha256","size","type","modified","created","property"), it looks like there is syntax error near the following sub-query: {"$match":"*"}}}],"path":{"$ne":"."},"$or":[{"$and":[{"repo":"dreg-backup-docker-local","path":{"$match":"**"},"name":"manifest.json"}]}]}).include("name","repo","path","actual_md5","actual_sha1","sha256","size","type","modified","created","property")

In this case the wildcard would be to indicate any artifact that has this property set to any value, in other words that the property exists on the given artifact.

  • Neither --props nor --exclude-props support logical operators. In fact the documentation explicitly states that "Only artifacts without all of the specified properties names and values will be affected". For our use-case we have a parameter called retention_policy, which provides a hint to our cleaning batch job how long the artifact should be saved before being deleted. This property can have several different values, such as 1month, 1year etc. We only allow certain policies in certain repos, and because of this we have a batch job that tries to identify artifacts where the retention policy is not set to e.g 1week OR 6months OR 1year. Currently we have to solve this by making several queries, merging the results, and then subtracting that from the full list of artifacts for that given repo.

Solution we would like to see

Extend the capability of the --props and --exclude-props to both allow for wildcards, but also to allow for more complex logic in the matchings. An example might be to allow the user to specify prop=a|prop=b to signify a logical OR operation.

Alternatives we have considered

Making seperate queries and taking the union or intersection of the results by passing the results to the jq tool.

@PM-JoakimGustavsson PM-JoakimGustavsson added the feature request New feature or request label Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant