mirror of
https://github.com/paralus/paralus.git
synced 2026-08-24 15:47:19 +00:00
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>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user