From 2797dad34036fc65e1ec72e7986b47da4709c0c4 Mon Sep 17 00:00:00 2001 From: MUzairS15 Date: Sat, 11 Nov 2023 02:14:05 +0530 Subject: [PATCH] add required func Signed-off-by: MUzairS15 --- utils/manifests/getComponents.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/utils/manifests/getComponents.go b/utils/manifests/getComponents.go index 8ffcd2ed..b9fb1bdf 100644 --- a/utils/manifests/getComponents.go +++ b/utils/manifests/getComponents.go @@ -1,15 +1,42 @@ package manifests import ( + "context" "encoding/json" "io" "strings" "gopkg.in/yaml.v3" + "github.com/layer5io/meshkit/utils" k8s "github.com/layer5io/meshkit/utils/kubernetes" ) + +func GetFromManifest(ctx context.Context, url string, resource int, cfg Config) (*Component, error) { + manifest, err := utils.ReadFileSource(url) + if err != nil { + return nil, err + } + comp, err := GenerateComponents(ctx, manifest, resource, cfg) + if err != nil { + return nil, err + } + return comp, nil +} + +func GetFromHelm(ctx context.Context, url string, resource int, cfg Config) (*Component, error) { + manifest, err := k8s.GetManifestsFromHelm(url) + if err != nil { + return nil, err + } + comp, err := GenerateComponents(ctx, manifest, resource, cfg) + if err != nil { + return nil, err + } + return comp, nil +} + func GetCrdsFromHelm(url string) ([]string, error) { manifest, err := k8s.GetManifestsFromHelm(url) if err != nil {