mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
Merge pull request #15510 from aveshagarwal/master-selflink-objref
Auto commit by PR queue bot
This commit is contained in:
commit
df265b2d6e
@ -32,10 +32,6 @@ var (
|
|||||||
ErrNoSelfLink = errors.New("selfLink was empty, can't make reference")
|
ErrNoSelfLink = errors.New("selfLink was empty, can't make reference")
|
||||||
)
|
)
|
||||||
|
|
||||||
// ForTesting_ReferencesAllowBlankSelfLinks can be set to true in tests to avoid
|
|
||||||
// "ErrNoSelfLink" errors.
|
|
||||||
var ForTesting_ReferencesAllowBlankSelfLinks = false
|
|
||||||
|
|
||||||
// GetReference returns an ObjectReference which refers to the given
|
// GetReference returns an ObjectReference which refers to the given
|
||||||
// object, or an error if the object doesn't follow the conventions
|
// object, or an error if the object doesn't follow the conventions
|
||||||
// that would allow this.
|
// that would allow this.
|
||||||
@ -68,11 +64,7 @@ func GetReference(obj runtime.Object) (*ObjectReference, error) {
|
|||||||
if version == "" {
|
if version == "" {
|
||||||
selfLink := meta.SelfLink()
|
selfLink := meta.SelfLink()
|
||||||
if selfLink == "" {
|
if selfLink == "" {
|
||||||
if ForTesting_ReferencesAllowBlankSelfLinks {
|
return nil, ErrNoSelfLink
|
||||||
version = "testing"
|
|
||||||
} else {
|
|
||||||
return nil, ErrNoSelfLink
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
selfLinkUrl, err := url.Parse(selfLink)
|
selfLinkUrl, err := url.Parse(selfLink)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -38,10 +38,6 @@ var (
|
|||||||
alwaysReady = func() bool { return true }
|
alwaysReady = func() bool { return true }
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
api.ForTesting_ReferencesAllowBlankSelfLinks = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func getKey(ds *extensions.DaemonSet, t *testing.T) string {
|
func getKey(ds *extensions.DaemonSet, t *testing.T) string {
|
||||||
if key, err := controller.KeyFunc(ds); err != nil {
|
if key, err := controller.KeyFunc(ds); err != nil {
|
||||||
t.Errorf("Unexpected error getting key for ds %v: %v", ds.Name, err)
|
t.Errorf("Unexpected error getting key for ds %v: %v", ds.Name, err)
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/api/errors"
|
"k8s.io/kubernetes/pkg/api/errors"
|
||||||
"k8s.io/kubernetes/pkg/api/resource"
|
"k8s.io/kubernetes/pkg/api/resource"
|
||||||
|
"k8s.io/kubernetes/pkg/api/testapi"
|
||||||
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
|
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
|
||||||
"k8s.io/kubernetes/pkg/volume"
|
"k8s.io/kubernetes/pkg/volume"
|
||||||
"k8s.io/kubernetes/pkg/volume/host_path"
|
"k8s.io/kubernetes/pkg/volume/host_path"
|
||||||
@ -169,7 +170,6 @@ func TestExampleObjects(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBindingWithExamples(t *testing.T) {
|
func TestBindingWithExamples(t *testing.T) {
|
||||||
api.ForTesting_ReferencesAllowBlankSelfLinks = true
|
|
||||||
o := testclient.NewObjects(api.Scheme, api.Scheme)
|
o := testclient.NewObjects(api.Scheme, api.Scheme)
|
||||||
if err := testclient.AddObjectsFromPath("../../../docs/user-guide/persistent-volumes/claims/claim-01.yaml", o, api.Scheme); err != nil {
|
if err := testclient.AddObjectsFromPath("../../../docs/user-guide/persistent-volumes/claims/claim-01.yaml", o, api.Scheme); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -186,11 +186,13 @@ func TestBindingWithExamples(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpected error getting PV from client: %v", err)
|
t.Errorf("Unexpected error getting PV from client: %v", err)
|
||||||
}
|
}
|
||||||
|
pv.ObjectMeta.SelfLink = testapi.Default.SelfLink("pv", "")
|
||||||
|
|
||||||
claim, error := client.PersistentVolumeClaims("ns").Get("any")
|
claim, error := client.PersistentVolumeClaims("ns").Get("any")
|
||||||
if error != nil {
|
if error != nil {
|
||||||
t.Errorf("Unexpected error getting PVC from client: %v", err)
|
t.Errorf("Unexpected error getting PVC from client: %v", err)
|
||||||
}
|
}
|
||||||
|
claim.ObjectMeta.SelfLink = testapi.Default.SelfLink("pvc", "")
|
||||||
|
|
||||||
volumeIndex := NewPersistentVolumeOrderedIndex()
|
volumeIndex := NewPersistentVolumeOrderedIndex()
|
||||||
mockClient := &mockBinderClient{
|
mockClient := &mockBinderClient{
|
||||||
@ -273,7 +275,6 @@ func TestBindingWithExamples(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMissingFromIndex(t *testing.T) {
|
func TestMissingFromIndex(t *testing.T) {
|
||||||
api.ForTesting_ReferencesAllowBlankSelfLinks = true
|
|
||||||
o := testclient.NewObjects(api.Scheme, api.Scheme)
|
o := testclient.NewObjects(api.Scheme, api.Scheme)
|
||||||
if err := testclient.AddObjectsFromPath("../../../docs/user-guide/persistent-volumes/claims/claim-01.yaml", o, api.Scheme); err != nil {
|
if err := testclient.AddObjectsFromPath("../../../docs/user-guide/persistent-volumes/claims/claim-01.yaml", o, api.Scheme); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -289,11 +290,13 @@ func TestMissingFromIndex(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpected error getting PV from client: %v", err)
|
t.Errorf("Unexpected error getting PV from client: %v", err)
|
||||||
}
|
}
|
||||||
|
pv.ObjectMeta.SelfLink = testapi.Default.SelfLink("pv", "")
|
||||||
|
|
||||||
claim, error := client.PersistentVolumeClaims("ns").Get("any")
|
claim, error := client.PersistentVolumeClaims("ns").Get("any")
|
||||||
if error != nil {
|
if error != nil {
|
||||||
t.Errorf("Unexpected error getting PVC from client: %v", err)
|
t.Errorf("Unexpected error getting PVC from client: %v", err)
|
||||||
}
|
}
|
||||||
|
claim.ObjectMeta.SelfLink = testapi.Default.SelfLink("pvc", "")
|
||||||
|
|
||||||
volumeIndex := NewPersistentVolumeOrderedIndex()
|
volumeIndex := NewPersistentVolumeOrderedIndex()
|
||||||
mockClient := &mockBinderClient{
|
mockClient := &mockBinderClient{
|
||||||
|
@ -39,10 +39,6 @@ import (
|
|||||||
|
|
||||||
var alwaysReady = func() bool { return true }
|
var alwaysReady = func() bool { return true }
|
||||||
|
|
||||||
func init() {
|
|
||||||
api.ForTesting_ReferencesAllowBlankSelfLinks = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func getKey(rc *api.ReplicationController, t *testing.T) string {
|
func getKey(rc *api.ReplicationController, t *testing.T) string {
|
||||||
if key, err := controller.KeyFunc(rc); err != nil {
|
if key, err := controller.KeyFunc(rc); err != nil {
|
||||||
t.Errorf("Unexpected error getting key for rc %v: %v", rc.Name, err)
|
t.Errorf("Unexpected error getting key for rc %v: %v", rc.Name, err)
|
||||||
|
@ -39,10 +39,6 @@ type describeClient struct {
|
|||||||
client.Interface
|
client.Interface
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
api.ForTesting_ReferencesAllowBlankSelfLinks = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDescribePod(t *testing.T) {
|
func TestDescribePod(t *testing.T) {
|
||||||
fake := testclient.NewSimpleFake(&api.Pod{
|
fake := testclient.NewSimpleFake(&api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
|
@ -972,7 +972,6 @@ func TestSyncPodsDoesNothing(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSyncPodWithPullPolicy(t *testing.T) {
|
func TestSyncPodWithPullPolicy(t *testing.T) {
|
||||||
api.ForTesting_ReferencesAllowBlankSelfLinks = true
|
|
||||||
dm, fakeDocker := newTestDockerManager()
|
dm, fakeDocker := newTestDockerManager()
|
||||||
puller := dm.dockerPuller.(*FakeDockerPuller)
|
puller := dm.dockerPuller.(*FakeDockerPuller)
|
||||||
puller.HasImages = []string{"existing_one", "want:latest"}
|
puller.HasImages = []string{"existing_one", "want:latest"}
|
||||||
|
@ -61,7 +61,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
api.ForTesting_ReferencesAllowBlankSelfLinks = true
|
|
||||||
util.ReallyCrash = true
|
util.ReallyCrash = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user