Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Svensson committed Apr 16, 2024
2 parents 5d10c82 + 333ffcb commit e7d46c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ Is meant to be used either stand alone like:
```bash
split-yaml -f longfile.yaml -o files
```
to split longfile.yaml into multiple files, they will be named $(name)-$(kind).yaml and end up in the files directory (in this case).
Or it can be used when piping output into it like this:
to split longfile.yaml into multiple files, they will be named `$(name)-$(kind).yaml` and end up in the `./files/` directory (in this case).

It can also be used when piping output into it like this:
```bash
kubectl get deploy,svc,configmap,ingress -o yaml | split-yaml -o files -
kubectl get deploy,svc,configmap,ingress -o yaml | split-yaml -o files -f -
```
To split the `kind: List` content into individual files.

Contributing PR's are welcome! If you want to expand it to use real kubernetes objects, I'm open to contributions.
**You must have LF line endings for this to work. CRLF would need to be converted to LF using git line ending normalization**

**You must have LF line endings for this to work. CRLF would need to be converted to LF using git line ending normalization**
Feel free to reach out with suggestions or issues!
10 changes: 0 additions & 10 deletions helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,10 @@ func GetYamlKindName(y string) (string, string, error) {
if r.Metadata.Name == "" {
return "", "", fmt.Errorf("could not find 'metadata.name' in yaml")
}
//fmt.Printf("Got kind: %v and name: %v", r.Kind, r.Metadata.Name)
return strings.ToLower(r.Kind), r.Metadata.Name, nil
}

func GetKindAndNameFromYaml(y string) (string, string) {
// var obj interface{}
// err := yaml.Unmarshal([]byte(s), *obj)
// if err != nil {
// fmt.Printf("unable to unmarshal yaml, %v", err)
// return "", "", err
// }
// name := obj.Metadata.Name
// kind := obj.kind
kind := ""
name := ""

Expand All @@ -84,7 +75,6 @@ func GetKindAndNameFromYaml(y string) (string, string) {
if kind != "" && name != "" {
break
}

}

return kind, name
Expand Down

0 comments on commit e7d46c9

Please sign in to comment.