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
cdded4f0
Commit
cdded4f0
authored
Nov 26, 2015
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use VersionedParams in "extensions" client.
parent
1dc513d3
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
45 additions
and
48 deletions
+45
-48
conversion.go
pkg/api/conversion.go
+28
-2
register.go
pkg/apis/extensions/register.go
+4
-0
register.go
pkg/apis/extensions/v1beta1/register.go
+4
-0
listwatch.go
pkg/client/cache/listwatch.go
+2
-3
listwatch_test.go
pkg/client/cache/listwatch_test.go
+1
-1
daemon_sets.go
pkg/client/unversioned/daemon_sets.go
+2
-2
deployment.go
pkg/client/unversioned/deployment.go
+1
-2
helper.go
pkg/client/unversioned/helper.go
+0
-9
horizontalpodautoscaler.go
pkg/client/unversioned/horizontalpodautoscaler.go
+1
-2
ingress.go
pkg/client/unversioned/ingress.go
+1
-2
jobs.go
pkg/client/unversioned/jobs.go
+1
-2
request.go
pkg/client/unversioned/request.go
+0
-13
request_test.go
pkg/client/unversioned/request_test.go
+0
-10
No files found.
pkg/api/conversion.go
View file @
cdded4f0
...
...
@@ -32,8 +32,12 @@ var Codec = runtime.CodecFor(Scheme, "")
func
init
()
{
Scheme
.
AddDefaultingFuncs
(
func
(
obj
*
unversioned
.
ListOptions
)
{
obj
.
LabelSelector
=
unversioned
.
LabelSelector
{
labels
.
Everything
()}
obj
.
FieldSelector
=
unversioned
.
FieldSelector
{
fields
.
Everything
()}
if
obj
.
LabelSelector
.
Selector
==
nil
{
obj
.
LabelSelector
=
unversioned
.
LabelSelector
{
labels
.
Everything
()}
}
if
obj
.
FieldSelector
.
Selector
==
nil
{
obj
.
FieldSelector
=
unversioned
.
FieldSelector
{
fields
.
Everything
()}
}
},
// TODO: see about moving this into v1/defaults.go
func
(
obj
*
PodExecOptions
)
{
...
...
@@ -135,6 +139,28 @@ func init() {
*
out
=
in
.
Selector
.
String
()
return
nil
},
func
(
in
*
unversioned
.
LabelSelector
,
out
*
unversioned
.
LabelSelector
,
s
conversion
.
Scope
)
error
{
if
in
.
Selector
==
nil
{
return
nil
}
selector
,
err
:=
labels
.
Parse
(
in
.
Selector
.
String
())
if
err
!=
nil
{
return
err
}
out
.
Selector
=
selector
return
nil
},
func
(
in
*
unversioned
.
FieldSelector
,
out
*
unversioned
.
FieldSelector
,
s
conversion
.
Scope
)
error
{
if
in
.
Selector
==
nil
{
return
nil
}
selector
,
err
:=
fields
.
ParseSelector
(
in
.
Selector
.
String
())
if
err
!=
nil
{
return
err
}
out
.
Selector
=
selector
return
nil
},
func
(
in
*
resource
.
Quantity
,
out
*
resource
.
Quantity
,
s
conversion
.
Scope
)
error
{
// Cannot deep copy these, because inf.Dec has unexported fields.
*
out
=
*
in
.
Copy
()
...
...
pkg/apis/extensions/register.go
View file @
cdded4f0
...
...
@@ -57,6 +57,10 @@ func addKnownTypes() {
&
Ingress
{},
&
IngressList
{},
)
// Register Unversioned types
// TODO this should not be done here
api
.
Scheme
.
AddKnownTypes
(
SchemeGroupVersion
,
&
unversioned
.
ListOptions
{})
}
func
(
*
ClusterAutoscaler
)
IsAnAPIObject
()
{}
...
...
pkg/apis/extensions/v1beta1/register.go
View file @
cdded4f0
...
...
@@ -55,6 +55,10 @@ func addKnownTypes() {
&
Ingress
{},
&
IngressList
{},
)
// Register Unversioned types
// TODO this should not be done here
api
.
Scheme
.
AddKnownTypes
(
SchemeGroupVersion
,
&
unversioned
.
ListOptions
{})
}
func
(
*
ClusterAutoscaler
)
IsAnAPIObject
()
{}
...
...
pkg/client/cache/listwatch.go
View file @
cdded4f0
...
...
@@ -19,6 +19,7 @@ package cache
import
(
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
client
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/fields"
...
...
@@ -60,9 +61,7 @@ func NewListWatchFromClient(c Getter, resource string, namespace string, fieldSe
Prefix
(
"watch"
)
.
Namespace
(
namespace
)
.
Resource
(
resource
)
.
// TODO: Use VersionedParams once this is supported for non v1 API.
Param
(
"resourceVersion"
,
options
.
ResourceVersion
)
.
TimeoutSeconds
(
timeoutFromListOptions
(
options
))
.
VersionedParams
(
&
options
,
api
.
Scheme
)
.
FieldsSelectorParam
(
fieldSelector
)
.
Watch
()
}
...
...
pkg/client/cache/listwatch_test.go
View file @
cdded4f0
...
...
@@ -117,7 +117,7 @@ func TestListWatchesCanWatch(t *testing.T) {
{
location
:
buildLocation
(
testapi
.
Default
.
ResourcePathWithPrefix
(
"watch"
,
"nodes"
,
api
.
NamespaceAll
,
""
),
buildQueryValues
(
url
.
Values
{
"resourceVersion"
:
[]
string
{
""
}
})),
buildQueryValues
(
url
.
Values
{})),
rv
:
""
,
resource
:
"nodes"
,
namespace
:
api
.
NamespaceAll
,
...
...
pkg/client/unversioned/daemon_sets.go
View file @
cdded4f0
...
...
@@ -17,6 +17,7 @@ limitations under the License.
package
unversioned
import
(
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/fields"
...
...
@@ -97,8 +98,7 @@ func (c *daemonSets) Watch(label labels.Selector, field fields.Selector, opts un
Prefix
(
"watch"
)
.
Namespace
(
c
.
ns
)
.
Resource
(
"daemonsets"
)
.
Param
(
"resourceVersion"
,
opts
.
ResourceVersion
)
.
TimeoutSeconds
(
TimeoutFromListOptions
(
opts
))
.
VersionedParams
(
&
opts
,
api
.
Scheme
)
.
LabelsSelectorParam
(
label
)
.
FieldsSelectorParam
(
field
)
.
Watch
()
...
...
pkg/client/unversioned/deployment.go
View file @
cdded4f0
...
...
@@ -107,8 +107,7 @@ func (c *deployments) Watch(label labels.Selector, field fields.Selector, opts u
Prefix
(
"watch"
)
.
Namespace
(
c
.
ns
)
.
Resource
(
"deployments"
)
.
Param
(
"resourceVersion"
,
opts
.
ResourceVersion
)
.
TimeoutSeconds
(
TimeoutFromListOptions
(
opts
))
.
VersionedParams
(
&
opts
,
api
.
Scheme
)
.
LabelsSelectorParam
(
label
)
.
FieldsSelectorParam
(
field
)
.
Watch
()
...
...
pkg/client/unversioned/helper.go
View file @
cdded4f0
...
...
@@ -568,12 +568,3 @@ func DefaultKubernetesUserAgent() string {
version
=
seg
[
0
]
return
fmt
.
Sprintf
(
"%s/%s (%s/%s) kubernetes/%s"
,
path
.
Base
(
os
.
Args
[
0
]),
version
,
gruntime
.
GOOS
,
gruntime
.
GOARCH
,
commit
)
}
// TimeoutFromListOptions returns timeout to be set via TimeoutSeconds() method
// based on given options.
func
TimeoutFromListOptions
(
options
unversioned
.
ListOptions
)
time
.
Duration
{
if
options
.
TimeoutSeconds
!=
nil
{
return
time
.
Duration
(
*
options
.
TimeoutSeconds
)
*
time
.
Second
}
return
0
}
pkg/client/unversioned/horizontalpodautoscaler.go
View file @
cdded4f0
...
...
@@ -109,8 +109,7 @@ func (c *horizontalPodAutoscalers) Watch(label labels.Selector, field fields.Sel
Prefix
(
"watch"
)
.
Namespace
(
c
.
ns
)
.
Resource
(
"horizontalPodAutoscalers"
)
.
Param
(
"resourceVersion"
,
opts
.
ResourceVersion
)
.
TimeoutSeconds
(
TimeoutFromListOptions
(
opts
))
.
VersionedParams
(
&
opts
,
api
.
Scheme
)
.
LabelsSelectorParam
(
label
)
.
FieldsSelectorParam
(
field
)
.
Watch
()
...
...
pkg/client/unversioned/ingress.go
View file @
cdded4f0
...
...
@@ -99,8 +99,7 @@ func (c *ingress) Watch(label labels.Selector, field fields.Selector, opts unver
Prefix
(
"watch"
)
.
Namespace
(
c
.
ns
)
.
Resource
(
"ingresses"
)
.
Param
(
"resourceVersion"
,
opts
.
ResourceVersion
)
.
TimeoutSeconds
(
TimeoutFromListOptions
(
opts
))
.
VersionedParams
(
&
opts
,
api
.
Scheme
)
.
LabelsSelectorParam
(
label
)
.
FieldsSelectorParam
(
field
)
.
Watch
()
...
...
pkg/client/unversioned/jobs.go
View file @
cdded4f0
...
...
@@ -103,8 +103,7 @@ func (c *jobs) Watch(label labels.Selector, field fields.Selector, opts unversio
Prefix
(
"watch"
)
.
Namespace
(
c
.
ns
)
.
Resource
(
"jobs"
)
.
Param
(
"resourceVersion"
,
opts
.
ResourceVersion
)
.
TimeoutSeconds
(
TimeoutFromListOptions
(
opts
))
.
VersionedParams
(
&
opts
,
api
.
Scheme
)
.
LabelsSelectorParam
(
label
)
.
FieldsSelectorParam
(
field
)
.
Watch
()
...
...
pkg/client/unversioned/request.go
View file @
cdded4f0
...
...
@@ -464,19 +464,6 @@ func (r *Request) Timeout(d time.Duration) *Request {
return
r
}
// Timeout makes the request use the given duration as a timeout. Sets the "timeoutSeconds"
// parameter.
func
(
r
*
Request
)
TimeoutSeconds
(
d
time
.
Duration
)
*
Request
{
if
r
.
err
!=
nil
{
return
r
}
if
d
!=
0
{
timeout
:=
int64
(
d
.
Seconds
())
r
.
Param
(
"timeoutSeconds"
,
strconv
.
FormatInt
(
timeout
,
10
))
}
return
r
}
// Body makes the request use obj as the body. Optional.
// If obj is a string, try to read a file of that name.
// If obj is a []byte, send it directly.
...
...
pkg/client/unversioned/request_test.go
View file @
cdded4f0
...
...
@@ -176,16 +176,6 @@ func TestRequestParam(t *testing.T) {
}
}
func
TestTimeoutSeconds
(
t
*
testing
.
T
)
{
r
:=
&
Request
{}
r
.
TimeoutSeconds
(
time
.
Duration
(
5
*
time
.
Second
))
if
!
reflect
.
DeepEqual
(
r
.
params
,
url
.
Values
{
"timeoutSeconds"
:
[]
string
{
"5"
},
})
{
t
.
Errorf
(
"invalid timeoutSeconds parameter: %#v"
,
r
)
}
}
func
TestRequestVersionedParams
(
t
*
testing
.
T
)
{
r
:=
(
&
Request
{
apiVersion
:
"v1"
})
.
Param
(
"foo"
,
"a"
)
if
!
reflect
.
DeepEqual
(
r
.
params
,
url
.
Values
{
"foo"
:
[]
string
{
"a"
}})
{
...
...
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