コード例 #1
0
ファイル: conversion.go プロジェクト: abhgupta/origin
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)
	}
}
コード例 #2
0
ファイル: strategy.go プロジェクト: abhgupta/origin
// 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.EgressNetworkPolicy)
		if !ok {
			return false, fmt.Errorf("not an EgressNetworkPolicy")
		}
		fields := api.EgressNetworkPolicyToSelectableFields(network)
		return label.Matches(labels.Set(network.Labels)) && field.Matches(fields), nil
	})
}
コード例 #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{}),
	)

	testutil.CheckFieldLabelConversions(t, "v1", "EgressNetworkPolicy",
		// Ensure all currently returned labels are supported
		api.EgressNetworkPolicyToSelectableFields(&api.EgressNetworkPolicy{}),
	)
}
コード例 #4
0
ファイル: strategy.go プロジェクト: xgwang-zte/origin
// SelectableFields returns a field set that can be used for filter selection
func SelectableFields(obj *api.EgressNetworkPolicy) fields.Set {
	return api.EgressNetworkPolicyToSelectableFields(obj)
}