From 367651a483a13cbd670d41021b6fcc5c6c8f5c9a Mon Sep 17 00:00:00 2001 From: bobmex <38759636+bobmex@users.noreply.github.com> Date: Thu, 3 Jan 2019 18:21:55 -0800 Subject: [PATCH] handle long yaml strings in a special way (#23) --- mexos/manifest.go | 2 +- mexos/templates.go | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/mexos/manifest.go b/mexos/manifest.go index 259fa5e83..8839d7811 100644 --- a/mexos/manifest.go +++ b/mexos/manifest.go @@ -307,7 +307,7 @@ func GetKubeManifest(mf *Manifest) (string, error) { mani := mf.Config.ConfigDetail.Manifest //XXX controlling pass full yaml text in parameter of another yaml log.DebugLog(log.DebugLevelMexos, "getting kubernetes manifest", "base", base, "manifest", mani) - if !strings.Contains(mani, "://") { + if !strings.HasPrefix(mani, "apiVersion: v1") { fn := fmt.Sprintf("%s/%s", base, mani) log.DebugLog(log.DebugLevelMexos, "getting manifest file", "uri", fn) res, err := GetURIFile(mf, fn) diff --git a/mexos/templates.go b/mexos/templates.go index 5d4e18e43..c89d3090e 100644 --- a/mexos/templates.go +++ b/mexos/templates.go @@ -120,9 +120,9 @@ config: kind: source: detail: - resources: "{{.Config.Resources}}" + resources: {{.Config.Resources}} deployment: {{.Config.Deployment}} - manifest: "{{.Config.Manifest}}" + manifest: {{.Config.Manifest}} template: {{.Config.Template}} base: {{.Config.Base}} overlay: {{.Config.Overlay}} @@ -253,11 +253,11 @@ func fillAppTemplate(rootLB *MEXRootLB, appInst *edgeproto.AppInst, app *edgepro NetworkScheme: vp.Network.Scheme, //XXX "external-ip," + GetMEXExternalNetwork(rootLB.PlatConf), Config: templateConfig{ Deployment: app.Deployment, //vp.Application.Deployment - Resources: config.Resources, - Manifest: app.DeploymentManifest, //XXX vp.Application.Manifest,controller passes entire YAML - Template: vp.Application.Template, - Base: vp.Application.Base, - Overlay: vp.Application.Overlay, + //Resources: config.Resources, + //Manifest: app.DeploymentManifest, //XXX vp.Application.Manifest,controller passes entire YAML + Template: vp.Application.Template, + Base: vp.Application.Base, + Overlay: vp.Application.Overlay, }, SpecPorts: vp.Application.Ports, Command: strings.Split(app.Command, " "), @@ -266,6 +266,9 @@ func fillAppTemplate(rootLB *MEXRootLB, appInst *edgeproto.AppInst, app *edgepro if err != nil { return nil, err } + //XXX these are passed in unmarshallable format from controller. it can contain entire YAML content + mf.Config.ConfigDetail.Resources = config.Resources + mf.Config.ConfigDetail.Manifest = app.DeploymentManifest switch appDeploymentType { case cloudcommon.AppDeploymentTypeKubernetes: case cloudcommon.AppDeploymentTypeDockerSwarm: