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
790a8bbd
Commit
790a8bbd
authored
Mar 09, 2015
by
nikhiljindal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding conversion functions for event field selectors
parent
07c20356
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
11 deletions
+75
-11
conversion.go
pkg/api/v1beta1/conversion.go
+22
-0
conversion.go
pkg/api/v1beta2/conversion.go
+22
-0
conversion.go
pkg/api/v1beta3/conversion.go
+24
-5
scheme.go
pkg/runtime/scheme.go
+7
-6
No files found.
pkg/api/v1beta1/conversion.go
View file @
790a8bbd
...
@@ -1398,4 +1398,26 @@ func init() {
...
@@ -1398,4 +1398,26 @@ func init() {
// If one of the conversion functions is malformed, detect it immediately.
// If one of the conversion functions is malformed, detect it immediately.
panic
(
err
)
panic
(
err
)
}
}
err
=
newer
.
Scheme
.
AddFieldLabelConversionFunc
(
"v1beta1"
,
"events"
,
func
(
label
,
value
string
)
(
string
,
string
,
error
)
{
switch
label
{
case
"involvedObject.kind"
,
"involvedObject.namespace"
,
"involvedObject.uid"
,
"involvedObject.apiVersion"
,
"involvedObject.resourceVersion"
,
"involvedObject.fieldPath"
,
"reason"
,
"source"
:
return
label
,
value
,
nil
case
"involvedObject.id"
:
return
"involvedObject.name"
,
value
,
nil
default
:
return
""
,
""
,
fmt
.
Errorf
(
"field label not supported: %s"
,
label
)
}
})
if
err
!=
nil
{
// If one of the conversion functions is malformed, detect it immediately.
panic
(
err
)
}
}
}
pkg/api/v1beta2/conversion.go
View file @
790a8bbd
...
@@ -1314,4 +1314,26 @@ func init() {
...
@@ -1314,4 +1314,26 @@ func init() {
// If one of the conversion functions is malformed, detect it immediately.
// If one of the conversion functions is malformed, detect it immediately.
panic
(
err
)
panic
(
err
)
}
}
err
=
newer
.
Scheme
.
AddFieldLabelConversionFunc
(
"v1beta2"
,
"events"
,
func
(
label
,
value
string
)
(
string
,
string
,
error
)
{
switch
label
{
case
"involvedObject.kind"
,
"involvedObject.namespace"
,
"involvedObject.uid"
,
"involvedObject.apiVersion"
,
"involvedObject.resourceVersion"
,
"involvedObject.fieldPath"
,
"reason"
,
"source"
:
return
label
,
value
,
nil
case
"involvedObject.id"
:
return
"involvedObject.name"
,
value
,
nil
default
:
return
""
,
""
,
fmt
.
Errorf
(
"field label not supported: %s"
,
label
)
}
})
if
err
!=
nil
{
// If one of the conversion functions is malformed, detect it immediately.
panic
(
err
)
}
}
}
pkg/api/v1beta3/conversion.go
View file @
790a8bbd
...
@@ -27,11 +27,30 @@ func init() {
...
@@ -27,11 +27,30 @@ func init() {
err
:=
newer
.
Scheme
.
AddFieldLabelConversionFunc
(
"v1beta3"
,
"pods"
,
err
:=
newer
.
Scheme
.
AddFieldLabelConversionFunc
(
"v1beta3"
,
"pods"
,
func
(
label
,
value
string
)
(
string
,
string
,
error
)
{
func
(
label
,
value
string
)
(
string
,
string
,
error
)
{
switch
label
{
switch
label
{
case
"name"
:
case
"name"
,
fallthrough
"status.phase"
,
case
"status.phase"
:
"spec.host"
:
fallthrough
return
label
,
value
,
nil
case
"spec.host"
:
default
:
return
""
,
""
,
fmt
.
Errorf
(
"field label not supported: %s"
,
label
)
}
})
if
err
!=
nil
{
// If one of the conversion functions is malformed, detect it immediately.
panic
(
err
)
}
err
=
newer
.
Scheme
.
AddFieldLabelConversionFunc
(
"v1beta3"
,
"events"
,
func
(
label
,
value
string
)
(
string
,
string
,
error
)
{
switch
label
{
case
"involvedObject.kind"
,
"involvedObject.namespace"
,
"involvedObject.name"
,
"involvedObject.uid"
,
"involvedObject.apiVersion"
,
"involvedObject.resourceVersion"
,
"involvedObject.fieldPath"
,
"reason"
,
"source"
:
return
label
,
value
,
nil
return
label
,
value
,
nil
default
:
default
:
return
""
,
""
,
fmt
.
Errorf
(
"field label not supported: %s"
,
label
)
return
""
,
""
,
fmt
.
Errorf
(
"field label not supported: %s"
,
label
)
...
...
pkg/runtime/scheme.go
View file @
790a8bbd
...
@@ -322,13 +322,14 @@ func (s *Scheme) Convert(in, out interface{}) error {
...
@@ -322,13 +322,14 @@ func (s *Scheme) Convert(in, out interface{}) error {
// Converts the given field label and value for an apiResource field selector from
// Converts the given field label and value for an apiResource field selector from
// versioned representation to an unversioned one.
// versioned representation to an unversioned one.
func
(
s
*
Scheme
)
ConvertFieldLabel
(
version
,
apiResource
,
label
,
value
string
)
(
string
,
string
,
error
)
{
func
(
s
*
Scheme
)
ConvertFieldLabel
(
version
,
apiResource
,
label
,
value
string
)
(
string
,
string
,
error
)
{
if
typeFuncMap
,
ok
:=
s
.
fieldLabelConversionFuncs
[
version
];
ok
{
if
s
.
fieldLabelConversionFuncs
[
version
]
==
nil
{
if
conversionFunc
,
ok
:=
typeFuncMap
[
apiResource
];
ok
{
return
""
,
""
,
fmt
.
Errorf
(
"No conversion function found for version: %s"
,
version
)
return
conversionFunc
(
label
,
value
)
}
}
conversionFunc
,
ok
:=
s
.
fieldLabelConversionFuncs
[
version
][
apiResource
]
if
!
ok
{
return
""
,
""
,
fmt
.
Errorf
(
"No conversion function found for version %s and api resource %s"
,
version
,
apiResource
)
}
}
// Don't fail on types we haven't added conversion funcs for yet.
return
conversionFunc
(
label
,
value
)
return
label
,
value
,
nil
}
}
// ConvertToVersion attempts to convert an input object to its matching Kind in another
// ConvertToVersion attempts to convert an input object to its matching Kind in another
...
...
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