mirror of
https://github.com/passbolt/go-passbolt-cli.git
synced 2025-05-12 02:58:20 +00:00
Implement an builtin function to parse timestamps
for filter expressions
This commit is contained in:
parent
48604aefd0
commit
3d395a11ed
1 changed files with 17 additions and 1 deletions
|
@ -37,7 +37,23 @@ var celEnvOptions = []cel.EnvOption{
|
|||
cel.Variable("Password", cel.StringType),
|
||||
cel.Variable("Description", cel.StringType),
|
||||
cel.Variable("CreatedTimestamp", cel.TimestampType),
|
||||
cel.Variable("ModifiedTimestamp", cel.TimestampType)}
|
||||
cel.Variable("ModifiedTimestamp", cel.TimestampType),
|
||||
cel.Function("parseTimestamp",
|
||||
cel.Overload("parse_timestamp_string",
|
||||
[]*cel.Type{cel.StringType},
|
||||
cel.TimestampType,
|
||||
cel.UnaryBinding(func(timeStampInput ref.Val) ref.Val {
|
||||
timeStampString := fmt.Sprintf("%s", timeStampInput.Value())
|
||||
timeStamp, err := time.Parse(`2006-01-02+15:04:05`, timeStampString)
|
||||
if err != nil {
|
||||
fmt.Printf("Error while parsing timestamp: %v\n", err)
|
||||
}
|
||||
return types.Timestamp{Time: timeStamp}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
}
|
||||
|
||||
func init() {
|
||||
ResourceListCmd.Flags().Bool("favorite", false, "Resources that are marked as favorite")
|
||||
|
|
Loading…
Add table
Reference in a new issue