mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-01 17:32:20 +00:00
Merge pull request #63913 from deads2k/controller-10-event
Automatic merge from submit-queue (batch tested with PRs 63598, 63913, 63459, 63963, 60464). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. fix event ref determination for apigroups The event ref determination was never updated to handle apigroups so it has been returning only a group (not a version). @kubernetes/sig-apps-bugs ```release-note event object references with apiversion will now report an apiversion. ``` Kubernetes-commit: 4810b9ba679f4fb9cc39f3a83bbcd23b3e4accce
This commit is contained in:
commit
fd323869ad
102
Godeps/Godeps.json
generated
102
Godeps/Godeps.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"ImportPath": "k8s.io/client-go",
|
||||
"GoVersion": "go1.9",
|
||||
"GoVersion": "go1.10",
|
||||
"GodepVersion": "v80",
|
||||
"Packages": [
|
||||
"./..."
|
||||
@ -388,203 +388,203 @@
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/errors",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/meta",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/resource",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/testing",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/testing/fuzzer",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/api/testing/roundtrip",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/conversion",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/fields",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/labels",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/selection",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/types",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/cache",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/clock",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/diff",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/errors",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/framer",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/json",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/net",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/sets",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/validation",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/wait",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/version",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/pkg/watch",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
|
||||
"Rev": "e226be1f5ed46b19fedc971f410f84de5b3dab8a"
|
||||
"Rev": "184e700b32b7f1b532b9fce8dd8c1f412d297c4b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto",
|
||||
|
@ -86,10 +86,14 @@ func GetReference(scheme *runtime.Scheme, obj runtime.Object) (*v1.ObjectReferen
|
||||
}
|
||||
// example paths: /<prefix>/<version>/*
|
||||
parts := strings.Split(selfLinkUrl.Path, "/")
|
||||
if len(parts) < 3 {
|
||||
if len(parts) < 4 {
|
||||
return nil, fmt.Errorf("unexpected self link format: '%v'; got version '%v'", selfLink, version)
|
||||
}
|
||||
version = parts[2]
|
||||
if parts[1] == "api" {
|
||||
version = parts[2]
|
||||
} else {
|
||||
version = parts[2] + "/" + parts[3]
|
||||
}
|
||||
}
|
||||
|
||||
// only has list metadata
|
||||
|
72
tools/reference/ref_test.go
Normal file
72
tools/reference/ref_test.go
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package reference
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
type TestRuntimeObj struct {
|
||||
metav1.TypeMeta
|
||||
metav1.ObjectMeta
|
||||
}
|
||||
|
||||
func (o *TestRuntimeObj) DeepCopyObject() runtime.Object {
|
||||
panic("die")
|
||||
}
|
||||
|
||||
func TestGetReferenceRefVersion(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input *TestRuntimeObj
|
||||
expectedRefVersion string
|
||||
}{
|
||||
{
|
||||
name: "api from selflink",
|
||||
input: &TestRuntimeObj{
|
||||
ObjectMeta: metav1.ObjectMeta{SelfLink: "/api/v1/namespaces"},
|
||||
},
|
||||
expectedRefVersion: "v1",
|
||||
},
|
||||
{
|
||||
name: "foo.group/v3 from selflink",
|
||||
input: &TestRuntimeObj{
|
||||
ObjectMeta: metav1.ObjectMeta{SelfLink: "/apis/foo.group/v3/namespaces"},
|
||||
},
|
||||
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) {
|
||||
ref, err := GetReference(scheme, test.input)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if test.expectedRefVersion != ref.APIVersion {
|
||||
t.Errorf("expected %q, got %q", test.expectedRefVersion, ref.APIVersion)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user