From 4e5983dc4327a929e73fc756a954ec5079dd2337 Mon Sep 17 00:00:00 2001 From: PiMaDaum Date: Wed, 1 Feb 2023 21:16:28 +0100 Subject: [PATCH] Remove the overloaded parseTimestamp function --- resource/filter.go | 16 ---------------- resource/list.go | 4 ++-- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/resource/filter.go b/resource/filter.go index f694f59..22c2550 100644 --- a/resource/filter.go +++ b/resource/filter.go @@ -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 diff --git a/resource/list.go b/resource/list.go index 26c3387..322b80c 100644 --- a/resource/list.go +++ b/resource/list.go @@ -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")