Skip to content

Commit

Permalink
Merge pull request #59 from flanksource/unstructuredObjects
Browse files Browse the repository at this point in the history
chore: add function to get []*unstructured.Unstructured from json array
  • Loading branch information
moshloop authored Jul 20, 2021
2 parents 7c107ac + 498f1a3 commit 3004704
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package kommons

import (
"bytes"
"encoding/json"
"fmt"
"reflect"
"strings"
Expand Down Expand Up @@ -664,6 +665,14 @@ func GetUnstructuredObjects(data []byte) ([]*unstructured.Unstructured, error) {
return items, nil
}

func GetUnstructuredObjectsFromJson(data []byte) ([]*unstructured.Unstructured, error) {
var items []*unstructured.Unstructured
if err := json.Unmarshal(data, &items); err != nil {
return nil, err
}
return items, nil
}

// GetCurrentClusterNameFrom returns the name of the cluster associated with the currentContext of the
// specified kubeconfig file
func GetCurrentClusterNameFrom(kubeConfigPath string) string {
Expand Down

0 comments on commit 3004704

Please sign in to comment.