Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 3b34cb9

Browse files
committed
Merge pull request #76 from carmark/watch
add 'network' watch selector('metadata.name')
2 parents e4c3602 + 0b5092f commit 3b34cb9

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

pkg/api/v1/conversion.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,20 @@ func addConversionFuncs(scheme *runtime.Scheme) {
200200
// If one of the conversion functions is malformed, detect it immediately.
201201
panic(err)
202202
}
203+
err = api.Scheme.AddFieldLabelConversionFunc("v1", "Network",
204+
func(label, value string) (string, string, error) {
205+
switch label {
206+
case "metadata.name",
207+
"status.phase":
208+
return label, value, nil
209+
default:
210+
return "", "", fmt.Errorf("field label not supported: %s", label)
211+
}
212+
})
213+
if err != nil {
214+
// If one of the conversion functions is malformed, detect it immediately.
215+
panic(err)
216+
}
203217
}
204218

205219
func Convert_api_ReplicationControllerSpec_To_v1_ReplicationControllerSpec(in *api.ReplicationControllerSpec, out *ReplicationControllerSpec, s conversion.Scope) error {

pkg/registry/network/rest.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func MatchNetwork(label labels.Selector, field fields.Selector) generic.Matcher
119119
// NetworkToSelectableFields returns a label set that represents the object
120120
func NetworkToSelectableFields(network *api.Network) labels.Set {
121121
return labels.Set{
122-
"name": network.Name,
123-
"status.phase": string(network.Status.Phase),
122+
"metadata.name": network.Name,
123+
"status.phase": string(network.Status.Phase),
124124
}
125125
}

0 commit comments

Comments
 (0)