func parseSelectorOrDie(s string) fields.Selector { selector, err := fields.ParseSelector(s) if err != nil { panic(err) } return selector }
func Convert_string_To_fields_Selector(in *string, out *fields.Selector, s conversion.Scope) error { selector, err := fields.ParseSelector(*in) if err != nil { return err } *out = selector return nil }
// VersionedParams will take the provided object, serialize it to a map[string][]string using the // implicit RESTClient API version and the default parameter codec, and then add those as parameters // to the request. Use this to provide versioned query parameters from client libraries. func (r *Request) VersionedParams(obj runtime.Object, codec runtime.ParameterCodec) *Request { if r.err != nil { return r } params, err := codec.EncodeParameters(obj, *r.content.GroupVersion) if err != nil { r.err = err return r } for k, v := range params { for _, value := range v { // TODO: Move it to setParam method, once we get rid of // FieldSelectorParam & LabelSelectorParam methods. if k == unversioned.LabelSelectorQueryParam(r.content.GroupVersion.String()) && value == "" { // Don't set an empty selector for backward compatibility. // Since there is no way to get the difference between empty // and unspecified string, we don't set it to avoid having // labelSelector= param in every request. continue } if k == unversioned.FieldSelectorQueryParam(r.content.GroupVersion.String()) { if len(value) == 0 { // Don't set an empty selector for backward compatibility. // Since there is no way to get the difference between empty // and unspecified string, we don't set it to avoid having // fieldSelector= param in every request. continue } // TODO: Filtering should be handled somewhere else. selector, err := fields.ParseSelector(value) if err != nil { r.err = fmt.Errorf("unparsable field selector: %v", err) return r } filteredSelector, err := selector.Transform( func(field, value string) (newField, newValue string, err error) { return fieldMappings.filterField(r.content.GroupVersion, r.resource, field, value) }) if err != nil { r.err = fmt.Errorf("untransformable field selector: %v", err) return r } value = filteredSelector.String() } r.setParam(k, value) } } return r }
func validateFields(a, b string) bool { sA, _ := fields.ParseSelector(a) sB, _ := fields.ParseSelector(b) return sA.String() == sB.String() }