Files
paralus/pkg/controller/util/patch_test.go
nirav-rafay c66bdc25cd restructure rcloud-base as a single base controller (#37)
* restructure rcloud-base as a single base controller
* updated master.rest
* moved sentry from internal to pkg as it is used by relay
* removing unused rpc and it's dependencies
* Fix usermgmt tests
* Don't redefine variables in rest file
Co-authored-by: Abin Simon <abin.simon@rafay.co>
2022-03-03 17:59:06 +05:30

44 lines
760 B
Go

package util
import (
"encoding/json"
"io/ioutil"
"os"
"github.com/RafaySystems/rcloud-base/pkg/controller/scheme"
apiv2 "github.com/RafaySystems/rcloud-base/proto/types/controller"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/yaml"
)
func loadRuntimeObject(path string) runtime.Object {
f, err := os.Open(path)
if err != nil {
panic(err)
}
yb, err := ioutil.ReadAll(f)
if err != nil {
panic(err)
}
jb, err := yaml.YAMLToJSON(yb)
if err != nil {
panic(err)
}
var so apiv2.StepObject
err = json.Unmarshal(jb, &so)
if err != nil {
panic(err)
}
o, _, err := scheme.Serializer.Decode(so.Raw, nil, &unstructured.Unstructured{})
if err != nil {
panic(err)
}
return o
}