Compare commits

..

1 Commits

Author SHA1 Message Date
Kubernetes Publisher
62e1c231c5 Fix Godeps.json to point to kubernetes-1.14.4 tags 2019-07-08 17:54:33 +00:00
7 changed files with 192 additions and 185 deletions

190
Godeps/Godeps.json generated
View File

@@ -1,7 +1,7 @@
{
"ImportPath": "k8s.io/client-go",
"GoVersion": "go1.12",
"GodepVersion": "v80-k8s-r1",
"GodepVersion": "v80",
"Packages": [
"./..."
],
@@ -192,27 +192,27 @@
},
{
"ImportPath": "golang.org/x/net/context",
"Rev": "cdfb69ac37fc6fa907650654115ebebb3aae2087"
"Rev": "65e2d4e15006aab9813ff8769e768bbf4bb667a0"
},
{
"ImportPath": "golang.org/x/net/context/ctxhttp",
"Rev": "cdfb69ac37fc6fa907650654115ebebb3aae2087"
"Rev": "65e2d4e15006aab9813ff8769e768bbf4bb667a0"
},
{
"ImportPath": "golang.org/x/net/http/httpguts",
"Rev": "cdfb69ac37fc6fa907650654115ebebb3aae2087"
"Rev": "65e2d4e15006aab9813ff8769e768bbf4bb667a0"
},
{
"ImportPath": "golang.org/x/net/http2",
"Rev": "cdfb69ac37fc6fa907650654115ebebb3aae2087"
"Rev": "65e2d4e15006aab9813ff8769e768bbf4bb667a0"
},
{
"ImportPath": "golang.org/x/net/http2/hpack",
"Rev": "cdfb69ac37fc6fa907650654115ebebb3aae2087"
"Rev": "65e2d4e15006aab9813ff8769e768bbf4bb667a0"
},
{
"ImportPath": "golang.org/x/net/idna",
"Rev": "cdfb69ac37fc6fa907650654115ebebb3aae2087"
"Rev": "65e2d4e15006aab9813ff8769e768bbf4bb667a0"
},
{
"ImportPath": "golang.org/x/oauth2",
@@ -272,355 +272,355 @@
},
{
"ImportPath": "k8s.io/api/admissionregistration/v1beta1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/apps/v1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/apps/v1beta1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/apps/v1beta2",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/auditregistration/v1alpha1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/authentication/v1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/authentication/v1beta1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/authorization/v1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/authorization/v1beta1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/autoscaling/v1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/autoscaling/v2beta1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/autoscaling/v2beta2",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/batch/v1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/batch/v1beta1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/batch/v2alpha1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/certificates/v1beta1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/coordination/v1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/coordination/v1beta1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/core/v1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/events/v1beta1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/extensions/v1beta1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/imagepolicy/v1alpha1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/networking/v1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/networking/v1beta1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/node/v1alpha1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/node/v1beta1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/policy/v1beta1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/rbac/v1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/rbac/v1alpha1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/rbac/v1beta1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/scheduling/v1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/scheduling/v1alpha1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/scheduling/v1beta1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/settings/v1alpha1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/storage/v1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/storage/v1alpha1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/api/storage/v1beta1",
"Rev": "e3a6b8045b0b303430f6d0c261fd9e35be50800e"
"Rev": "539a33f6e81741ed7bc3f69e07b4a966788723cf"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/fuzzer",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/roundtrip",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/errors",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/meta",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/resource",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/conversion",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/fields",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/labels",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/selection",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/types",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/cache",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/clock",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/diff",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/errors",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/framer",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/json",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/naming",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/net",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/sets",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/validation",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/wait",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/version",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/watch",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
"Rev": "a9f1d8a9c10182d101acf19b5145c3d4e9299adb"
"Rev": "6a84e37a896db9780c75367af8d2ed2bb944022e"
},
{
"ImportPath": "k8s.io/klog",

View File

@@ -48,7 +48,7 @@ type ExpirationCache struct {
// ExpirationPolicy dictates when an object expires. Currently only abstracted out
// so unittests don't rely on the system clock.
type ExpirationPolicy interface {
IsExpired(obj *TimestampedEntry) bool
IsExpired(obj *timestampedEntry) bool
}
// TTLPolicy implements a ttl based ExpirationPolicy.
@@ -63,29 +63,26 @@ type TTLPolicy struct {
// IsExpired returns true if the given object is older than the ttl, or it can't
// determine its age.
func (p *TTLPolicy) IsExpired(obj *TimestampedEntry) bool {
return p.Ttl > 0 && p.Clock.Since(obj.Timestamp) > p.Ttl
func (p *TTLPolicy) IsExpired(obj *timestampedEntry) bool {
return p.Ttl > 0 && p.Clock.Since(obj.timestamp) > p.Ttl
}
// TimestampedEntry is the only type allowed in a ExpirationCache.
// Keep in mind that it is not safe to share timestamps between computers.
// Behavior may be inconsistent if you get a timestamp from the API Server and
// use it on the client machine as part of your ExpirationCache.
type TimestampedEntry struct {
Obj interface{}
Timestamp time.Time
// timestampedEntry is the only type allowed in a ExpirationCache.
type timestampedEntry struct {
obj interface{}
timestamp time.Time
}
// getTimestampedEntry returns the TimestampedEntry stored under the given key.
func (c *ExpirationCache) getTimestampedEntry(key string) (*TimestampedEntry, bool) {
// getTimestampedEntry returns the timestampedEntry stored under the given key.
func (c *ExpirationCache) getTimestampedEntry(key string) (*timestampedEntry, bool) {
item, _ := c.cacheStorage.Get(key)
if tsEntry, ok := item.(*TimestampedEntry); ok {
if tsEntry, ok := item.(*timestampedEntry); ok {
return tsEntry, true
}
return nil, false
}
// getOrExpire retrieves the object from the TimestampedEntry if and only if it hasn't
// getOrExpire retrieves the object from the timestampedEntry if and only if it hasn't
// already expired. It holds a write lock across deletion.
func (c *ExpirationCache) getOrExpire(key string) (interface{}, bool) {
// Prevent all inserts from the time we deem an item as "expired" to when we
@@ -98,11 +95,11 @@ func (c *ExpirationCache) getOrExpire(key string) (interface{}, bool) {
return nil, false
}
if c.expirationPolicy.IsExpired(timestampedItem) {
klog.V(4).Infof("Entry %v: %+v has expired", key, timestampedItem.Obj)
klog.V(4).Infof("Entry %v: %+v has expired", key, timestampedItem.obj)
c.cacheStorage.Delete(key)
return nil, false
}
return timestampedItem.Obj, true
return timestampedItem.obj, true
}
// GetByKey returns the item stored under the key, or sets exists=false.
@@ -129,7 +126,7 @@ func (c *ExpirationCache) List() []interface{} {
list := make([]interface{}, 0, len(items))
for _, item := range items {
obj := item.(*TimestampedEntry).Obj
obj := item.(*timestampedEntry).obj
if key, err := c.keyFunc(obj); err != nil {
list = append(list, obj)
} else if obj, exists := c.getOrExpire(key); exists {
@@ -154,7 +151,7 @@ func (c *ExpirationCache) Add(obj interface{}) error {
c.expirationLock.Lock()
defer c.expirationLock.Unlock()
c.cacheStorage.Add(key, &TimestampedEntry{obj, c.clock.Now()})
c.cacheStorage.Add(key, &timestampedEntry{obj, c.clock.Now()})
return nil
}
@@ -187,7 +184,7 @@ func (c *ExpirationCache) Replace(list []interface{}, resourceVersion string) er
if err != nil {
return KeyError{item, err}
}
items[key] = &TimestampedEntry{item, ts}
items[key] = &timestampedEntry{item, ts}
}
c.expirationLock.Lock()
defer c.expirationLock.Unlock()
@@ -202,15 +199,10 @@ func (c *ExpirationCache) Resync() error {
// NewTTLStore creates and returns a ExpirationCache with a TTLPolicy
func NewTTLStore(keyFunc KeyFunc, ttl time.Duration) Store {
return NewExpirationStore(keyFunc, &TTLPolicy{ttl, clock.RealClock{}})
}
// NewExpirationStore creates and returns a ExpirationCache for a given policy
func NewExpirationStore(keyFunc KeyFunc, expirationPolicy ExpirationPolicy) Store {
return &ExpirationCache{
cacheStorage: NewThreadSafeStore(Indexers{}, Indices{}),
keyFunc: keyFunc,
clock: clock.RealClock{},
expirationPolicy: expirationPolicy,
expirationPolicy: &TTLPolicy{ttl, clock.RealClock{}},
}
}

View File

@@ -38,7 +38,7 @@ type FakeExpirationPolicy struct {
RetrieveKeyFunc KeyFunc
}
func (p *FakeExpirationPolicy) IsExpired(obj *TimestampedEntry) bool {
func (p *FakeExpirationPolicy) IsExpired(obj *timestampedEntry) bool {
key, _ := p.RetrieveKeyFunc(obj)
return !p.NeverExpire.Has(key)
}

View File

@@ -34,7 +34,7 @@ func TestTTLExpirationBasic(t *testing.T) {
&FakeExpirationPolicy{
NeverExpire: sets.NewString(),
RetrieveKeyFunc: func(obj interface{}) (string, error) {
return obj.(*TimestampedEntry).Obj.(testStoreObject).id, nil
return obj.(*timestampedEntry).obj.(testStoreObject).id, nil
},
},
clock.RealClock{},
@@ -67,7 +67,7 @@ func TestReAddExpiredItem(t *testing.T) {
exp := &FakeExpirationPolicy{
NeverExpire: sets.NewString(),
RetrieveKeyFunc: func(obj interface{}) (string, error) {
return obj.(*TimestampedEntry).Obj.(testStoreObject).id, nil
return obj.(*timestampedEntry).obj.(testStoreObject).id, nil
},
}
ttlStore := NewFakeExpirationStore(
@@ -130,7 +130,7 @@ func TestTTLList(t *testing.T) {
&FakeExpirationPolicy{
NeverExpire: sets.NewString(testObjs[1].id),
RetrieveKeyFunc: func(obj interface{}) (string, error) {
return obj.(*TimestampedEntry).Obj.(testStoreObject).id, nil
return obj.(*timestampedEntry).obj.(testStoreObject).id, nil
},
},
clock.RealClock{},
@@ -168,15 +168,15 @@ func TestTTLPolicy(t *testing.T) {
expiredTime := fakeTime.Add(-(ttl + 1))
policy := TTLPolicy{ttl, clock.NewFakeClock(fakeTime)}
fakeTimestampedEntry := &TimestampedEntry{Obj: struct{}{}, Timestamp: exactlyOnTTL}
fakeTimestampedEntry := &timestampedEntry{obj: struct{}{}, timestamp: exactlyOnTTL}
if policy.IsExpired(fakeTimestampedEntry) {
t.Errorf("TTL cache should not expire entries exactly on ttl")
}
fakeTimestampedEntry.Timestamp = fakeTime
fakeTimestampedEntry.timestamp = fakeTime
if policy.IsExpired(fakeTimestampedEntry) {
t.Errorf("TTL Cache should not expire entries before ttl")
}
fakeTimestampedEntry.Timestamp = expiredTime
fakeTimestampedEntry.timestamp = expiredTime
if !policy.IsExpired(fakeTimestampedEntry) {
t.Errorf("TTL Cache should expire entries older than ttl")
}

View File

@@ -153,7 +153,7 @@ func TestEventf(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "bar",
APIVersion: "v1",
APIVersion: "version",
FieldPath: "spec.containers[2]",
},
Reason: "Started",
@@ -162,7 +162,7 @@ func TestEventf(t *testing.T) {
Count: 1,
Type: v1.EventTypeNormal,
},
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectUpdate: false,
},
{
@@ -181,7 +181,7 @@ func TestEventf(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "bar",
APIVersion: "v1",
APIVersion: "version",
},
Reason: "Killed",
Message: "some other verbose message: 1",
@@ -189,7 +189,7 @@ func TestEventf(t *testing.T) {
Count: 1,
Type: v1.EventTypeNormal,
},
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1", ResourceVersion:"", FieldPath:""}): type: 'Normal' reason: 'Killed' some other verbose message: 1`,
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:""}): type: 'Normal' reason: 'Killed' some other verbose message: 1`,
expectUpdate: false,
},
{
@@ -208,7 +208,7 @@ func TestEventf(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "bar",
APIVersion: "v1",
APIVersion: "version",
FieldPath: "spec.containers[2]",
},
Reason: "Started",
@@ -217,7 +217,7 @@ func TestEventf(t *testing.T) {
Count: 2,
Type: v1.EventTypeNormal,
},
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectUpdate: true,
},
{
@@ -236,7 +236,7 @@ func TestEventf(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "differentUid",
APIVersion: "v1",
APIVersion: "version",
FieldPath: "spec.containers[3]",
},
Reason: "Started",
@@ -245,7 +245,7 @@ func TestEventf(t *testing.T) {
Count: 1,
Type: v1.EventTypeNormal,
},
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectUpdate: false,
},
{
@@ -264,7 +264,7 @@ func TestEventf(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "bar",
APIVersion: "v1",
APIVersion: "version",
FieldPath: "spec.containers[2]",
},
Reason: "Started",
@@ -273,7 +273,7 @@ func TestEventf(t *testing.T) {
Count: 3,
Type: v1.EventTypeNormal,
},
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectUpdate: true,
},
{
@@ -292,7 +292,7 @@ func TestEventf(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "differentUid",
APIVersion: "v1",
APIVersion: "version",
FieldPath: "spec.containers[3]",
},
Reason: "Stopped",
@@ -301,7 +301,7 @@ func TestEventf(t *testing.T) {
Count: 1,
Type: v1.EventTypeNormal,
},
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`,
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`,
expectUpdate: false,
},
{
@@ -320,7 +320,7 @@ func TestEventf(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "differentUid",
APIVersion: "v1",
APIVersion: "version",
FieldPath: "spec.containers[3]",
},
Reason: "Stopped",
@@ -329,7 +329,7 @@ func TestEventf(t *testing.T) {
Count: 2,
Type: v1.EventTypeNormal,
},
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`,
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`,
expectUpdate: true,
},
}
@@ -509,7 +509,7 @@ func TestLotsOfEvents(t *testing.T) {
Name: fmt.Sprintf("foo-%v", i),
Namespace: "baz",
UID: "bar",
APIVersion: "v1",
APIVersion: "version",
}
// we need to vary the reason to prevent aggregation
go recorder.Eventf(ref, v1.EventTypeNormal, "Reason-"+string(i), strconv.Itoa(i))
@@ -567,7 +567,7 @@ func TestEventfNoNamespace(t *testing.T) {
Name: "foo",
Namespace: "",
UID: "bar",
APIVersion: "v1",
APIVersion: "version",
FieldPath: "spec.containers[2]",
},
Reason: "Started",
@@ -576,7 +576,7 @@ func TestEventfNoNamespace(t *testing.T) {
Count: 1,
Type: v1.EventTypeNormal,
},
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"", Name:"foo", UID:"bar", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectUpdate: false,
},
}
@@ -677,7 +677,7 @@ func TestMultiSinkCache(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "bar",
APIVersion: "v1",
APIVersion: "version",
FieldPath: "spec.containers[2]",
},
Reason: "Started",
@@ -686,7 +686,7 @@ func TestMultiSinkCache(t *testing.T) {
Count: 1,
Type: v1.EventTypeNormal,
},
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectUpdate: false,
},
{
@@ -705,7 +705,7 @@ func TestMultiSinkCache(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "bar",
APIVersion: "v1",
APIVersion: "version",
},
Reason: "Killed",
Message: "some other verbose message: 1",
@@ -713,7 +713,7 @@ func TestMultiSinkCache(t *testing.T) {
Count: 1,
Type: v1.EventTypeNormal,
},
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1", ResourceVersion:"", FieldPath:""}): type: 'Normal' reason: 'Killed' some other verbose message: 1`,
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:""}): type: 'Normal' reason: 'Killed' some other verbose message: 1`,
expectUpdate: false,
},
{
@@ -732,7 +732,7 @@ func TestMultiSinkCache(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "bar",
APIVersion: "v1",
APIVersion: "version",
FieldPath: "spec.containers[2]",
},
Reason: "Started",
@@ -741,7 +741,7 @@ func TestMultiSinkCache(t *testing.T) {
Count: 2,
Type: v1.EventTypeNormal,
},
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectUpdate: true,
},
{
@@ -760,7 +760,7 @@ func TestMultiSinkCache(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "differentUid",
APIVersion: "v1",
APIVersion: "version",
FieldPath: "spec.containers[3]",
},
Reason: "Started",
@@ -769,7 +769,7 @@ func TestMultiSinkCache(t *testing.T) {
Count: 1,
Type: v1.EventTypeNormal,
},
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectUpdate: false,
},
{
@@ -788,7 +788,7 @@ func TestMultiSinkCache(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "bar",
APIVersion: "v1",
APIVersion: "version",
FieldPath: "spec.containers[2]",
},
Reason: "Started",
@@ -797,7 +797,7 @@ func TestMultiSinkCache(t *testing.T) {
Count: 3,
Type: v1.EventTypeNormal,
},
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"bar", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[2]"}): type: 'Normal' reason: 'Started' some verbose message: 1`,
expectUpdate: true,
},
{
@@ -816,7 +816,7 @@ func TestMultiSinkCache(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "differentUid",
APIVersion: "v1",
APIVersion: "version",
FieldPath: "spec.containers[3]",
},
Reason: "Stopped",
@@ -825,7 +825,7 @@ func TestMultiSinkCache(t *testing.T) {
Count: 1,
Type: v1.EventTypeNormal,
},
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`,
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`,
expectUpdate: false,
},
{
@@ -844,7 +844,7 @@ func TestMultiSinkCache(t *testing.T) {
Name: "foo",
Namespace: "baz",
UID: "differentUid",
APIVersion: "v1",
APIVersion: "version",
FieldPath: "spec.containers[3]",
},
Reason: "Stopped",
@@ -853,7 +853,7 @@ func TestMultiSinkCache(t *testing.T) {
Count: 2,
Type: v1.EventTypeNormal,
},
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"v1", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`,
expectLog: `Event(v1.ObjectReference{Kind:"Pod", Namespace:"baz", Name:"foo", UID:"differentUid", APIVersion:"version", ResourceVersion:"", FieldPath:"spec.containers[3]"}): type: 'Normal' reason: 'Stopped' some verbose message: 1`,
expectUpdate: true,
},
}

View File

@@ -19,6 +19,8 @@ package reference
import (
"errors"
"fmt"
"net/url"
"strings"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
@@ -28,7 +30,8 @@ import (
var (
// Errors that could be returned by GetReference.
ErrNilObject = errors.New("can't reference a nil object")
ErrNilObject = errors.New("can't reference a nil object")
ErrNoSelfLink = errors.New("selfLink was empty, can't make reference")
)
// GetReference returns an ObjectReference which refers to the given
@@ -44,6 +47,20 @@ func GetReference(scheme *runtime.Scheme, obj runtime.Object) (*v1.ObjectReferen
return ref, nil
}
gvk := obj.GetObjectKind().GroupVersionKind()
// if the object referenced is actually persisted, we can just get kind from meta
// if we are building an object reference to something not yet persisted, we should fallback to scheme
kind := gvk.Kind
if len(kind) == 0 {
// TODO: this is wrong
gvks, _, err := scheme.ObjectKinds(obj)
if err != nil {
return nil, err
}
kind = gvks[0].Kind
}
// An object that implements only List has enough metadata to build a reference
var listMeta metav1.Common
objectMeta, err := meta.Accessor(obj)
@@ -56,29 +73,29 @@ func GetReference(scheme *runtime.Scheme, obj runtime.Object) (*v1.ObjectReferen
listMeta = objectMeta
}
gvk := obj.GetObjectKind().GroupVersionKind()
// If object meta doesn't contain data about kind and/or version,
// we are falling back to scheme.
//
// TODO: This doesn't work for CRDs, which are not registered in scheme.
if gvk.Empty() {
gvks, _, err := scheme.ObjectKinds(obj)
// if the object referenced is actually persisted, we can also get version from meta
version := gvk.GroupVersion().String()
if len(version) == 0 {
selfLink := listMeta.GetSelfLink()
if len(selfLink) == 0 {
return nil, ErrNoSelfLink
}
selfLinkUrl, err := url.Parse(selfLink)
if err != nil {
return nil, err
}
if len(gvks) == 0 || gvks[0].Empty() {
return nil, fmt.Errorf("unexpected gvks registered for object %T: %v", obj, gvks)
// example paths: /<prefix>/<version>/*
parts := strings.Split(selfLinkUrl.Path, "/")
if len(parts) < 4 {
return nil, fmt.Errorf("unexpected self link format: '%v'; got version '%v'", selfLink, version)
}
if parts[1] == "api" {
version = parts[2]
} else {
version = parts[2] + "/" + parts[3]
}
// TODO: The same object can be registered for multiple group versions
// (although in practise this doesn't seem to be used).
// In such case, the version set may not be correct.
gvk = gvks[0]
}
kind := gvk.Kind
version := gvk.GroupVersion().String()
// only has list metadata
if objectMeta == nil {
return &v1.ObjectReference{

View File

@@ -37,31 +37,29 @@ func TestGetReferenceRefVersion(t *testing.T) {
tests := []struct {
name string
input *TestRuntimeObj
groupVersion schema.GroupVersion
expectedRefVersion string
}{
{
name: "v1 GV from scheme",
name: "api from selflink",
input: &TestRuntimeObj{
ObjectMeta: metav1.ObjectMeta{SelfLink: "/bad-selflink/unused"},
ObjectMeta: metav1.ObjectMeta{SelfLink: "/api/v1/namespaces"},
},
groupVersion: schema.GroupVersion{Group: "", Version: "v1"},
expectedRefVersion: "v1",
},
{
name: "foo.group/v3 GV from scheme",
name: "foo.group/v3 from selflink",
input: &TestRuntimeObj{
ObjectMeta: metav1.ObjectMeta{SelfLink: "/bad-selflink/unused"},
ObjectMeta: metav1.ObjectMeta{SelfLink: "/apis/foo.group/v3/namespaces"},
},
groupVersion: schema.GroupVersion{Group: "foo.group", Version: "v3"},
expectedRefVersion: "foo.group/v3",
},
}
scheme := runtime.NewScheme()
scheme.AddKnownTypes(schema.GroupVersion{Group: "this", Version: "is ignored"}, &TestRuntimeObj{})
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
scheme := runtime.NewScheme()
scheme.AddKnownTypes(test.groupVersion, &TestRuntimeObj{})
ref, err := GetReference(scheme, test.input)
if err != nil {
t.Fatal(err)