Repository: deis/deis

Issue:
Allow file to be specified for config:push
Hey,

It would be good for `deis config:push` to accept a path to a .env file. 

I have 2 apps setup from 1 repo, one for staging and one for production, each have their own .env files.

An example would be: `deis config:push ./env.production`



Discussion:
ive got some code it reads a config.json file from the project root when creating a projects so on `deis create` the config it added to the application so by the time you run `git push deis master` the config is in place.
It lets you set RAM, CPU , VALUES etc. it you want Im happy to issue a pull request , It would not be hard to change it to use a .env file ..

@apps4u that may be a great candidate for a plugin!

http://docs.deis.io/en/latest/customizing_deis/cli-plugins/

@apps4u That would be awesome. Does it let you set all ENV vars?

yes , I’ll create a public repo and issue a push or should I just publish the link as I said its reads from a file called config.json in the project root but it would not be hard to change to read a .env file . Also It has not had any test written for the features I added so the pull request won’t be approved so I’ll just post a link to the repo and copy the code ..

All you need to do is change the default file name from config.json to your .env and then write one or two tests as it required for the pull request to be approved .. 

I use the code every day so its works 100% but I didn’t write a test for it.

Jason Kristian | Director | Apps 4 U Pty Ltd.
ph: +61 075699 8109
mob: +61 0411 389 392
e: Jason Kristian mailto:jasonk@apps4u.com.au

> On 8 Apr 2015, at 6:10 pm, Scott Robertson notifications@github.com wrote:
> 
> @apps4u https://github.com/apps4u That would be awesome. Does it let you set all ENV vars?
> 
> —
> Reply to this email directly or view it on GitHub https://github.com/deis/deis/issues/3423#issuecomment-90837886.

+1

Sorry The codes on my laptop and I left it mothers when I went for easter.  so I wont have it back for three days please wait and I'll upload the code then sorry for the delay Ive not added the changes to repo  so its the only copy is on my laptop.


Resolving patch:
diff --git a/client/deis.py b/client/deis.py
--- a/client/deis.py
+++ b/client/deis.py
@@ -1176,6 +1176,7 @@ def config_set(self, args):
         app = args.get('--app')
         if not app:
             app = self._session.app
+
         values = dictify(args['<var>=<value>'])
         if values.get('SSH_KEY'):
             if os.path.isfile(values.get('SSH_KEY')):
@@ -1321,24 +1322,27 @@ def config_push(self, args):
         """
         Sets environment variables for an application.
 
-        Your environment is read from a file named .env. This file can be
-        read by foreman to load the local environment for your app.
+        The environment is read from <path>. This file can be read by foreman
+        to load the local environment for your app.
 
         Usage: deis config:push [options]
 
         Options:
           -a --app=<app>
             the uniquely identifiable name for the application.
+          -p <path>, --path=<path>
+            a path leading to an environment file [default: .env]
         """
         app = args.get('--app')
         if not app:
             app = self._session.app
+
         # read from .env
         try:
-            with open('.env', 'r') as f:
+            with open(args.get('--path'), 'r') as f:
                 self._config_set(app, dictify([line.strip() for line in f]))
         except IOError:
-            self._logger.error('could not read from local env')
+            self._logger.error('could not read env from ' + args.get('--path'))
             sys.exit(1)
 
     def domains(self, args):


Test patch: