// convert_runtime_Object_To_runtime_RawExtension attempts to convert runtime.Objects to the appropriate target.
199790
func convert_runtime_Object_To_runtime_RawExtension(in *runtime.Object, out *runtime.RawExtension, s conversion.Scope) error {
	return apihelpers.Convert_runtime_Object_To_runtime_RawExtension(internal.Scheme, in, out, s)
}
418462
func AsVersionedObjects(infos []*Info, version string, encoder runtime.Encoder) ([]runtime.Object, error) {
	objects := []runtime.Object{}
	for _, info := range infos {
		if info.Object == nil {
			continue
		}

		// TODO: use info.VersionedObject as the value?

		// objects that are not part of api.Scheme must be converted to JSON
		// TODO: convert to map[string]interface{}, attach to runtime.Unknown?
		if len(version) > 0 {
			if _, err := api.Scheme.ObjectKind(info.Object); runtime.IsNotRegisteredError(err) {
				// TODO: ideally this would encode to version, but we don't expose multiple codecs here.
				data, err := runtime.Encode(encoder, info.Object)
				if err != nil {
					return nil, err
				}
				objects = append(objects, &runtime.Unknown{RawJSON: data})
				continue
			}
		}

		converted, err := tryConvert(info.Mapping.ObjectConvertor, info.Object, version, info.Mapping.GroupVersionKind.GroupVersion().String())
		if err != nil {
			return nil, err
		}
		objects = append(objects, converted)
	}
	return objects, nil
}
1077824
func (c *unstructuredConverter) FromUnstructured(u map[string]interface{}, obj interface{}) error {
	t := reflect.TypeOf(obj)
	value := reflect.ValueOf(obj)
	if t.Kind() != reflect.Ptr || value.IsNil() {
		return fmt.Errorf("FromUnstructured requires a non-nil pointer to an object, got %v", t)
	}
	err := fromUnstructured(reflect.ValueOf(u), value.Elem())
	if c.mismatchDetection {
		newObj := reflect.New(t.Elem()).Interface()
		newErr := fromUnstructuredViaJSON(u, newObj)
		if (err != nil) != (newErr != nil) {
			klog.Fatalf("FromUnstructured unexpected error for %v: error: %v", u, err)
		}
		if err == nil && !c.comparison.DeepEqual(obj, newObj) {
			klog.Fatalf("FromUnstructured mismatch\nobj1: %#v\nobj2: %#v", obj, newObj)
		}
	}
	return err
}
440517
func (w *wrapper) RawCopy() Configuration {
	w.mut.Lock()
	defer w.mut.Unlock()
	return w.cfg.Copy()
}
708661
func (c unsafeObjectConvertor) ConvertToVersion(in Object, outVersion GroupVersioner) (Object, error) {
	return c.Scheme.UnsafeConvertToVersion(in, outVersion)
}
675299
func ConvertType(scheme *runtime.Scheme, in, out runtime.Object) error {
	in = in.DeepCopyObject()
	if err := scheme.Convert(in, out, nil); err != nil {
		return err
	}
	gvkOut := out.GetObjectKind().GroupVersionKind()
	if gvkOut.Kind == "" || gvkOut.Version == "" { // Group can be empty
		// API machinery discards TypeMeta for typed objects. This is annoying.
		gvks, _, err := scheme.ObjectKinds(in)
		if err != nil {
			return err
		}
		out.GetObjectKind().SetGroupVersionKind(gvks[0])
	}
	return nil
}
246429
func Convert_node_RuntimeClassList_To_v1alpha1_RuntimeClassList(in *node.RuntimeClassList, out *v1alpha1.RuntimeClassList, s conversion.Scope) error {
	return autoConvert_node_RuntimeClassList_To_v1alpha1_RuntimeClassList(in, out, s)
}
889627
func (f CodecFactory) SerializerForFileExtension(extension string) (runtime.Serializer, bool) {
	for _, s := range f.serializers {
		for _, ext := range s.FileExtensions {
			if extension == ext {
				return s.Serializer, true
			}
		}
	}
	return nil, false
}
868144
func (converter PatternToListConverter) Convert(value interface{}, item AttributeAccessor) (interface{}, error) {
	result := []string{}
	i := 0
	for {
		key := AttributeExpression(strings.Replace(converter.pattern, "?", strconv.Itoa(i), 1))
		if v := item.Get(key); v != nil {
			result = append(result, v.(string))
		} else {
			break
		}
		i++
	}
	return result, nil
}
1364390
func Convert(obj interface{}) (url.Values, error) {
	result := url.Values{}
	if obj == nil {
		return result, nil
	}
	var sv reflect.Value
	switch reflect.TypeOf(obj).Kind() {
	case reflect.Ptr, reflect.Interface:
		sv = reflect.ValueOf(obj).Elem()
	default:
		return nil, fmt.Errorf("expecting a pointer or interface")
	}
	st := sv.Type()
	if !isStructKind(st.Kind()) {
		return nil, fmt.Errorf("expecting a pointer to a struct")
	}

	// Check all object fields
	convertStruct(result, st, sv)

	return result, nil
}
440284
func (t *Template) Raw() (*rawTemplate, error) {
	var out rawTemplate

	out.MinVersion = t.MinVersion
	out.Description = t.Description

	for k, v := range t.Comments {
		out.Comments = append(out.Comments, map[string]string{k: v})
	}

	for _, b := range t.Builders {
		out.Builders = append(out.Builders, b)
	}

	for _, p := range t.Provisioners {
		out.Provisioners = append(out.Provisioners, p)
	}

	for _, pp := range t.PostProcessors {
		out.PostProcessors = append(out.PostProcessors, pp)
	}

	for _, v := range t.SensitiveVariables {
		out.SensitiveVariables = append(out.SensitiveVariables, v.Key)
	}

	for k, v := range t.Variables {
		if out.Variables == nil {
			out.Variables = make(map[string]interface{})
		}

		out.Variables[k] = v
	}

	if t.Push.Name != "" {
		b, _ := json.Marshal(t.Push)

		var m map[string]interface{}
		_ = json.Unmarshal(b, &m)

		out.Push = m
	}

	return &out, nil
}
823537
func ExtractList(obj runtime.Object) ([]runtime.Object, error) {
	itemsPtr, err := GetItemsPtr(obj)
	if err != nil {
		return nil, err
	}
	items, err := conversion.EnforcePtr(itemsPtr)
	if err != nil {
		return nil, err
	}
	list := make([]runtime.Object, items.Len())
	for i := range list {
		raw := items.Index(i)
		switch item := raw.Interface().(type) {
		case runtime.Object:
			list[i] = item
		case runtime.RawExtension:
			list[i] = &runtime.Unknown{
				RawJSON: item.RawJSON,
			}
		default:
			var found bool
			if list[i], found = raw.Addr().Interface().(runtime.Object); !found {
				return nil, fmt.Errorf("%v: item[%v]: Expected object, got %#v(%s)", obj, i, raw.Interface(), raw.Kind())
			}
		}
	}
	return list, nil
}
1142522
func (f *CustomUplinkFunctions) convert(fields map[string]interface{}, port uint8) (map[string]interface{}, error) {
	if f.Converter == "" {
		return fields, nil
	}

	env := map[string]interface{}{
		"fields": fields,
		"port":   port,
	}

	code := fmt.Sprintf(`
		%s;
		Converter(fields, port)
	`, f.Converter)

	value, err := functions.RunCode("Converter", code, env, timeOut, f.Logger)
	if err != nil {
		return nil, err
	}

	m, ok := value.(map[string]interface{})
	if !ok {
		return nil, errors.NewErrInvalidArgument("Converter", "does not return an object")
	}

	return m, nil
}
720597
func ConvertPortBindings(portBindings []types.PortBinding) ([]json.RawMessage, error) {
	var pbs []json.RawMessage

	// Enumerate through the port bindings specified by the user and convert
	// them into the internal structure matching the JSON blob that can be
	// understood by the HCS.
	for _, elem := range portBindings {
		proto := strings.ToUpper(elem.Proto.String())
		if proto != "TCP" && proto != "UDP" {
			return nil, fmt.Errorf("invalid protocol %s", elem.Proto.String())
		}

		if elem.HostPort != elem.HostPortEnd {
			return nil, fmt.Errorf("Windows does not support more than one host port in NAT settings")
		}

		if len(elem.HostIP) != 0 {
			return nil, fmt.Errorf("Windows does not support host IP addresses in NAT settings")
		}

		encodedPolicy, err := json.Marshal(hcsshim.NatPolicy{
			Type:         "NAT",
			ExternalPort: elem.HostPort,
			InternalPort: elem.Port,
			Protocol:     elem.Proto.String(),
		})

		if err != nil {
			return nil, err
		}
		pbs = append(pbs, encodedPolicy)
	}
	return pbs, nil
}
1112557
func sliceOrMap2ExpandedSlice(value interface{}) []string {
	var result []string
	expandedStringOrPanic := func(v interface{}) string {
		switch concreteValue := v.(type) {
		case []interface{}: // YAML or JSON
			panic(StatusError{fmt.Errorf("unknown type: %v", v), 65})
		case map[interface{}]interface{}: // YAML
			panic(StatusError{fmt.Errorf("unknown type: %v", v), 65})
		case map[string]interface{}: // JSON
			panic(StatusError{fmt.Errorf("unknown type: %v", v), 65})
		default:
			return expandEnv(fmt.Sprintf("%v", concreteValue))
		}
	}
	if value != nil {
		switch concreteValue := value.(type) {
		case []interface{}: // YAML or JSON: array
			for _, v := range concreteValue {
				result = append(result, expandedStringOrPanic(v))
			}
		case map[interface{}]interface{}: // YAML: hash
			for k, v := range concreteValue {
				result = append(result, expandedStringOrPanic(k)+"="+expandedStringOrPanic(v))
			}
		case map[string]interface{}: // JSON: hash
			for k, v := range concreteValue {
				result = append(result, expandEnv(k)+"="+expandedStringOrPanic(v))
			}
		default:
			panic(StatusError{fmt.Errorf("unknown type: %v", value), 65})
		}
	}
	return result
}
182718
func (obj *Global) EngineVersionRaw(ctx context.Context) (json.RawMessage, error) {
	result := &struct {
		Version json.RawMessage	`json:"qVersion"`
	} {}
	err := obj.rpc(ctx, "EngineVersion", result)
	return result.Version, err 
}
857435
func RuntimeToUnstructured(obj runtime.Object) (*unstructured.Unstructured, error) {
	gvk := obj.GetObjectKind().GroupVersionKind()
	if gvk.Kind == "" || gvk.Version == "" { // Group can be empty
		return nil, errors.Errorf("cannot convert %T to Unstructured: object Kind and/or object Version is empty", obj)
	}
	u, err := runtime.DefaultUnstructuredConverter.ToUnstructured(obj.DeepCopyObject())
	if err != nil {
		return nil, errors.WithStack(err)
	}
	return &unstructured.Unstructured{
		Object: u,
	}, nil
}