Skip to content

Commit 3068727

Browse files
authored
Merge pull request #3347 from mmilata/env-file
Document --param-file and --env-file oc arguments
2 parents ef3f256 + 77c9ecf commit 3068727

File tree

2 files changed

+58
-3
lines changed

2 files changed

+58
-3
lines changed

dev_guide/application_lifecycle/new_app.adoc

+35-1
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,20 @@ $ oc new-app ruby-helloworld-sample \
275275
----
276276
====
277277

278+
You can store your parameters in a file and then use this file with
279+
`--param-file` when instantiating a template. If you want to read the
280+
parameters from standard input, use `--param-file=-`:
281+
282+
====
283+
----
284+
$ cat helloworld.params
285+
ADMIN_USERNAME=admin
286+
ADMIN_PASSWORD=mypassword
287+
$ oc new-app ruby-helloworld-sample --param-file=helloworld.params
288+
$ cat helloworld.params | oc new-app ruby-helloworld-sample --param-file=-
289+
----
290+
====
291+
278292
[[new-app-output]]
279293

280294
=== Further Modifying Application Creation
@@ -342,10 +356,30 @@ $ oc new-app openshift/postgresql-92-centos7 \
342356
----
343357
====
344358

359+
The variables can also be read from file using the `--env-file` argument:
360+
361+
====
362+
----
363+
$ cat postgresql.env
364+
POSTGRESQL_USER=user
365+
POSTGRESQL_DATABASE=db
366+
POSTGRESQL_PASSWORD=password
367+
$ oc new-app openshift/postgresql-92-centos7 --env-file=postgresql.env
368+
----
369+
====
370+
371+
Additionally, environment variables can be given on standard input by using
372+
`--env-file=-`:
373+
====
374+
----
375+
$ cat postgresql.env | oc new-app openshift/postgresql-92-centos7 --env-file=-
376+
----
377+
====
378+
345379
[NOTE]
346380
====
347381
Any `*BuildConfig*` objects created as part of `new-app` processing will not be updated with
348-
environment variables passed via the `-e|--env` argument.
382+
environment variables passed via the `-e|--env` or `--env-file` argument.
349383
====
350384

351385

dev_guide/templates.adoc

+23-2
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ $ oc process <template> | oc create -f -
190190

191191
You can override any
192192
xref:../dev_guide/templates.adoc#templates-parameters[parameter] values defined
193-
in the file by adding the `-v` option for each `<name>=<value>` pair you want
193+
in the file by adding the `-p` option for each `<name>=<value>` pair you want
194194
to override. A parameter reference may appear in any text field inside the
195195
template items.
196196

@@ -215,11 +215,32 @@ command:
215215
----
216216
$ oc process -f my-rails-postgresql \
217217
-p POSTGRESQL_USER=bob \
218-
-P POSTGRESQL_DATABASE=mydatabase \
218+
-p POSTGRESQL_DATABASE=mydatabase \
219219
| oc create -f -
220220
----
221221
====
222222

223+
If you have large number of parameters you might prefer to store them in a file
224+
and then pass this file to `oc process`:
225+
226+
====
227+
----
228+
$ cat postgres.env
229+
POSTGRESQL_USER=bob
230+
POSTGRESQL_DATABASE=mydatabase
231+
$ oc process -f my-rails-postgresql --param-file=postgres.env
232+
----
233+
====
234+
235+
You can also read the environment from standard input by using `"-"` as the
236+
argument to `--param-file`:
237+
238+
====
239+
----
240+
$ sed s/bob/alice/ postgres.env | oc process -f my-rails-postgresql --param-file=-
241+
----
242+
====
243+
223244
[[modifying-an-uploaded-template]]
224245

225246
== Modifying an Uploaded Template

0 commit comments

Comments
 (0)