-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding converter functions to convert field label selectors to internal version before matching #4575
Adding converter functions to convert field label selectors to internal version before matching #4575
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1206,4 +1206,26 @@ func init() { | |
// If one of the conversion functions is malformed, detect it immediately. | ||
panic(err) | ||
} | ||
|
||
// Add field conversion funcs. | ||
err = newer.Scheme.AddFieldLabelConversionFunc("v1beta2", "pods", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check this error value :) (also in v1beta1) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. v1beta1 was checking it already :) |
||
func(label, value string) (string, string, error) { | ||
switch label { | ||
case "name": | ||
return "name", value, nil | ||
case "DesiredState.Host": | ||
return "Status.Host", value, nil | ||
case "DesiredState.Status": | ||
podStatus := PodStatus(value) | ||
var internalValue newer.PodPhase | ||
newer.Scheme.Convert(&podStatus, &internalValue) | ||
return "Status.Phase", string(internalValue), 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) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
Copyright 2014 Google Inc. All rights reserved. | ||
|
||
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 v1beta3 | ||
|
||
import ( | ||
"fmt" | ||
|
||
newer "github.com/GoogleCloudPlatform/kubernetes/pkg/api" | ||
) | ||
|
||
func init() { | ||
// Add field conversion funcs. | ||
err := newer.Scheme.AddFieldLabelConversionFunc("v1beta3", "pods", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this converter necessary in v1beta3? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. We need a conversion func from all external versions to internal versions. |
||
func(label, value string) (string, string, error) { | ||
switch label { | ||
case "name": | ||
fallthrough | ||
case "Status.Phase": | ||
fallthrough | ||
case "Status.Host": | ||
return label, 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) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I convinced Brian that we don't need to sprinkle TODOs for this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks :)