mirror of
https://github.com/paralus/paralus.git
synced 2026-03-03 09:30:18 +00:00
* 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>
44 lines
760 B
Go
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
|
|
}
|