Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Programmatic access to heroku with the Heroku Client gem

Received: by 10.224.97.134 with SMTP id l6mr1552666qan.6.1336060131923;
        Thu, 03 May 2012 08:48:51 -0700 (PDT)
X-BeenThere: heroku@googlegroups.com
Received: by 10.224.182.133 with SMTP id cc5ls1486144qab.6.gmail; Thu, 03 May
 2012 08:48:47 -0700 (PDT)
Received: by 10.224.184.70 with SMTP id cj6mr1562736qab.3.1336060127590;
        Thu, 03 May 2012 08:48:47 -0700 (PDT)
Received: by 10.224.184.70 with SMTP id cj6mr1562735qab.3.1336060127567;
        Thu, 03 May 2012 08:48:47 -0700 (PDT)
Return-Path: <dbl...@dblock.org>
Received: from mail-qa0-f42.google.com (mail-qa0-f42.google.com [209.85.216.42])
        by gmr-mx.google.com with ESMTPS id ez28si2102387qcb.1.2012.05.03.08.48.47
        (version=TLSv1/SSLv3 cipher=OTHER);
        Thu, 03 May 2012 08:48:47 -0700 (PDT)
Received-SPF: neutral (google.com: 209.85.216.42 is neither permitted nor denied by best guess record for domain of dbl...@dblock.org) client-ip=209.85.216.42;
Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 209.85.216.42 is neither permitted nor denied by best guess record for domain of dbl...@dblock.org) smtp.mail=dbl...@dblock.org
Received: by qafi31 with SMTP id i31so360201qaf.15
        for <heroku@googlegroups.com>; Thu, 03 May 2012 08:48:47 -0700 (PDT)
        d=google.com; s=20120113;
        h=mime-version:x-originating-ip:in-reply-to:references:date
         :message-id:subject:from:to:content-type:x-gm-message-state;
        bh=AQcECPmDsj9OHyARpcd4hmqaMPHrGV4Ya6UbZkfxPpg=;
        b=fin/2QvyYOihbxBLJY6n7jzYjGwulXW9y3hvG5PHhdNIQHlv184dE4XhwF+6HAlxfo
         NY7iZJCtOeRwe+oHZhRNUpvq2oO6f0rYPTzHz2Id70KgFBOTj1EYALo0bAEARZqhfjus
         S48ytSkeZmnZUfzY7GzqsQjJMyzexdWtQ8+AMTDM0cYq8OVczzitrLACZHR73VBGReSN
         NDrql6XpuJLe4nF7SWZ9kZwFMXF/+k/b1y8nCfTSrGxaJBQKXGZZ7MdMaudB6RaEplJ9
         E/eg4+6YDGwNFGYoynW0o3TL4Vu8U22fAM43lB266BGUp6Val8GlTz/9mbJhmWnrt/pp
         9VKA==
MIME-Version: 1.0
Received: by 10.60.22.70 with SMTP id b6mr3457403oef.5.1336060127225; Thu, 03
 May 2012 08:48:47 -0700 (PDT)
Received: by 10.76.91.37 with HTTP; Thu, 3 May 2012 08:48:47 -0700 (PDT)
X-Originating-IP: [108.21.231.67]
In-Reply-To: <10153174.177.1335975053399.JavaMail.geo-discussion-forums@pbpl7>
References: <CALCE7pknLmi=MYGPu9pOt2Mm+k61meuS5XC1pP0ZrOpRme_...@mail.gmail.com>
	<10153174.177.1335975053399.JavaMail.geo-discussion-forums@pbpl7>
Date: Thu, 3 May 2012 11:48:47 -0400
Message-ID: <CALCE7pmrNx=HScqRR2ByAORdt6+OpY6z2=ZyF+vaVbeyubw...@mail.gmail.com>
Subject: Re: Programmatic access to heroku with the Heroku Client gem
From: Daniel Doubrovkine <dbl...@dblock.org>
To: heroku@googlegroups.com
Content-Type: multipart/alternative; boundary=e89a8fb2061648260f04bf23bd79
X-Gm-Message-State: ALoCoQk1yECz7ExEnRK2HTnXT9rFxWXLUMq3a+DAjzEho7FJPRX19I0TMbyF54hsUznLFuZVTYoC

--e89a8fb2061648260f04bf23bd79
Content-Type: text/plain; charset=ISO-8859-1

Take the example of a rake task that pushes a deployment to Heroku along
with some S3 assets. Every developer has their own heroku application, and
they configure it by creating a Heroku remote origin.

To push to heroku a developer does do *git push heroku master*, then they
need to push some assets to their own S3 bucket (eg. developer-bucket). The
name of the bucket is configured as a S3_BUCKET variable on their heroku
application. Right now we execute 'heroku config --long', parse that to
figure out what the S3_BUCKET is, which is not ideal. Nowhere the Rake task
knows the name of the remote Heroku application.

Of course we could force every developer to hardcode the name of their
application somewhere on the client, but we might as well keep our heroku
config output parsing instead.

Makes sense?

On Wed, May 2, 2012 at 12:10 PM, geemus <wes...@heroku.com> wrote:

> I'd actually recommend checking out the heroku-api gem for programatic
> access.  You can cover your example then this way:
>
> require "heroku-api"
> api = Heroku::API.new(:api_key => XXX)
> api.get_convig_vars("my-app").body
>
> That said, I'm not sure what the best answer is on the default app front.
>  Could you describe how you intend to use this information?  I think that
> might help me narrow down a recommendation and/or fix it up to make it
> easier to do what you need.
>
> Thanks!
> wes
>
>
> On Tuesday, May 1, 2012 5:48:22 PM UTC-5, dB. wrote:
>>
>> I'm trying to replace some code in a Rake task that executes 'heroku
>> config --long' and parses the output.
>>
>> I can do this:
>>
>> c = Heroku::Client.new(* Heroku::Auth.read_credentials)
>> c.config_vars("my-app")
>>
>> Awesome, this returns the configuration variables for my-app as a Hash.
>>
>> The next problem is how to figure out the default app name - in
>> development environments we often want to have our tasks run against our
>> "default" development Heroku instance. The code I want to call is in
>> lib/heroku/command/base.rb, ex**tract_app_in_dir(Dir.pwd). There's quite
>> a bit of logic underneath this, storing git remotes and what not.
>>
>>    1. Do you think this should be refactored so that one can call
>>    extract_app_in_dir without an instance of a class?
>>    2. Is there a simple(r) way to get the default app name?
>>
>> Thanks,
>> dB.
>>
>> --
>>
>> dB. | Moscow - Geneva - Seattle - New York
>> dblock.org <http://www.dblock.org> - @dblockdotorg<http://twitter.com/#!/dblockdotorg>
>>
>>   --
> You received this message because you are subscribed to the Google
> Groups "Heroku" group.
>
> To unsubscribe from this group, send email to
> heroku+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/heroku?hl=en_US?hl=en
>



-- 

dB. | Moscow - Geneva - Seattle - New York
dblock.org <http://www.dblock.org> -
@dblockdotorg<http://twitter.com/#!/dblockdotorg>

--e89a8fb2061648260f04bf23bd79
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Take the example of a rake task that pushes a deployment to Heroku along wi=
th some S3 assets. Every developer has their own heroku application, and th=
ey configure it by creating a Heroku remote origin.=A0<div><br></div><div>
To push to heroku a developer does do <i>git push heroku master</i>, then t=
hey need to push some assets to their own S3 bucket (eg. developer-bucket).=
 The name of the bucket is configured as a S3_BUCKET variable on their hero=
ku application. Right now we execute &#39;heroku config --long&#39;, parse =
that to figure out what the S3_BUCKET is, which is not ideal. Nowhere the R=
ake task knows the name of the remote Heroku application.</div>
<div><br></div><div>Of course we could force every developer to hardcode th=
e name of their application somewhere on the client, but we might as well k=
eep our heroku config output parsing instead.</div><div><br></div><div>
Makes sense?<br><br><div class=3D"gmail_quote">On Wed, May 2, 2012 at 12:10=
 PM, geemus <span dir=3D"ltr">&lt;<a href=3D"mailto:wes...@heroku.com" targ=
et=3D"_blank">wes...@heroku.com</a>&gt;</span> wrote:<br><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex">
I&#39;d actually recommend checking out the heroku-api gem for programatic =
access. =A0You can cover your example then this way:<div><br></div><div>req=
uire &quot;heroku-api&quot;</div><div>api =3D Heroku::API.new(:api_key =3D&=
gt; XXX)</div>
<div>api.get_convig_vars(&quot;my-app&quot;).body</div><div><br></div><div>=
That said, I&#39;m not sure what the best answer is on the default app fron=
t. =A0Could you describe how you intend to use this information? =A0I think=
 that might help me narrow down a recommendation and/or fix it up to make i=
t easier to do what you need.</div>
<div><br></div><div>Thanks!<br>wes<div><div class=3D"h5"><br><br>On Tuesday=
, May 1, 2012 5:48:22 PM UTC-5, dB. wrote:<blockquote class=3D"gmail_quote"=
 style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-lef=
t:1ex">
I&#39;m trying to replace some code in a Rake task that executes &#39;herok=
u config --long&#39; and parses the output.<div><br></div><div>I can do thi=
s:</div><div><br></div><div><font face=3D"&#39;courier new&#39;, monospace"=
>c =3D Heroku::Client.new(* Heroku::Auth.read_credentials)</font></div>

<div><font face=3D"&#39;courier new&#39;, monospace">c.config_vars(&quot;my=
-app&quot;)<br></font><div><div><br></div><div>Awesome, this returns the co=
nfiguration variables for my-app as a Hash.=A0</div><div><br></div><div>The=
 next problem is how to figure out the default app name - in development en=
vironments we often want to have our tasks run against our &quot;default&qu=
ot; development Heroku instance. The code I want to call is in lib/heroku/c=
ommand/base.rb,=A0<font face=3D"&#39;courier new&#39;, monospace"><span sty=
le=3D"padding-right:0px;padding-left:0px;border-bottom-width:0px;padding-to=
p:0px;font:inherit;border-style:initial;border-color:initial;margin-bottom:=
0px;padding-bottom:0px;border-top-width:0px;line-height:16px;margin-right:0=
px;color:rgb(51,51,51);white-space:pre-wrap;margin-left:0px;border-right-wi=
dth:0px;margin-top:0px;border-left-width:0px">ex<u></u>tract_app_in_dir</sp=
an><span style=3D"padding-right:0px;padding-left:0px;border-bottom-width:0p=
x;padding-top:0px;font:inherit;border-style:initial;border-color:initial;ma=
rgin-bottom:0px;padding-bottom:0px;border-top-width:0px;line-height:16px;ma=
rgin-right:0px;color:rgb(51,51,51);white-space:pre-wrap;margin-left:0px;bor=
der-right-width:0px;margin-top:0px;border-left-width:0px">(</span><span sty=
le=3D"padding-right:0px;padding-left:0px;border-bottom-width:0px;padding-to=
p:0px;font:inherit;border-style:initial;border-color:initial;margin-bottom:=
0px;padding-bottom:0px;border-top-width:0px;line-height:16px;margin-right:0=
px;color:rgb(0,128,128);white-space:pre-wrap;margin-left:0px;border-right-w=
idth:0px;margin-top:0px;border-left-width:0px">Dir</span><span style=3D"pad=
ding-right:0px;padding-left:0px;border-bottom-width:0px;padding-top:0px;fon=
t:inherit;border-style:initial;border-color:initial;margin-bottom:0px;font-=
weight:bold;padding-bottom:0px;border-top-width:0px;line-height:16px;margin=
-right:0px;color:rgb(51,51,51);white-space:pre-wrap;margin-left:0px;border-=
right-width:0px;margin-top:0px;border-left-width:0px">.</span><span style=
=3D"padding-right:0px;padding-left:0px;border-bottom-width:0px;padding-top:=
0px;font:inherit;border-style:initial;border-color:initial;margin-bottom:0p=
x;padding-bottom:0px;border-top-width:0px;line-height:16px;margin-right:0px=
;color:rgb(51,51,51);white-space:pre-wrap;margin-left:0px;border-right-widt=
h:0px;margin-top:0px;border-left-width:0px">pwd). </span></font>There&#39;s=
 quite a bit of logic underneath this, storing git remotes and what not.</d=
iv>

<div><ol><li>Do you think this should be refactored so that one can call ex=
tract_app_in_dir without an instance of a class?</li><li>Is there a simple(=
r) way to get the default app name?</li></ol></div><div><div>Thanks,</div>

<div>dB.</div><div><br></div>-- <br><p><a name=3D"1370fc67d3114f0b_CALCE7pk=
nLmi=3DMYGPu9pOt2Mm+k61meuS5XC1pP0ZrOpRme_...@mail.gmail.com_SafeHtmlFilter=
__MailAutoSig"><span style=3D"font-size:8.0pt">dB. | Moscow - Geneva - Seat=
tle - New York<br>
</span></a><span><span style=3D"font-size:8.0pt"><a href=3D"http://www.dblo=
ck.org" target=3D"_blank">dblock.org</a>=A0- <a href=3D"http://twitter.com/=
#!/dblockdotorg" target=3D"_blank">@dblockdotorg</a></span></span></p>
<br>
</div></div></div>
</blockquote></div></div></div><span class=3D"HOEnZb"><font color=3D"#88888=
8">

<p></p>

-- <br>
You received this message because you are subscribed to the Google<br>
Groups &quot;Heroku&quot; group.<br>
=A0<br>
To unsubscribe from this group, send email to<br>
<a href=3D"mailto:heroku%2Bunsubscribe@googlegroups.com" target=3D"_blank">=
heroku+unsubscribe@googlegroups.com</a><br>
For more options, visit this group at<br>
<a href=3D"http://groups.google.com/group/heroku?hl=3Den_US?hl=3Den" target=
=3D"_blank">http://groups.google.com/group/heroku?hl=3Den_US?hl=3Den</a><br=
>
</font></span></blockquote></div><br><br clear=3D"all"><div><br></div>-- <b=
r><p><a name=3D"SafeHtmlFilter__MailAutoSig"><span style=3D"font-size:8.0pt=
">dB. | Moscow - Geneva - Seattle - New York<br></span></a><span><span styl=
e=3D"font-size:8.0pt"><a href=3D"http://www.dblock.org" target=3D"_blank">d=
block.org</a>=A0- <a href=3D"http://twitter.com/#!/dblockdotorg" target=3D"=
_blank">@dblockdotorg</a></span></span></p>
<br>
</div>

--e89a8fb2061648260f04bf23bd79--