// keepOrDeleteNullInJsonPatch takes a json-encoded byte array and a boolean.
// It returns a filtered object and its corresponding json-encoded byte array.
// It is a wrapper of func keepOrDeleteNullInObj
18327
func keepOrDeleteNullInJsonPatch(patch []byte, keepNull bool) ([]byte, map[string]interface{}, error) {
	var patchMap map[string]interface{}
	err := json.Unmarshal(patch, &patchMap)
	if err != nil {
		return nil, nil, err
	}
	filteredMap, err := keepOrDeleteNullInObj(patchMap, keepNull)
	if err != nil {
		return nil, nil, err
	}
	o, err := json.Marshal(filteredMap)
	return o, filteredMap, err
}
1107173
func (r *BrokerResource) GetPatch(owner, slug string, id int) (string, error) {
	data := []byte{}
	// uri, err := url.Parse("https://api.bitbucket.org/1.0" + path)
	// https://bitbucket.org/!api/2.0/repositories/tdburke/test_mymysql/pullrequests/1/patch

	path := fmt.Sprintf("/repositories/tdburke/test_mymysql/pullrequests/1/patch")

	fmt.Println(path)

	if err := r.client.do("GET", path, nil, nil, &data); err != nil {
		fmt.Println("Get error:", err)
		return "", err
	}

	fmt.Println(data)

	if len(data) == 0 {
		return "", ErrNotFound
	}

	return "", nil
}
880590
func orderByBindingsChecker() ClauseHook {
	var f ClauseHook
	f = func(s *Statement, _ Symbol) (ClauseHook, error) {
		// Force working projection flush.
		outs := make(map[string]bool)
		for _, out := range s.OutputBindings() {
			outs[out] = true
		}
		seen, dups := make(map[string]bool), false
		for _, cfg := range s.orderBy {
			// Check there are no contradictions
			if b, ok := seen[cfg.Binding]; ok {
				if b != cfg.Desc {
					return nil, fmt.Errorf("inconsisting sorting direction for %q binding", cfg.Binding)
				}
				dups = true
			} else {
				seen[cfg.Binding] = cfg.Desc
			}
			// Check that the binding exist.
			if _, ok := outs[cfg.Binding]; !ok {
				return nil, fmt.Errorf("order by binding %q unknown; available bindings are %v", cfg.Binding, s.OutputBindings())
			}
		}
		// If dups exist rewrite the order by SortConfig.
		if dups {
			s.orderBy = table.SortConfig{}
			for b, d := range seen {
				s.orderBy = append(s.orderBy, table.SortConfig{{Binding: b, Desc: d}}...)
			}
		}
		return f, nil
	}
	return f
}
785323
func applyPatchToObject(
	defaulter runtime.ObjectDefaulter,
	originalMap map[string]interface{},
	patchMap map[string]interface{},
	objToUpdate runtime.Object,
	schemaReferenceObj runtime.Object,
) error {
	patchedObjMap, err := strategicpatch.StrategicMergeMapPatch(originalMap, patchMap, schemaReferenceObj)
	if err != nil {
		return interpretStrategicMergePatchError(err)
	}

	// Rather than serialize the patched map to JSON, then decode it to an object, we go directly from a map to an object
	if err := runtime.DefaultUnstructuredConverter.FromUnstructured(patchedObjMap, objToUpdate); err != nil {
		return err
	}
	// Decoding from JSON to a versioned object would apply defaults, so we do the same here
	defaulter.Default(objToUpdate)

	return nil
}
421140
func (_class PoolPatchClass) CleanOnHost(sessionID SessionRef, self PoolPatchRef, host HostRef) (_err error) {
	_method := "pool_patch.clean_on_host"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_selfArg, _err := convertPoolPatchRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), self)
	if _err != nil {
		return
	}
	_hostArg, _err := convertHostRefToXen(fmt.Sprintf("%s(%s)", _method, "host"), host)
	if _err != nil {
		return
	}
	_, _err =  _class.client.APICall(_method, _sessionIDArg, _selfArg, _hostArg)
	return
}
757527
func (n *node) unblockOwnerReferencesStrategicMergePatch() ([]byte, error) {
	var dummy metaonly.MetadataOnlyObject
	var blockingRefs []metav1.OwnerReference
	falseVar := false
	for _, owner := range n.owners {
		if owner.BlockOwnerDeletion != nil && *owner.BlockOwnerDeletion {
			ref := owner
			ref.BlockOwnerDeletion = &falseVar
			blockingRefs = append(blockingRefs, ref)
		}
	}
	dummy.ObjectMeta.SetOwnerReferences(blockingRefs)
	dummy.ObjectMeta.UID = n.identity.UID
	return json.Marshal(dummy)
}
728883
func GlobbedStringsMatch(item, val string) bool {
	if len(item) < 2 {
		return val == item
	}

	hasPrefix := strings.HasPrefix(item, "*")
	hasSuffix := strings.HasSuffix(item, "*")

	if hasPrefix && hasSuffix {
		return strings.Contains(val, item[1:len(item)-1])
	} else if hasPrefix {
		return strings.HasSuffix(val, item[1:])
	} else if hasSuffix {
		return strings.HasPrefix(val, item[:len(item)-1])
	}

	return val == item
}
134934
func (v *Version) IncrementPatch() error {
	if v.Major == 0 {
		return fmt.Errorf("Patch version can not be incremented for %q", v.String())
	}
	v.Patch += 1
	return nil
}
93708
func getDeploymentPatch(podTemplate *corev1.PodTemplateSpec, annotations map[string]string) (types.PatchType, []byte, error) {
	// Create a patch of the Deployment that replaces spec.template
	patch, err := json.Marshal([]interface{}{
		map[string]interface{}{
			"op":    "replace",
			"path":  "/spec/template",
			"value": podTemplate,
		},
		map[string]interface{}{
			"op":    "replace",
			"path":  "/metadata/annotations",
			"value": annotations,
		},
	})
	return types.JSONPatchType, patch, err
}
738852
func (pattern *MeshPattern) EndPatch() {
	C.cairo_mesh_pattern_end_patch(pattern.Ptr)
	if err := pattern.status(); err != nil {
		panic(err)
	}
}
1352180
func (b *BlockOpsStandard) TogglePrefetcher(enable bool) <-chan struct{} {
	return b.queue.TogglePrefetcher(enable, nil, nil)
}
716118
func ListRemoveByIndexOp(binName string, index int, returnType ListReturnType) *Operation {
	return &Operation{opType: _CDT_MODIFY, binName: binName, binValue: ListValue{_CDT_LIST_REMOVE_BY_INDEX, IntegerValue(returnType), IntegerValue(index)}, encoder: listGenericOpEncoder}
}
280646
func ListRemoveByIndexRangeOp(binName string, index, returnType ListReturnType) *Operation {
	return &Operation{opType: _CDT_MODIFY, binName: binName, binValue: ListValue{_CDT_LIST_REMOVE_BY_INDEX_RANGE, IntegerValue(returnType), IntegerValue(index)}, encoder: listGenericOpEncoder}
}
85610
func (ctx *Context) ApplyPatchFull(output io.Writer, pool Pool, ops chan Operation, failFast bool) error {
	for op := range ops {
		err := ctx.ApplySingleFull(output, pool, op, failFast)
		if err != nil {
			return errors.WithStack(err)
		}
	}

	return nil
}
528313
func (p *MemPostings) EnsureOrder() {
	p.mtx.Lock()
	defer p.mtx.Unlock()

	if p.ordered {
		return
	}

	n := runtime.GOMAXPROCS(0)
	workc := make(chan []uint64)

	var wg sync.WaitGroup
	wg.Add(n)

	for i := 0; i < n; i++ {
		go func() {
			for l := range workc {
				sort.Slice(l, func(i, j int) bool { return l[i] < l[j] })
			}
			wg.Done()
		}()
	}

	for _, e := range p.m {
		for _, l := range e {
			workc <- l
		}
	}
	close(workc)
	wg.Wait()

	p.ordered = true
}
674805
func SortAlphabeticFunc(list []string) func(i, j int) bool {
	return func(i, j int) bool {
		return LessIgnoreCase(list[i], list[j])
	}
}
472126
func JSONMapToStateValue(m map[string]interface{}, block *configschema.Block) (cty.Value, error) {
	var val cty.Value

	js, err := json.Marshal(m)
	if err != nil {
		return val, err
	}

	val, err = ctyjson.Unmarshal(js, block.ImpliedType())
	if err != nil {
		return val, err
	}

	return block.CoerceValue(val)
}