Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
d9920c53
Commit
d9920c53
authored
Apr 10, 2017
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move ref.go to its own subpackage
parent
c3463d73
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
215 additions
and
197 deletions
+215
-197
BUILD
pkg/api/BUILD
+5
-7
objectreference.go
pkg/api/objectreference.go
+34
-0
BUILD
pkg/api/ref/BUILD
+46
-0
ref.go
pkg/api/ref/ref.go
+7
-18
ref_test.go
pkg/api/ref/ref_test.go
+12
-11
taint.go
pkg/api/taint.go
+0
-10
taint_test.go
pkg/api/taint_test.go
+0
-0
toleration.go
pkg/api/toleration.go
+30
-0
BUILD
...erated/internalclientset/typed/core/internalversion/BUILD
+1
-0
event_expansion.go
...alclientset/typed/core/internalversion/event_expansion.go
+2
-1
BUILD
pkg/kubectl/cmd/BUILD
+1
-0
drain_test.go
pkg/kubectl/cmd/drain_test.go
+2
-1
BUILD
pkg/printers/internalversion/BUILD
+1
-0
describe.go
pkg/printers/internalversion/describe.go
+3
-2
proxier.go
pkg/proxy/userspace/proxier.go
+1
-1
BUILD
plugin/pkg/admission/podpreset/BUILD
+1
-0
admission.go
plugin/pkg/admission/podpreset/admission.go
+2
-1
objectreference.go
staging/src/k8s.io/client-go/pkg/api/objectreference.go
+34
-0
ref.go
staging/src/k8s.io/client-go/pkg/api/ref.go
+0
-132
taint.go
staging/src/k8s.io/client-go/pkg/api/taint.go
+0
-10
toleration.go
staging/src/k8s.io/client-go/pkg/api/toleration.go
+30
-0
BUILD
vendor/BUILD
+3
-3
No files found.
pkg/api/BUILD
View file @
d9920c53
...
@@ -16,16 +16,16 @@ go_library(
...
@@ -16,16 +16,16 @@ go_library(
"doc.go",
"doc.go",
"field_constants.go",
"field_constants.go",
"json.go",
"json.go",
"methods.go",
"objectreference.go",
"ref.go",
"register.go",
"register.go",
"resource_helpers.go",
"resource_helpers.go",
"taint.go",
"toleration.go",
"types.go",
"types.go",
"zz_generated.deepcopy.go",
"zz_generated.deepcopy.go",
],
],
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = [
"//vendor:k8s.io/apimachinery/pkg/api/meta",
"//vendor:k8s.io/apimachinery/pkg/api/resource",
"//vendor:k8s.io/apimachinery/pkg/api/resource",
"//vendor:k8s.io/apimachinery/pkg/apimachinery/announced",
"//vendor:k8s.io/apimachinery/pkg/apimachinery/announced",
"//vendor:k8s.io/apimachinery/pkg/apimachinery/registered",
"//vendor:k8s.io/apimachinery/pkg/apimachinery/registered",
...
@@ -44,17 +44,14 @@ go_library(
...
@@ -44,17 +44,14 @@ go_library(
go_test(
go_test(
name = "go_default_test",
name = "go_default_test",
srcs = [
srcs = [
"methods_test.go",
"ref_test.go",
"resource_helpers_test.go",
"resource_helpers_test.go",
"taint_test.go",
],
],
library = ":go_default_library",
library = ":go_default_library",
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = [
"//vendor:k8s.io/apimachinery/pkg/api/resource",
"//vendor:k8s.io/apimachinery/pkg/api/resource",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/runtime",
"//vendor:k8s.io/apimachinery/pkg/runtime/schema",
],
],
)
)
...
@@ -120,6 +117,7 @@ filegroup(
...
@@ -120,6 +117,7 @@ filegroup(
"//pkg/api/install:all-srcs",
"//pkg/api/install:all-srcs",
"//pkg/api/meta:all-srcs",
"//pkg/api/meta:all-srcs",
"//pkg/api/pod:all-srcs",
"//pkg/api/pod:all-srcs",
"//pkg/api/ref:all-srcs",
"//pkg/api/resource:all-srcs",
"//pkg/api/resource:all-srcs",
"//pkg/api/service:all-srcs",
"//pkg/api/service:all-srcs",
"//pkg/api/testapi:all-srcs",
"//pkg/api/testapi:all-srcs",
...
...
pkg/api/objectreference.go
0 → 100644
View file @
d9920c53
/*
Copyright 2017 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.
*/
//TODO: consider making these methods functions, because we don't want helper
//functions in the k8s.io/api repo.
package
api
import
(
"k8s.io/apimachinery/pkg/runtime/schema"
)
func
(
obj
*
ObjectReference
)
SetGroupVersionKind
(
gvk
schema
.
GroupVersionKind
)
{
obj
.
APIVersion
,
obj
.
Kind
=
gvk
.
ToAPIVersionAndKind
()
}
func
(
obj
*
ObjectReference
)
GroupVersionKind
()
schema
.
GroupVersionKind
{
return
schema
.
FromAPIVersionAndKind
(
obj
.
APIVersion
,
obj
.
Kind
)
}
func
(
obj
*
ObjectReference
)
GetObjectKind
()
schema
.
ObjectKind
{
return
obj
}
pkg/api/ref/BUILD
0 → 100644
View file @
d9920c53
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_test(
name = "go_default_test",
srcs = ["ref_test.go"],
library = ":go_default_library",
tags = ["automanaged"],
deps = [
"//pkg/api:go_default_library",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/runtime",
"//vendor:k8s.io/apimachinery/pkg/runtime/schema",
],
)
go_library(
name = "go_default_library",
srcs = ["ref.go"],
tags = ["automanaged"],
deps = [
"//pkg/api:go_default_library",
"//vendor:k8s.io/apimachinery/pkg/api/meta",
"//vendor:k8s.io/apimachinery/pkg/runtime",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)
pkg/api/ref.go
→
pkg/api/ref
/ref
.go
View file @
d9920c53
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
api
package
ref
import
(
import
(
"errors"
"errors"
...
@@ -24,7 +24,7 @@ import (
...
@@ -24,7 +24,7 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/
apimachinery/pkg/runtime/schema
"
"k8s.io/
kubernetes/pkg/api
"
)
)
var
(
var
(
...
@@ -37,11 +37,11 @@ var (
...
@@ -37,11 +37,11 @@ var (
// 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.
// TODO: should take a meta.Interface see http://issue.k8s.io/7127
// TODO: should take a meta.Interface see http://issue.k8s.io/7127
func
GetReference
(
scheme
*
runtime
.
Scheme
,
obj
runtime
.
Object
)
(
*
ObjectReference
,
error
)
{
func
GetReference
(
scheme
*
runtime
.
Scheme
,
obj
runtime
.
Object
)
(
*
api
.
ObjectReference
,
error
)
{
if
obj
==
nil
{
if
obj
==
nil
{
return
nil
,
ErrNilObject
return
nil
,
ErrNilObject
}
}
if
ref
,
ok
:=
obj
.
(
*
ObjectReference
);
ok
{
if
ref
,
ok
:=
obj
.
(
*
api
.
ObjectReference
);
ok
{
// Don't make a reference to a reference.
// Don't make a reference to a reference.
return
ref
,
nil
return
ref
,
nil
}
}
...
@@ -93,14 +93,14 @@ func GetReference(scheme *runtime.Scheme, obj runtime.Object) (*ObjectReference,
...
@@ -93,14 +93,14 @@ func GetReference(scheme *runtime.Scheme, obj runtime.Object) (*ObjectReference,
// only has list metadata
// only has list metadata
if
objectMeta
==
nil
{
if
objectMeta
==
nil
{
return
&
ObjectReference
{
return
&
api
.
ObjectReference
{
Kind
:
kind
,
Kind
:
kind
,
APIVersion
:
version
,
APIVersion
:
version
,
ResourceVersion
:
listMeta
.
GetResourceVersion
(),
ResourceVersion
:
listMeta
.
GetResourceVersion
(),
},
nil
},
nil
}
}
return
&
ObjectReference
{
return
&
api
.
ObjectReference
{
Kind
:
kind
,
Kind
:
kind
,
APIVersion
:
version
,
APIVersion
:
version
,
Name
:
objectMeta
.
GetName
(),
Name
:
objectMeta
.
GetName
(),
...
@@ -111,7 +111,7 @@ func GetReference(scheme *runtime.Scheme, obj runtime.Object) (*ObjectReference,
...
@@ -111,7 +111,7 @@ func GetReference(scheme *runtime.Scheme, obj runtime.Object) (*ObjectReference,
}
}
// GetPartialReference is exactly like GetReference, but allows you to set the FieldPath.
// GetPartialReference is exactly like GetReference, but allows you to set the FieldPath.
func
GetPartialReference
(
scheme
*
runtime
.
Scheme
,
obj
runtime
.
Object
,
fieldPath
string
)
(
*
ObjectReference
,
error
)
{
func
GetPartialReference
(
scheme
*
runtime
.
Scheme
,
obj
runtime
.
Object
,
fieldPath
string
)
(
*
api
.
ObjectReference
,
error
)
{
ref
,
err
:=
GetReference
(
scheme
,
obj
)
ref
,
err
:=
GetReference
(
scheme
,
obj
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -119,14 +119,3 @@ func GetPartialReference(scheme *runtime.Scheme, obj runtime.Object, fieldPath s
...
@@ -119,14 +119,3 @@ func GetPartialReference(scheme *runtime.Scheme, obj runtime.Object, fieldPath s
ref
.
FieldPath
=
fieldPath
ref
.
FieldPath
=
fieldPath
return
ref
,
nil
return
ref
,
nil
}
}
// IsAnAPIObject allows clients to preemptively get a reference to an API object and pass it to places that
// intend only to get a reference to that object. This simplifies the event recording interface.
func
(
obj
*
ObjectReference
)
SetGroupVersionKind
(
gvk
schema
.
GroupVersionKind
)
{
obj
.
APIVersion
,
obj
.
Kind
=
gvk
.
ToAPIVersionAndKind
()
}
func
(
obj
*
ObjectReference
)
GroupVersionKind
()
schema
.
GroupVersionKind
{
return
schema
.
FromAPIVersionAndKind
(
obj
.
APIVersion
,
obj
.
Kind
)
}
func
(
obj
*
ObjectReference
)
GetObjectKind
()
schema
.
ObjectKind
{
return
obj
}
pkg/api/ref_test.go
→
pkg/api/ref
/ref
_test.go
View file @
d9920c53
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
api
package
ref
import
(
import
(
"reflect"
"reflect"
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/kubernetes/pkg/api"
)
)
type
FakeAPIObject
struct
{}
type
FakeAPIObject
struct
{}
...
@@ -41,18 +42,18 @@ func TestGetReference(t *testing.T) {
...
@@ -41,18 +42,18 @@ func TestGetReference(t *testing.T) {
// when vendoring kube, if you don't force the set of registered versions (like make test does)
// when vendoring kube, if you don't force the set of registered versions (like make test does)
// then you run into trouble because the types aren't registered in the scheme by anything. This does the
// then you run into trouble because the types aren't registered in the scheme by anything. This does the
// register manually to allow unit test execution
// register manually to allow unit test execution
if
_
,
_
,
err
:=
Scheme
.
ObjectKinds
(
&
Pod
{});
err
!=
nil
{
if
_
,
_
,
err
:=
api
.
Scheme
.
ObjectKinds
(
&
api
.
Pod
{});
err
!=
nil
{
AddToScheme
(
Scheme
)
api
.
AddToScheme
(
api
.
Scheme
)
}
}
table
:=
map
[
string
]
struct
{
table
:=
map
[
string
]
struct
{
obj
runtime
.
Object
obj
runtime
.
Object
ref
*
ObjectReference
ref
*
api
.
ObjectReference
fieldPath
string
fieldPath
string
shouldErr
bool
shouldErr
bool
}{
}{
"pod"
:
{
"pod"
:
{
obj
:
&
Pod
{
obj
:
&
api
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
,
Name
:
"foo"
,
UID
:
"bar"
,
UID
:
"bar"
,
...
@@ -61,7 +62,7 @@ func TestGetReference(t *testing.T) {
...
@@ -61,7 +62,7 @@ func TestGetReference(t *testing.T) {
},
},
},
},
fieldPath
:
".desiredState.containers[0]"
,
fieldPath
:
".desiredState.containers[0]"
,
ref
:
&
ObjectReference
{
ref
:
&
api
.
ObjectReference
{
Kind
:
"Pod"
,
Kind
:
"Pod"
,
APIVersion
:
"version1"
,
APIVersion
:
"version1"
,
Name
:
"foo"
,
Name
:
"foo"
,
...
@@ -71,13 +72,13 @@ func TestGetReference(t *testing.T) {
...
@@ -71,13 +72,13 @@ func TestGetReference(t *testing.T) {
},
},
},
},
"serviceList"
:
{
"serviceList"
:
{
obj
:
&
ServiceList
{
obj
:
&
api
.
ServiceList
{
ListMeta
:
metav1
.
ListMeta
{
ListMeta
:
metav1
.
ListMeta
{
ResourceVersion
:
"42"
,
ResourceVersion
:
"42"
,
SelfLink
:
"/api/version2/services"
,
SelfLink
:
"/api/version2/services"
,
},
},
},
},
ref
:
&
ObjectReference
{
ref
:
&
api
.
ObjectReference
{
Kind
:
"ServiceList"
,
Kind
:
"ServiceList"
,
APIVersion
:
"version2"
,
APIVersion
:
"version2"
,
ResourceVersion
:
"42"
,
ResourceVersion
:
"42"
,
...
@@ -95,7 +96,7 @@ func TestGetReference(t *testing.T) {
...
@@ -95,7 +96,7 @@ func TestGetReference(t *testing.T) {
SelfLink
:
"/custom_prefix/version1/extensions/foo"
,
SelfLink
:
"/custom_prefix/version1/extensions/foo"
,
},
},
},
},
ref
:
&
ObjectReference
{
ref
:
&
api
.
ObjectReference
{
Kind
:
"ExtensionAPIObject"
,
Kind
:
"ExtensionAPIObject"
,
APIVersion
:
"version1"
,
APIVersion
:
"version1"
,
Name
:
"foo"
,
Name
:
"foo"
,
...
@@ -104,7 +105,7 @@ func TestGetReference(t *testing.T) {
...
@@ -104,7 +105,7 @@ func TestGetReference(t *testing.T) {
},
},
},
},
"badSelfLink"
:
{
"badSelfLink"
:
{
obj
:
&
ServiceList
{
obj
:
&
api
.
ServiceList
{
ListMeta
:
metav1
.
ListMeta
{
ListMeta
:
metav1
.
ListMeta
{
ResourceVersion
:
"42"
,
ResourceVersion
:
"42"
,
SelfLink
:
"version2/services"
,
SelfLink
:
"version2/services"
,
...
@@ -125,7 +126,7 @@ func TestGetReference(t *testing.T) {
...
@@ -125,7 +126,7 @@ func TestGetReference(t *testing.T) {
}
}
for
name
,
item
:=
range
table
{
for
name
,
item
:=
range
table
{
ref
,
err
:=
GetPartialReference
(
Scheme
,
item
.
obj
,
item
.
fieldPath
)
ref
,
err
:=
GetPartialReference
(
api
.
Scheme
,
item
.
obj
,
item
.
fieldPath
)
if
e
,
a
:=
item
.
shouldErr
,
(
err
!=
nil
);
e
!=
a
{
if
e
,
a
:=
item
.
shouldErr
,
(
err
!=
nil
);
e
!=
a
{
t
.
Errorf
(
"%v: expected %v, got %v, err %v"
,
name
,
e
,
a
,
err
)
t
.
Errorf
(
"%v: expected %v, got %v, err %v"
,
name
,
e
,
a
,
err
)
continue
continue
...
...
pkg/api/
methods
.go
→
pkg/api/
taint
.go
View file @
d9920c53
...
@@ -21,16 +21,6 @@ package api
...
@@ -21,16 +21,6 @@ package api
import
"fmt"
import
"fmt"
// MatchToleration checks if the toleration matches tolerationToMatch. Tolerations are unique by <key,effect,operator,value>,
// if the two tolerations have same <key,effect,operator,value> combination, regard as they match.
// TODO: uniqueness check for tolerations in api validations.
func
(
t
*
Toleration
)
MatchToleration
(
tolerationToMatch
*
Toleration
)
bool
{
return
t
.
Key
==
tolerationToMatch
.
Key
&&
t
.
Effect
==
tolerationToMatch
.
Effect
&&
t
.
Operator
==
tolerationToMatch
.
Operator
&&
t
.
Value
==
tolerationToMatch
.
Value
}
// MatchTaint checks if the taint matches taintToMatch. Taints are unique by key:effect,
// MatchTaint checks if the taint matches taintToMatch. Taints are unique by key:effect,
// if the two taints have same key:effect, regard as they match.
// if the two taints have same key:effect, regard as they match.
func
(
t
*
Taint
)
MatchTaint
(
taintToMatch
Taint
)
bool
{
func
(
t
*
Taint
)
MatchTaint
(
taintToMatch
Taint
)
bool
{
...
...
pkg/api/
methods
_test.go
→
pkg/api/
taint
_test.go
View file @
d9920c53
File moved
pkg/api/toleration.go
0 → 100644
View file @
d9920c53
/*
Copyright 2017 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.
*/
//TODO: consider making these methods functions, because we don't want helper
//functions in the k8s.io/api repo.
package
api
// MatchToleration checks if the toleration matches tolerationToMatch. Tolerations are unique by <key,effect,operator,value>,
// if the two tolerations have same <key,effect,operator,value> combination, regard as they match.
// TODO: uniqueness check for tolerations in api validations.
func
(
t
*
Toleration
)
MatchToleration
(
tolerationToMatch
*
Toleration
)
bool
{
return
t
.
Key
==
tolerationToMatch
.
Key
&&
t
.
Effect
==
tolerationToMatch
.
Effect
&&
t
.
Operator
==
tolerationToMatch
.
Operator
&&
t
.
Value
==
tolerationToMatch
.
Value
}
pkg/client/clientset_generated/internalclientset/typed/core/internalversion/BUILD
View file @
d9920c53
...
@@ -38,6 +38,7 @@ go_library(
...
@@ -38,6 +38,7 @@ go_library(
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = [
"//pkg/api:go_default_library",
"//pkg/api:go_default_library",
"//pkg/api/ref:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/api/v1:go_default_library",
"//pkg/client/clientset_generated/internalclientset/scheme:go_default_library",
"//pkg/client/clientset_generated/internalclientset/scheme:go_default_library",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
...
...
pkg/client/clientset_generated/internalclientset/typed/core/internalversion/event_expansion.go
View file @
d9920c53
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/types"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/ref"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/v1"
)
)
...
@@ -100,7 +101,7 @@ func (e *events) PatchWithEventNamespace(incompleteEvent *api.Event, data []byte
...
@@ -100,7 +101,7 @@ func (e *events) PatchWithEventNamespace(incompleteEvent *api.Event, data []byte
// object must match this event's client namespace unless the event client
// object must match this event's client namespace unless the event client
// was made with the "" namespace.
// was made with the "" namespace.
func
(
e
*
events
)
Search
(
scheme
*
runtime
.
Scheme
,
objOrRef
runtime
.
Object
)
(
*
api
.
EventList
,
error
)
{
func
(
e
*
events
)
Search
(
scheme
*
runtime
.
Scheme
,
objOrRef
runtime
.
Object
)
(
*
api
.
EventList
,
error
)
{
ref
,
err
:=
api
.
GetReference
(
scheme
,
objOrRef
)
ref
,
err
:=
ref
.
GetReference
(
scheme
,
objOrRef
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
pkg/kubectl/cmd/BUILD
View file @
d9920c53
...
@@ -195,6 +195,7 @@ go_test(
...
@@ -195,6 +195,7 @@ go_test(
deps = [
deps = [
"//pkg/api:go_default_library",
"//pkg/api:go_default_library",
"//pkg/api/annotations:go_default_library",
"//pkg/api/annotations:go_default_library",
"//pkg/api/ref:go_default_library",
"//pkg/api/testapi:go_default_library",
"//pkg/api/testapi:go_default_library",
"//pkg/api/testing:go_default_library",
"//pkg/api/testing:go_default_library",
"//pkg/api/unversioned:go_default_library",
"//pkg/api/unversioned:go_default_library",
...
...
pkg/kubectl/cmd/drain_test.go
View file @
d9920c53
...
@@ -41,6 +41,7 @@ import (
...
@@ -41,6 +41,7 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/rest/fake"
"k8s.io/client-go/rest/fake"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/ref"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/apis/extensions"
...
@@ -795,7 +796,7 @@ func (m *MyReq) isFor(method string, path string) bool {
...
@@ -795,7 +796,7 @@ func (m *MyReq) isFor(method string, path string) bool {
}
}
func
refJson
(
t
*
testing
.
T
,
o
runtime
.
Object
)
string
{
func
refJson
(
t
*
testing
.
T
,
o
runtime
.
Object
)
string
{
ref
,
err
:=
api
.
GetReference
(
api
.
Scheme
,
o
)
ref
,
err
:=
ref
.
GetReference
(
api
.
Scheme
,
o
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
}
...
...
pkg/printers/internalversion/BUILD
View file @
d9920c53
...
@@ -63,6 +63,7 @@ go_library(
...
@@ -63,6 +63,7 @@ go_library(
"//pkg/api/annotations:go_default_library",
"//pkg/api/annotations:go_default_library",
"//pkg/api/events:go_default_library",
"//pkg/api/events:go_default_library",
"//pkg/api/helper:go_default_library",
"//pkg/api/helper:go_default_library",
"//pkg/api/ref:go_default_library",
"//pkg/apis/apps:go_default_library",
"//pkg/apis/apps:go_default_library",
"//pkg/apis/autoscaling:go_default_library",
"//pkg/apis/autoscaling:go_default_library",
"//pkg/apis/batch:go_default_library",
"//pkg/apis/batch:go_default_library",
...
...
pkg/printers/internalversion/describe.go
View file @
d9920c53
...
@@ -48,6 +48,7 @@ import (
...
@@ -48,6 +48,7 @@ import (
"k8s.io/kubernetes/pkg/api/annotations"
"k8s.io/kubernetes/pkg/api/annotations"
"k8s.io/kubernetes/pkg/api/events"
"k8s.io/kubernetes/pkg/api/events"
"k8s.io/kubernetes/pkg/api/helper"
"k8s.io/kubernetes/pkg/api/helper"
"k8s.io/kubernetes/pkg/api/ref"
"k8s.io/kubernetes/pkg/apis/apps"
"k8s.io/kubernetes/pkg/apis/apps"
"k8s.io/kubernetes/pkg/apis/autoscaling"
"k8s.io/kubernetes/pkg/apis/autoscaling"
"k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/apis/batch"
...
@@ -521,7 +522,7 @@ func (d *PodDescriber) Describe(namespace, name string, describerSettings printe
...
@@ -521,7 +522,7 @@ func (d *PodDescriber) Describe(namespace, name string, describerSettings printe
var
events
*
api
.
EventList
var
events
*
api
.
EventList
if
describerSettings
.
ShowEvents
{
if
describerSettings
.
ShowEvents
{
if
ref
,
err
:=
api
.
GetReference
(
api
.
Scheme
,
pod
);
err
!=
nil
{
if
ref
,
err
:=
ref
.
GetReference
(
api
.
Scheme
,
pod
);
err
!=
nil
{
glog
.
Errorf
(
"Unable to construct reference to '%#v': %v"
,
pod
,
err
)
glog
.
Errorf
(
"Unable to construct reference to '%#v': %v"
,
pod
,
err
)
}
else
{
}
else
{
ref
.
Kind
=
""
ref
.
Kind
=
""
...
@@ -2033,7 +2034,7 @@ func (d *NodeDescriber) Describe(namespace, name string, describerSettings print
...
@@ -2033,7 +2034,7 @@ func (d *NodeDescriber) Describe(namespace, name string, describerSettings print
var
events
*
api
.
EventList
var
events
*
api
.
EventList
if
describerSettings
.
ShowEvents
{
if
describerSettings
.
ShowEvents
{
if
ref
,
err
:=
api
.
GetReference
(
api
.
Scheme
,
node
);
err
!=
nil
{
if
ref
,
err
:=
ref
.
GetReference
(
api
.
Scheme
,
node
);
err
!=
nil
{
glog
.
Errorf
(
"Unable to construct reference to '%#v': %v"
,
node
,
err
)
glog
.
Errorf
(
"Unable to construct reference to '%#v': %v"
,
node
,
err
)
}
else
{
}
else
{
// TODO: We haven't decided the namespace for Node object yet.
// TODO: We haven't decided the namespace for Node object yet.
...
...
pkg/proxy/userspace/proxier.go
View file @
d9920c53
...
@@ -411,7 +411,7 @@ func (proxier *Proxier) OnServiceUpdate(services []*api.Service) {
...
@@ -411,7 +411,7 @@ func (proxier *Proxier) OnServiceUpdate(services []*api.Service) {
continue
continue
}
}
// TODO: should this just be
api
.GetReference?
// TODO: should this just be
ref
.GetReference?
svcGVK
:=
service
.
GetObjectKind
()
.
GroupVersionKind
()
svcGVK
:=
service
.
GetObjectKind
()
.
GroupVersionKind
()
svcRef
:=
api
.
ObjectReference
{
svcRef
:=
api
.
ObjectReference
{
Kind
:
svcGVK
.
Kind
,
Kind
:
svcGVK
.
Kind
,
...
...
plugin/pkg/admission/podpreset/BUILD
View file @
d9920c53
...
@@ -33,6 +33,7 @@ go_library(
...
@@ -33,6 +33,7 @@ go_library(
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = [
"//pkg/api:go_default_library",
"//pkg/api:go_default_library",
"//pkg/api/ref:go_default_library",
"//pkg/apis/settings:go_default_library",
"//pkg/apis/settings:go_default_library",
"//pkg/client/clientset_generated/internalclientset:go_default_library",
"//pkg/client/clientset_generated/internalclientset:go_default_library",
"//pkg/client/informers/informers_generated/internalversion:go_default_library",
"//pkg/client/informers/informers_generated/internalversion:go_default_library",
...
...
plugin/pkg/admission/podpreset/admission.go
View file @
d9920c53
...
@@ -28,6 +28,7 @@ import (
...
@@ -28,6 +28,7 @@ import (
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apiserver/pkg/admission"
"k8s.io/apiserver/pkg/admission"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/ref"
"k8s.io/kubernetes/pkg/apis/settings"
"k8s.io/kubernetes/pkg/apis/settings"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
informers
"k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion"
informers
"k8s.io/kubernetes/pkg/client/informers/informers_generated/internalversion"
...
@@ -298,7 +299,7 @@ func mergeVolumes(pip *settings.PodPreset, original []api.Volume) ([]api.Volume,
...
@@ -298,7 +299,7 @@ func mergeVolumes(pip *settings.PodPreset, original []api.Volume) ([]api.Volume,
}
}
func
(
c
*
podPresetPlugin
)
addEvent
(
pod
*
api
.
Pod
,
pip
*
settings
.
PodPreset
,
message
string
)
{
func
(
c
*
podPresetPlugin
)
addEvent
(
pod
*
api
.
Pod
,
pip
*
settings
.
PodPreset
,
message
string
)
{
ref
,
err
:=
api
.
GetReference
(
api
.
Scheme
,
pod
)
ref
,
err
:=
ref
.
GetReference
(
api
.
Scheme
,
pod
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"pip %s: get reference for pod %s failed: %v"
,
pip
.
GetName
(),
pod
.
GetName
(),
err
)
glog
.
Errorf
(
"pip %s: get reference for pod %s failed: %v"
,
pip
.
GetName
(),
pod
.
GetName
(),
err
)
return
return
...
...
staging/src/k8s.io/client-go/pkg/api/objectreference.go
0 → 100644
View file @
d9920c53
/*
Copyright 2017 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.
*/
//TODO: consider making these methods functions, because we don't want helper
//functions in the k8s.io/api repo.
package
api
import
(
"k8s.io/apimachinery/pkg/runtime/schema"
)
func
(
obj
*
ObjectReference
)
SetGroupVersionKind
(
gvk
schema
.
GroupVersionKind
)
{
obj
.
APIVersion
,
obj
.
Kind
=
gvk
.
ToAPIVersionAndKind
()
}
func
(
obj
*
ObjectReference
)
GroupVersionKind
()
schema
.
GroupVersionKind
{
return
schema
.
FromAPIVersionAndKind
(
obj
.
APIVersion
,
obj
.
Kind
)
}
func
(
obj
*
ObjectReference
)
GetObjectKind
()
schema
.
ObjectKind
{
return
obj
}
staging/src/k8s.io/client-go/pkg/api/ref.go
deleted
100644 → 0
View file @
c3463d73
/*
Copyright 2014 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
api
import
(
"errors"
"fmt"
"net/url"
"strings"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
var
(
// Errors that could be returned by GetReference.
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
// object, or an error if the object doesn't follow the conventions
// that would allow this.
// TODO: should take a meta.Interface see http://issue.k8s.io/7127
func
GetReference
(
scheme
*
runtime
.
Scheme
,
obj
runtime
.
Object
)
(
*
ObjectReference
,
error
)
{
if
obj
==
nil
{
return
nil
,
ErrNilObject
}
if
ref
,
ok
:=
obj
.
(
*
ObjectReference
);
ok
{
// Don't make a reference to a reference.
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
meta
.
List
objectMeta
,
err
:=
meta
.
Accessor
(
obj
)
if
err
!=
nil
{
listMeta
,
err
=
meta
.
ListAccessor
(
obj
)
if
err
!=
nil
{
return
nil
,
err
}
}
else
{
listMeta
=
objectMeta
}
// 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
}
// example paths: /<prefix>/<version>/*
parts
:=
strings
.
Split
(
selfLinkUrl
.
Path
,
"/"
)
if
len
(
parts
)
<
3
{
return
nil
,
fmt
.
Errorf
(
"unexpected self link format: '%v'; got version '%v'"
,
selfLink
,
version
)
}
version
=
parts
[
2
]
}
// only has list metadata
if
objectMeta
==
nil
{
return
&
ObjectReference
{
Kind
:
kind
,
APIVersion
:
version
,
ResourceVersion
:
listMeta
.
GetResourceVersion
(),
},
nil
}
return
&
ObjectReference
{
Kind
:
kind
,
APIVersion
:
version
,
Name
:
objectMeta
.
GetName
(),
Namespace
:
objectMeta
.
GetNamespace
(),
UID
:
objectMeta
.
GetUID
(),
ResourceVersion
:
objectMeta
.
GetResourceVersion
(),
},
nil
}
// GetPartialReference is exactly like GetReference, but allows you to set the FieldPath.
func
GetPartialReference
(
scheme
*
runtime
.
Scheme
,
obj
runtime
.
Object
,
fieldPath
string
)
(
*
ObjectReference
,
error
)
{
ref
,
err
:=
GetReference
(
scheme
,
obj
)
if
err
!=
nil
{
return
nil
,
err
}
ref
.
FieldPath
=
fieldPath
return
ref
,
nil
}
// IsAnAPIObject allows clients to preemptively get a reference to an API object and pass it to places that
// intend only to get a reference to that object. This simplifies the event recording interface.
func
(
obj
*
ObjectReference
)
SetGroupVersionKind
(
gvk
schema
.
GroupVersionKind
)
{
obj
.
APIVersion
,
obj
.
Kind
=
gvk
.
ToAPIVersionAndKind
()
}
func
(
obj
*
ObjectReference
)
GroupVersionKind
()
schema
.
GroupVersionKind
{
return
schema
.
FromAPIVersionAndKind
(
obj
.
APIVersion
,
obj
.
Kind
)
}
func
(
obj
*
ObjectReference
)
GetObjectKind
()
schema
.
ObjectKind
{
return
obj
}
staging/src/k8s.io/client-go/pkg/api/
methods
.go
→
staging/src/k8s.io/client-go/pkg/api/
taint
.go
View file @
d9920c53
...
@@ -21,16 +21,6 @@ package api
...
@@ -21,16 +21,6 @@ package api
import
"fmt"
import
"fmt"
// MatchToleration checks if the toleration matches tolerationToMatch. Tolerations are unique by <key,effect,operator,value>,
// if the two tolerations have same <key,effect,operator,value> combination, regard as they match.
// TODO: uniqueness check for tolerations in api validations.
func
(
t
*
Toleration
)
MatchToleration
(
tolerationToMatch
*
Toleration
)
bool
{
return
t
.
Key
==
tolerationToMatch
.
Key
&&
t
.
Effect
==
tolerationToMatch
.
Effect
&&
t
.
Operator
==
tolerationToMatch
.
Operator
&&
t
.
Value
==
tolerationToMatch
.
Value
}
// MatchTaint checks if the taint matches taintToMatch. Taints are unique by key:effect,
// MatchTaint checks if the taint matches taintToMatch. Taints are unique by key:effect,
// if the two taints have same key:effect, regard as they match.
// if the two taints have same key:effect, regard as they match.
func
(
t
*
Taint
)
MatchTaint
(
taintToMatch
Taint
)
bool
{
func
(
t
*
Taint
)
MatchTaint
(
taintToMatch
Taint
)
bool
{
...
...
staging/src/k8s.io/client-go/pkg/api/toleration.go
0 → 100644
View file @
d9920c53
/*
Copyright 2017 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.
*/
//TODO: consider making these methods functions, because we don't want helper
//functions in the k8s.io/api repo.
package
api
// MatchToleration checks if the toleration matches tolerationToMatch. Tolerations are unique by <key,effect,operator,value>,
// if the two tolerations have same <key,effect,operator,value> combination, regard as they match.
// TODO: uniqueness check for tolerations in api validations.
func
(
t
*
Toleration
)
MatchToleration
(
tolerationToMatch
*
Toleration
)
bool
{
return
t
.
Key
==
tolerationToMatch
.
Key
&&
t
.
Effect
==
tolerationToMatch
.
Effect
&&
t
.
Operator
==
tolerationToMatch
.
Operator
&&
t
.
Value
==
tolerationToMatch
.
Value
}
vendor/BUILD
View file @
d9920c53
...
@@ -13903,16 +13903,16 @@ go_library(
...
@@ -13903,16 +13903,16 @@ go_library(
"k8s.io/client-go/pkg/api/doc.go",
"k8s.io/client-go/pkg/api/doc.go",
"k8s.io/client-go/pkg/api/field_constants.go",
"k8s.io/client-go/pkg/api/field_constants.go",
"k8s.io/client-go/pkg/api/json.go",
"k8s.io/client-go/pkg/api/json.go",
"k8s.io/client-go/pkg/api/methods.go",
"k8s.io/client-go/pkg/api/objectreference.go",
"k8s.io/client-go/pkg/api/ref.go",
"k8s.io/client-go/pkg/api/register.go",
"k8s.io/client-go/pkg/api/register.go",
"k8s.io/client-go/pkg/api/resource_helpers.go",
"k8s.io/client-go/pkg/api/resource_helpers.go",
"k8s.io/client-go/pkg/api/taint.go",
"k8s.io/client-go/pkg/api/toleration.go",
"k8s.io/client-go/pkg/api/types.go",
"k8s.io/client-go/pkg/api/types.go",
"k8s.io/client-go/pkg/api/zz_generated.deepcopy.go",
"k8s.io/client-go/pkg/api/zz_generated.deepcopy.go",
],
],
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = [
"//vendor:k8s.io/apimachinery/pkg/api/meta",
"//vendor:k8s.io/apimachinery/pkg/api/resource",
"//vendor:k8s.io/apimachinery/pkg/api/resource",
"//vendor:k8s.io/apimachinery/pkg/apimachinery/announced",
"//vendor:k8s.io/apimachinery/pkg/apimachinery/announced",
"//vendor:k8s.io/apimachinery/pkg/apimachinery/registered",
"//vendor:k8s.io/apimachinery/pkg/apimachinery/registered",
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment