Exemplo n.º 1
0
func addConversionFuncs(scheme *runtime.Scheme) {
	if err := scheme.AddFieldLabelConversionFunc("v1", "ClusterNetwork",
		oapi.GetFieldLabelConversionFunc(api.ClusterNetworkToSelectableFields(&api.ClusterNetwork{}), nil),
	); err != nil {
		panic(err)
	}

	if err := scheme.AddFieldLabelConversionFunc("v1", "HostSubnet",
		oapi.GetFieldLabelConversionFunc(api.HostSubnetToSelectableFields(&api.HostSubnet{}), nil),
	); err != nil {
		panic(err)
	}

	if err := scheme.AddFieldLabelConversionFunc("v1", "NetNamespace",
		oapi.GetFieldLabelConversionFunc(api.NetNamespaceToSelectableFields(&api.NetNamespace{}), nil),
	); err != nil {
		panic(err)
	}

	if err := scheme.AddFieldLabelConversionFunc("v1", "EgressNetworkPolicy",
		oapi.GetFieldLabelConversionFunc(api.EgressNetworkPolicyToSelectableFields(&api.EgressNetworkPolicy{}), nil),
	); err != nil {
		panic(err)
	}
}
Exemplo n.º 2
0
// Matcher returns a generic matcher for a given label and field selector.
func Matcher(label labels.Selector, field fields.Selector) generic.Matcher {
	return generic.MatcherFunc(func(obj runtime.Object) (bool, error) {
		network, ok := obj.(*api.ClusterNetwork)
		if !ok {
			return false, fmt.Errorf("not a ClusterNetwork")
		}
		fields := api.ClusterNetworkToSelectableFields(network)
		return label.Matches(labels.Set(network.Labels)) && field.Matches(fields), nil
	})
}
Exemplo n.º 3
0
func TestFieldSelectorConversions(t *testing.T) {
	testutil.CheckFieldLabelConversions(t, "v1", "ClusterNetwork",
		// Ensure all currently returned labels are supported
		api.ClusterNetworkToSelectableFields(&api.ClusterNetwork{}),
	)

	testutil.CheckFieldLabelConversions(t, "v1", "HostSubnet",
		// Ensure all currently returned labels are supported
		api.HostSubnetToSelectableFields(&api.HostSubnet{}),
	)

	testutil.CheckFieldLabelConversions(t, "v1", "NetNamespace",
		// Ensure all currently returned labels are supported
		api.NetNamespaceToSelectableFields(&api.NetNamespace{}),
	)

}
Exemplo n.º 4
0
func init() {
	if err := kapi.Scheme.AddFieldLabelConversionFunc("v1", "ClusterNetwork",
		oapi.GetFieldLabelConversionFunc(api.ClusterNetworkToSelectableFields(&api.ClusterNetwork{}), nil),
	); err != nil {
		panic(err)
	}

	if err := kapi.Scheme.AddFieldLabelConversionFunc("v1", "HostSubnet",
		oapi.GetFieldLabelConversionFunc(api.HostSubnetToSelectableFields(&api.HostSubnet{}), nil),
	); err != nil {
		panic(err)
	}

	if err := kapi.Scheme.AddFieldLabelConversionFunc("v1", "NetNamespace",
		oapi.GetFieldLabelConversionFunc(api.NetNamespaceToSelectableFields(&api.NetNamespace{}), nil),
	); err != nil {
		panic(err)
	}
}
Exemplo n.º 5
0
// SelectableFields returns a field set that can be used for filter selection
func SelectableFields(obj *api.ClusterNetwork) fields.Set {
	return api.ClusterNetworkToSelectableFields(obj)
}