Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Ijaz Ahmad
ksonnet
Commits
26e50b44
Unverified
Commit
26e50b44
authored
Apr 03, 2018
by
Bryan Liles
Committed by
GitHub
Apr 03, 2018
Browse files
Merge pull request #412 from bryanl/generate-new-style-env-params
generate env params with ext var to support modules
parents
1664590e
db784fa2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
9 deletions
+12
-9
e2e/apply_test.go
e2e/apply_test.go
+1
-3
e2e/param_test.go
e2e/param_test.go
+1
-1
e2e/testdata/output/apply/output.txt
e2e/testdata/output/apply/output.txt
+0
-1
pkg/env/data.go
pkg/env/data.go
+2
-1
pkg/pipeline/pipeline.go
pkg/pipeline/pipeline.go
+8
-3
No files found.
e2e/apply_test.go
View file @
26e50b44
...
...
@@ -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
()
{
...
...
e2e/param_test.go
View file @
26e50b44
...
...
@@ -30,7 +30,7 @@ var _ = Describe("ks param", func() {
})
F
Describe
(
"delete"
,
func
()
{
Describe
(
"delete"
,
func
()
{
var
(
component
=
"guestbook-ui"
envName
=
"default"
...
...
e2e/testdata/output/apply/output.txt
.tmpl
→
e2e/testdata/output/apply/output.txt
View file @
26e50b44
rewriting "{{ .Namespace }}" environment params to not use relative paths
Updating services guestbook-ui
Creating non-existent services guestbook-ui
Updating deployments guestbook-ui
...
...
pkg/env/data.go
View file @
26e50b44
...
...
@@ -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:
...
...
pkg/pipeline/pipeline.go
View file @
26e50b44
...
...
@@ -62,7 +62,7 @@ func New(ksApp app.App, envName string, opts ...Opt) *Pipeline {
return
p
}
//
Namespac
es returns the
namespac
es that belong to this pipeline.
//
Modul
es returns the
modul
es 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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment