diff options
author | Manjunath Ranganathaiah <manjunath.ranganathaiah@intel.com> | 2020-06-26 22:22:13 +0000 |
---|---|---|
committer | Ritu Sood <ritu.sood@intel.com> | 2020-06-27 20:11:33 -0700 |
commit | 8f338f5fb69c509439eb7f9ac7cfe7bd47849f8b (patch) | |
tree | 5839a7e861033ec259da8bcf31e496997b6143fe /src/rsync/pkg/internal | |
parent | 8e446beb55c68314896f16cb3105816cacc05f84 (diff) |
Remove config and yaml file creation
Signed-off-by: Manjunath Ranganathaiah <manjunath.ranganathaiah@intel.com>
Issue-ID: MULTICLOUD-1005
Change-Id: Iaa8b70f38cf1fc1f89cf2d95fbe37c242fc44f65
Diffstat (limited to 'src/rsync/pkg/internal')
-rw-r--r-- | src/rsync/pkg/internal/utils.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/rsync/pkg/internal/utils.go b/src/rsync/pkg/internal/utils.go index 59ff6df8..270edba5 100644 --- a/src/rsync/pkg/internal/utils.go +++ b/src/rsync/pkg/internal/utils.go @@ -23,8 +23,8 @@ import ( "k8s.io/client-go/kubernetes/scheme" ) -// DecodeYAML reads a YAMl file to extract the Kubernetes object definition -func DecodeYAML(path string, into runtime.Object) (runtime.Object, error) { +// DecodeYAMLFile reads a YAMl file to extract the Kubernetes object definition +func DecodeYAMLFile(path string, into runtime.Object) (runtime.Object, error) { if _, err := os.Stat(path); err != nil { if os.IsNotExist(err) { return nil, pkgerrors.New("File " + path + " not found") @@ -47,6 +47,17 @@ func DecodeYAML(path string, into runtime.Object) (runtime.Object, error) { return obj, nil } +// DecodeYAMLData reads a string to extract the Kubernetes object definition +func DecodeYAMLData(data string, into runtime.Object) (runtime.Object, error) { + decode := scheme.Codecs.UniversalDeserializer().Decode + obj, _, err := decode([]byte(data), nil, into) + if err != nil { + return nil, pkgerrors.Wrap(err, "Deserialize YAML error") + } + + return obj, nil +} + //EnsureDirectory makes sure that the directories specified in the path exist //If not, it will create them, if possible. func EnsureDirectory(f string) error { |