public class YAMLHelper
extends java.lang.Object
| Constructor and Description |
|---|
YAMLHelper() |
| Modifier and Type | Method and Description |
|---|---|
static com.fasterxml.jackson.databind.JsonNode |
addLabelToResource(java.lang.String yaml,
java.lang.String labelKey,
java.lang.String labelValue)
Add a label to resource metadata
|
static com.fasterxml.jackson.databind.JsonNode |
editValueInYAML(java.lang.String yamlAsString,
java.lang.String[] fieldnames,
java.lang.String value)
Edit value of a yaml field and return the update yaml as JsonNode
|
static java.lang.String |
getStringValueFromYAML(java.lang.String yamlAsString,
java.lang.String[] path)
Retrieve value as String from YAML text
|
static com.fasterxml.jackson.databind.JsonNode |
getValueFromYAML(java.lang.String yamlAsString,
java.lang.String[] path)
Retrieve value as JsonNode from YAML text
|
static java.lang.String |
JSONToYAML(com.fasterxml.jackson.databind.JsonNode json) |
static com.fasterxml.jackson.databind.JsonNode |
removeLabelFromResource(java.lang.String yaml,
java.lang.String labelKey)
Remove a label from resource metadata
|
static com.fasterxml.jackson.databind.JsonNode |
URLToJSON(java.net.URL file) |
static com.fasterxml.jackson.databind.JsonNode |
YAMLToJsonNode(java.lang.String yaml) |
public static java.lang.String getStringValueFromYAML(java.lang.String yamlAsString,
java.lang.String[] path)
throws java.io.IOException
yamlAsString - Full YAML where to search the value frompath - Path to scan to search for the value (e.g to get the resource name `String[] { "metadata", "name" } `)java.io.IOException - if erroring during parsingpublic static com.fasterxml.jackson.databind.JsonNode getValueFromYAML(java.lang.String yamlAsString,
java.lang.String[] path)
throws java.io.IOException
yamlAsString - Full YAML where to search the value frompath - Path to scan to search for the value (e.g to get the resource name `String[] { "metadata", "name" } `)java.io.IOException - if erroring during parsingpublic static java.lang.String JSONToYAML(com.fasterxml.jackson.databind.JsonNode json)
throws java.io.IOException
java.io.IOExceptionpublic static com.fasterxml.jackson.databind.JsonNode YAMLToJsonNode(java.lang.String yaml)
throws java.io.IOException
java.io.IOExceptionpublic static com.fasterxml.jackson.databind.JsonNode URLToJSON(java.net.URL file)
throws java.io.IOException
java.io.IOExceptionpublic static com.fasterxml.jackson.databind.JsonNode editValueInYAML(java.lang.String yamlAsString,
java.lang.String[] fieldnames,
java.lang.String value)
throws java.io.IOException
yamlAsString - original yaml to editfieldnames - array of string to define path of field to change (e.g "spec", "template", "containers[0]", "image")value - new value to add to the fieldjava.io.IOException - if errored during yaml parsingpublic static com.fasterxml.jackson.databind.JsonNode addLabelToResource(java.lang.String yaml,
java.lang.String labelKey,
java.lang.String labelValue)
throws java.io.IOException
yaml - the YAML resource configurationlabelKey - label key to addlabelValue - label value to addjava.io.IOException - if errored during yaml parsingpublic static com.fasterxml.jackson.databind.JsonNode removeLabelFromResource(java.lang.String yaml,
java.lang.String labelKey)
throws java.io.IOException
yaml - the YAML resource configurationlabelKey - label key to removejava.io.IOException - if errored during yaml parsing