Skip to content
Snippets Groups Projects
Unverified Commit db784fa2 authored by bryanl's avatar bryanl
Browse files

generate env params with ext var to support modules


Signed-off-by: default avatarbryanl <bryanliles@gmail.com>
parent 1664590e
No related branches found
No related tags found
No related merge requests found
......@@ -49,9 +49,7 @@ var _ = Describe("ks apply", func() {
It("reports which resources it creating", func() {
assertExitStatus(o, 0)
data := map[string]string{"Namespace": "default"}
assertTemplate(data, "apply/output.txt.tmpl", o.stderr)
assertOutput("apply/output.txt", o.stderr)
})
It("creates a guestbook-ui service", func() {
......
......@@ -30,7 +30,7 @@ var _ = Describe("ks param", func() {
})
FDescribe("delete", func() {
Describe("delete", func() {
var (
component = "guestbook-ui"
envName = "default"
......
rewriting "{{ .Namespace }}" environment params to not use relative paths
Updating services guestbook-ui
Creating non-existent services guestbook-ui
Updating deployments guestbook-ui
......
......@@ -33,7 +33,8 @@ base + {
`)
// DefaultParamsData generates the contents for an environment's `params.libsonnet`
var DefaultParamsData = []byte(`local params = import "` + relComponentParamsPath + `";
var DefaultParamsData = []byte(`local params = std.extVar("__ksonnet/params");
params + {
components +: {
// Insert component parameter overrides here. Ex:
......
......@@ -62,7 +62,7 @@ func New(ksApp app.App, envName string, opts ...Opt) *Pipeline {
return p
}
// Namespaces returns the namespaces that belong to this pipeline.
// Modules returns the modules that belong to this pipeline.
func (p *Pipeline) Modules() ([]component.Module, error) {
return p.cm.Modules(p.app, p.envName)
}
......@@ -88,6 +88,7 @@ func (p *Pipeline) EnvParameters(module string) (string, error) {
vm := jsonnet.MakeVM()
vm.ExtCode("__ksonnet/params", paramsStr)
return vm.EvaluateSnippet("snippet", string(envParams))
}
......@@ -197,8 +198,12 @@ var (
// NOTE: It warns when it makes a change. This serves as a temporary fix until
// ksonnet generates the correct file.
func upgradeParams(envName, in string) string {
logrus.Warnf("rewriting %q environment params to not use relative paths", envName)
return reParamSwap.ReplaceAllLiteralString(in, `std.extVar("__ksonnet/params")`)
if reParamSwap.MatchString(in) {
logrus.Warnf("rewriting %q environment params to not use relative paths", envName)
return reParamSwap.ReplaceAllLiteralString(in, `std.extVar("__ksonnet/params")`)
}
return in
}
func stringInSlice(s string, sl []string) bool {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment