Remove the overloaded parseTimestamp function

This commit is contained in:
PiMaDaum 2023-02-01 21:16:28 +01:00
parent e5bb6eceff
commit 4e5983dc43
2 changed files with 2 additions and 18 deletions

View file

@ -3,7 +3,6 @@ package resource
import (
"context"
"fmt"
"time"
"github.com/google/cel-go/cel"
"github.com/google/cel-go/common/types"
@ -23,21 +22,6 @@ var celEnvOptions = []cel.EnvOption{
cel.Variable("Description", cel.StringType),
cel.Variable("CreatedTimestamp", 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(time.R, timeStampString)
if err != nil {
fmt.Printf("Error while parsing timestamp: %v\n", err)
}
return types.Timestamp{Time: timeStamp}
},
),
),
),
}
// Filters the slice resources by invoke CEL program for each resource

View file

@ -31,8 +31,8 @@ func init() {
ResourceListCmd.Flags().String("filter", "",
"Define a CEl expression as filter for resources. In the expression, all available columns can be used (see -c/--column).\n"+
"See also CEl specifications under https://github.com/google/cel-spec."+
"\nExample:\n\t--filter '(Name == \"SomeName\" || matches(Name, \"RegExpr\")) && URI.startsWith(\"https://auth.\")'\n"+
"Available builtin functions:\n\tparseTimestamp(string): It parses a string to an timestamp like the layout '2006-01-02+15:04:05' (see golangs time.Parse documentation)")
"\nExamples:\n\t--filter '(Name == \"SomeName\" || matches(Name, \"RegExpr\")) && URI.startsWith(\"https://auth.\")'\n"+
"\t--filter 'Username == \"User\" && CreatedTimestamp > timestamp(\"2022-06-10T00:00:00.000-00:00\")'")
ResourceListCmd.Flags().StringP("group", "g", "", "Resources that are shared with group")
ResourceListCmd.Flags().StringArrayP("folder", "f", []string{}, "Resources that are in folder")