Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Herokuの小ネタ(仮)

tiwasaki
August 24, 2016

 Herokuの小ネタ(仮)

補足入りのブログ記事を下記に公開しています。
http://appirio.co.jp/blog-category/tech-blog/20160830-heroku-meetup-14-acdx/

tiwasaki

August 24, 2016
Tweet

Other Decks in Technology

Transcript

  1. 2 3 things you probably know about Heroku 1.Heroku =

    Hero + Haiku. 2.Heroku is built on top of AWS EC2. 3.Heroku was founded in 2007 and acquired by Salesforce.com in 2010.
  2. 8 Heroku SCM, pipelines, apps and review apps PR-1 staging

    master production staging PR-2 PR-1 PR-2 merge/promote commit/push/reset SCM App master merge/promote rollback rollback
  3. 9 Salesforce Release Process production full sandbox sandbox 1 sandbox

    2 pick-up components manually to release commit & push / no reset, no diff SCM App no rollback ⾃前で⽤意する必要あり
  4. 12 Force.com application template https://github.com/forcedotcom/force-com-app “This application demonstrates a source-driven

    approach to building Force.com applications. It uses a custom buildpack to configure deployment via Heroku's application lifecycle.”
  5. 14 app.json { "name": "Force.com Application", "addons": [ { "plan":

    "salesforce", "options": { "generate_subdomain": true } } ], "buildpacks": [ { "url": https://github.com/heroku/salesforce-buildpack } ], "env": { }}
  6. 15 bin/server.py(抜粋1) SALESFORCE_URL = environ['SALESFORCE_URL'] pattern = "force://(.*):(.*):(.*)@(.*)” m =

    re.search(pattern, SALESFORCE_URL) client_id=m.group(1) client_secret=m.group(2) refresh_token=m.group(3) instance = m.group(4) (続く)
  7. 16 bin/server.py(抜粋2) login_url = "https://%s/secur/frontdoor.jsp" % (instance) class myHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): def

    do_GET(self): print self.path self.send_response(303) new_path = '%s?sid=%s'%(login_url, access_token) self.send_header('Location', new_path) self.end_headers() handler = SocketServer.TCPServer(("", PORT), myHandler)
  8. 19 リフレッシュトークンの取得 ブラウザーで下記URLを開く https://login.salesforce.com/services/oauth2/authorize?response_type=code&client _id={client_id} → http://localhost/?code={code} にリダイレクトされる $ curl

    https://login.salesforce.com/services/oauth2/token --data "grant_type=authorization_code&code={code}" --data "client_id={client_id}" -- data "client_secret={client_secret}" --data "redirect_uri=https%3A%2F%2Flocalhost” {“access_token”:”(略)“,”refresh_token“:”(略)“,”signature“:以下略} force://{client_id}:{client_secret}:{refresh_token}@{instance} のように結合 instanceはna14.salesforce.comのように指定
  9. 24 lib/deploy.js const fs = require('fs'); const connection = require('jsforce-connection').connection;

    const jsforceDeploy = require('jsforce-deploy'); const srcPath = process.env.SALESFORCE_SRC_PATH || 'salesforce/src'; return connection().then((conn) => jsforceDeploy(conn)(srcPath));