Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theirish81/yamlref
An easy Golang library to reference and merge multiple YAML files into a main one
https://github.com/theirish81/yamlref
Last synced: 19 days ago
JSON representation
An easy Golang library to reference and merge multiple YAML files into a main one
- Host: GitHub
- URL: https://github.com/theirish81/yamlref
- Owner: theirish81
- License: mit
- Created: 2021-12-27T08:19:38.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-16T11:18:08.000Z (about 2 years ago)
- Last Synced: 2024-10-11T20:10:16.804Z (about 1 month ago)
- Language: Go
- Size: 29.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# YamlRef
| Status | Test coverage |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|
| [![CircleCI](https://dl.circleci.com/status-badge/img/gh/theirish81/yamlRef/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/theirish81/yamlRef/tree/main) | 92.1% |An easy Golang library to reference and merge multiple local YAML files into a main one.
## $ref links
To perform the replacement, use a "$ref string" as value in any item of your YAML as in:
* `$ref:file://external.yaml`: replace this $ref string with the value of the `external.yaml` file, located in the same
directory as the main file
* `$ref:file:///home/theirish81/external.yaml` replace this $ref with the value of the `external.yaml` file, located in
an absolute path
* `$ref:file://external.yaml?comp=externalBot` replace this $ref with a specific object `externalBot` (root level only)
described in the `external.yaml` file, located in the same directory as the main file## Example
**main.yaml**:
```yaml
rootObject:
foo: bar
extRef: "$ref:file://external1.yaml"
myArray:
- foo
- bar
- "$ref:file://external1.yaml?comp=externalBot"
```
**external1.yaml**:```yaml
externalObject:
externalFoo: externalBar
externalArray:
- a
- b
- c
externalBot:
bot: true
```
Invoking `MergeAndMarshall("main.yaml")` would produce the following output (in []byte):**outcome**:
```yaml
rootObjct:
extRef:
externalBot:
bot: true
externalObject:
externalArray:
- a
- b
- c
externalFoo: externalBar
foo: bar
myArray:
- foo
- bar
- bot: true
```You can also invoke the `Merge(path string)` function to obtain the unmarshalled data structure.