yamedit

package module
v0.0.0-...-addc531 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2020 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

yamedit

CI

Allows yaml files that are typically edited by humans to be updated without losing any formatting or comments.

It is not a fully-fledged YAML parser/writer, and only deals with updating values for existing fields in a YAML file. It cannot add new fields or new sub-trees to the data structure.

Example

yaml := []byte(`---
apiVersion: v1
kind: Namespace
metadata:
  name: platform
  labels:
    team: pricing`)

path := "/metadata/labels/team"


updated, err := yamedit.Edit(yaml, path, "checkout")
if err != nil {
  log.Fatal(err)
}

fmt.Println(updated)
// apiVersion: v1
// kind: Namespace
// metadata:
//  name: platform
//  labels:
//    team: checkout

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Edit

func Edit(YAML []byte, path, newValue string) ([]byte, error)

Edit the string value in the YAML from the given path

func Get

func Get(YAML []byte, path string) (string, error)

Get the string value from the YAML from the given path

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址