From 8f338f5fb69c509439eb7f9ac7cfe7bd47849f8b Mon Sep 17 00:00:00 2001 From: Manjunath Ranganathaiah Date: Fri, 26 Jun 2020 22:22:13 +0000 Subject: Remove config and yaml file creation Signed-off-by: Manjunath Ranganathaiah Issue-ID: MULTICLOUD-1005 Change-Id: Iaa8b70f38cf1fc1f89cf2d95fbe37c242fc44f65 --- src/rsync/pkg/internal/utils.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/rsync/pkg/internal/utils.go') 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 { -- cgit 1.2.3-korg