How to use the json-merge-patch.apply function in json-merge-patch

To help you get started, we’ve selected a few json-merge-patch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github garden-io / garden / garden-service / src / plugins / kubernetes / helm / build.ts View on Github external
// update the local helm repo and retry
      log.debug("Updating Helm repo...")
      await helm(namespace, context, log, ...["repo", "update"])
      log.debug("Fetching chart (after updating)...")
      await fetchChart(namespace, context, log, module)
    }
  }

  const chartPath = await getChartPath(module)

  // create the values.yml file (merge the configured parameters into the default values)
  log.debug("Preparing chart...")
  const chartValues = safeLoad(await helm(namespace, context, log, "inspect", "values", chartPath)) || {}

  // Merge with the base module's values, if applicable
  const specValues = baseModule ? jsonMerge(baseModule.spec.values, module.spec.values) : module.spec.values

  const mergedValues = jsonMerge(chartValues, specValues)

  const valuesPath = getValuesPath(chartPath)
  log.silly(`Writing chart values to ${valuesPath}`)
  await dumpYaml(valuesPath, mergedValues)

  return { fresh: true }
}
github remy / jsonbin / lib / routes / api.js View on Github external
const path = urlToArray(req.path);
  const value = undefsafe(user.store, path.join('.'));

  if (value === undefined) {
    return res.status(404).json(null);
  }

  const parent = path.length ?
    undefsafe(user.store, path.join('.')) :
    user.store;

  // merge
  if (Array.isArray(parent)) {
    parent.push(req.body);
  } else {
    const result = jsonmergepatch.apply(parent, req.body);
    undefsafe(user.store, path.join('.'), result);
  }

  user.dirty('storeJson', { method: 'PATCH', path: path.join('.') });
  user.save().then(user => {
    res.status(200).json(undefsafe(user.store, path.join('.')));
  }).catch(e => {
    next(422);
  });
});
github garden-io / garden / garden-service / src / plugins / kubernetes / helm / build.ts View on Github external
await helm(namespace, context, log, ...["repo", "update"])
      log.debug("Fetching chart (after updating)...")
      await fetchChart(namespace, context, log, module)
    }
  }

  const chartPath = await getChartPath(module)

  // create the values.yml file (merge the configured parameters into the default values)
  log.debug("Preparing chart...")
  const chartValues = safeLoad(await helm(namespace, context, log, "inspect", "values", chartPath)) || {}

  // Merge with the base module's values, if applicable
  const specValues = baseModule ? jsonMerge(baseModule.spec.values, module.spec.values) : module.spec.values

  const mergedValues = jsonMerge(chartValues, specValues)

  const valuesPath = getValuesPath(chartPath)
  log.silly(`Writing chart values to ${valuesPath}`)
  await dumpYaml(valuesPath, mergedValues)

  return { fresh: true }
}
github argoproj / argo-cd-ui / src / app / applications / components / application-details / application-details.tsx View on Github external
{
                                                const spec = JSON.parse(JSON.stringify(application.spec));
                                                return services.applications.updateSpec(application.metadata.name, jsonMergePatch.apply(spec, JSON.parse(patch)));
                                            }}/>
                                        ),
github argoproj / argo-cd / ui / src / app / applications / components / application-create-panel / application-create-panel.tsx View on Github external
onSave={async patch => {
                                        props.onAppChanged(jsonMergePatch.apply(app, JSON.parse(patch)));
                                        setYamlMode(false);
                                        return true;
                                    }}
                                />
github argoproj / argo-cd / ui / src / app / applications / components / application-create-panel / application-create-panel.tsx View on Github external
onSave={async patch => {
                                        props.onAppChanged(jsonMergePatch.apply(app, JSON.parse(patch)));
                                        setYamlMode(false);
                                        return true;
                                    }}
                                />
github argoproj / argo-workflows / ui / src / app / cron-workflows / components / cron-workflow-summary-panel.tsx View on Github external
                                .then(latest => jsonMergePatch.apply(latest, patch))
                                .then(patched => services.cronWorkflows.update(patched, props.cronWorkflow.metadata.name, props.cronWorkflow.metadata.namespace))
github fusor / mig-ui / src / client / kube_store / index.ts View on Github external
public patchResource(resource: KubeResource, name: string, patch: object): object {
    const apiKey = resource.listPath().substr(1);
    const mockedObject = { ...this.data()[apiKey][name] };
    const patchedReturn = JsonMergePatch.apply(mockedObject, patch);
    this.updateMockedData(apiKey, name, patchedReturn);
    return patchedReturn;
  }
github argoproj / argo-cd / ui / src / app / applications / components / resource-details / resource-details.tsx View on Github external
onSave={async patch => {
                            const spec = JSON.parse(JSON.stringify(application.spec));
                            return services.applications.updateSpec(application.metadata.name, jsonMergePatch.apply(spec, JSON.parse(patch)));
                        }}
                    />

json-merge-patch

Implementation of JSON Merge Patch (RFC 7396)

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis