예제 #1
0
파일: fake_events.go 프로젝트: jordic/k8s
func (c *FakeEvents) GetFieldSelector(involvedObjectName, involvedObjectNamespace, involvedObjectKind, involvedObjectUID *string) fields.Selector {
	action := GenericActionImpl{}
	action.Verb = "get-field-selector"
	action.Resource = "events"

	c.Fake.Invokes(action, nil)
	return fields.Everything()
}
예제 #2
0
파일: actions.go 프로젝트: jordic/k8s
func NewRootListAction(resource string, opts unversioned.ListOptions) ListActionImpl {
	action := ListActionImpl{}
	action.Verb = "list"
	action.Resource = resource
	labelSelector := opts.LabelSelector.Selector
	if labelSelector == nil {
		labelSelector = labels.Everything()
	}
	fieldSelector := opts.FieldSelector.Selector
	if fieldSelector == nil {
		fieldSelector = fields.Everything()
	}
	action.ListRestrictions = ListRestrictions{labelSelector, fieldSelector}

	return action
}
예제 #3
0
파일: actions.go 프로젝트: jordic/k8s
func NewRootWatchAction(resource string, opts unversioned.ListOptions) WatchActionImpl {
	action := WatchActionImpl{}
	action.Verb = "watch"
	action.Resource = resource
	labelSelector := opts.LabelSelector.Selector
	if labelSelector == nil {
		labelSelector = labels.Everything()
	}
	fieldSelector := opts.FieldSelector.Selector
	if fieldSelector == nil {
		fieldSelector = fields.Everything()
	}
	action.WatchRestrictions = WatchRestrictions{labelSelector, fieldSelector, opts.ResourceVersion}

	return action
}
예제 #4
0
파일: conversion.go 프로젝트: jordic/k8s
func init() {
	Scheme.AddDefaultingFuncs(
		func(obj *unversioned.ListOptions) {
			if obj.LabelSelector.Selector == nil {
				obj.LabelSelector = unversioned.LabelSelector{labels.Everything()}
			}
			if obj.FieldSelector.Selector == nil {
				obj.FieldSelector = unversioned.FieldSelector{fields.Everything()}
			}
		},
	)
	Scheme.AddConversionFuncs(
		func(in *unversioned.Time, out *unversioned.Time, s conversion.Scope) error {
			// Cannot deep copy these, because time.Time has unexported fields.
			*out = *in
			return nil
		},
		func(in *string, out *labels.Selector, s conversion.Scope) error {
			selector, err := labels.Parse(*in)
			if err != nil {
				return err
			}
			*out = selector
			return nil
		},
		func(in *string, out *fields.Selector, s conversion.Scope) error {
			selector, err := fields.ParseSelector(*in)
			if err != nil {
				return err
			}
			*out = selector
			return nil
		},
		func(in *labels.Selector, out *string, s conversion.Scope) error {
			if *in == nil {
				return nil
			}
			*out = (*in).String()
			return nil
		},
		func(in *fields.Selector, out *string, s conversion.Scope) error {
			if *in == nil {
				return nil
			}
			*out = (*in).String()
			return nil
		},
		func(in *string, out *unversioned.LabelSelector, s conversion.Scope) error {
			selector, err := labels.Parse(*in)
			if err != nil {
				return err
			}
			*out = unversioned.LabelSelector{selector}
			return nil
		},
		func(in *string, out *unversioned.FieldSelector, s conversion.Scope) error {
			selector, err := fields.ParseSelector(*in)
			if err != nil {
				return err
			}
			*out = unversioned.FieldSelector{selector}
			return nil
		},
		func(in *[]string, out *unversioned.LabelSelector, s conversion.Scope) error {
			selectorString := ""
			if len(*in) > 0 {
				selectorString = (*in)[0]
			}
			selector, err := labels.Parse(selectorString)
			if err != nil {
				return err
			}
			*out = unversioned.LabelSelector{selector}
			return nil
		},
		func(in *[]string, out *unversioned.FieldSelector, s conversion.Scope) error {
			selectorString := ""
			if len(*in) > 0 {
				selectorString = (*in)[0]
			}
			selector, err := fields.ParseSelector(selectorString)
			if err != nil {
				return err
			}
			*out = unversioned.FieldSelector{selector}
			return nil
		},
		func(in *unversioned.LabelSelector, out *string, s conversion.Scope) error {
			if in.Selector == nil {
				return nil
			}
			*out = in.Selector.String()
			return nil
		},
		func(in *unversioned.FieldSelector, out *string, s conversion.Scope) error {
			if in.Selector == nil {
				return nil
			}
			*out = in.Selector.String()
			return nil
		},
		func(in *unversioned.LabelSelector, out *unversioned.LabelSelector, s conversion.Scope) error {
			if in.Selector == nil {
				return nil
			}
			selector, err := labels.Parse(in.Selector.String())
			if err != nil {
				return err
			}
			out.Selector = selector
			return nil
		},
		func(in *unversioned.FieldSelector, out *unversioned.FieldSelector, s conversion.Scope) error {
			if in.Selector == nil {
				return nil
			}
			selector, err := fields.ParseSelector(in.Selector.String())
			if err != nil {
				return err
			}
			out.Selector = selector
			return nil
		},
		func(in *resource.Quantity, out *resource.Quantity, s conversion.Scope) error {
			// Cannot deep copy these, because inf.Dec has unexported fields.
			*out = *in.Copy()
			return nil
		},
	)
}