Skip to content

Instantly share code, notes, and snippets.

@morikat
Created March 28, 2015 02:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save morikat/806358fa5ada841041e9 to your computer and use it in GitHub Desktop.
Save morikat/806358fa5ada841041e9 to your computer and use it in GitHub Desktop.
cloudfoundry v2 service connection like a v2 caldecott(bash version sample)

cloudfoundry v2 service connection like a v2 caldecott(bash version sample)

require

  • jq command
  • psql command

git clone

morika-t@moog:~$ git clone https://github.com/morikat/chisel.git
Cloning into 'chisel'...
remote: Counting objects: 371, done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 371 (delta 3), reused 0 (delta 0), pack-reused 355
Receiving objects: 100% (371/371), 4.06 MiB | 446.00 KiB/s, done.
Resolving deltas: 100% (144/144), done.
Checking connectivity... done.

morika-t@moog:~$ cd chisel/
morika-t@moog:~/chisel$ ls
Godeps  Procfile  README.md  bin  client  example  main.go  server  share  test

cf push

morika-t@moog:~/chisel$ cf push chisel2 -m 64m --no-start
Creating app chisel2 in org morika-t@hogehoge.com / space dev as morika-t@hogehoge.com...
OK

Using route chisel2.mybluemix.net
Binding chisel2.mybluemix.net to chisel2...
OK

Uploading chisel2...
Uploading app files from: /home/morika-t/chisel
Uploading 41.9K, 27 files
Done uploading
OK

service bind

morika-t@moog:~/chisel$ cf bind-service chisel2 chisel_test
Binding service chisel_test to app chisel2 in org morika-t@hogehoge.com / space dev as morika-t@hogehoge.com...
OK
TIP: Use 'cf restage' to ensure your env variable changes take effect

application start

morika-t@moog:~/chisel$ cf start chisel2
Starting app chisel2 in org morika-t@hogehoge.com / space dev as morika-t@hogehoge.com...
-----> Downloaded app package (2.2M)
-------> Buildpack version 1.1.1
-----> Installing go1.4... done
-----> Running: godep go install -tags cloudfoundry ./...
main.go:9:2: cannot find package "github.com/jpillora/chisel/client" in any of:
        /tmp/cache/go1.4/go/src/github.com/jpillora/chisel/client (from $GOROOT)
        /tmp/staged/app/.heroku/g/src/github.com/morikat/chisel/Godeps/_workspace/src/github.com/jpillora/chisel/clie$
t (from $GOPATH)
        /tmp/staged/app/.heroku/g/src/github.com/jpillora/chisel/client
main.go:10:2: cannot find package "github.com/jpillora/chisel/server" in any of:
        /tmp/cache/go1.4/go/src/github.com/jpillora/chisel/server (from $GOROOT)
        /tmp/staged/app/.heroku/g/src/github.com/morikat/chisel/Godeps/_workspace/src/github.com/jpillora/chisel/serve
r (from $GOPATH)
        /tmp/staged/app/.heroku/g/src/github.com/jpillora/chisel/server
client/client.go:12:2: cannot find package "github.com/jpillora/backoff" in any of:
        /tmp/cache/go1.4/go/src/github.com/jpillora/backoff (from $GOROOT)
        /tmp/staged/app/.heroku/g/src/github.com/morikat/chisel/Godeps/_workspace/src/github.com/jpillora/backoff (fro
m $GOPATH)
        /tmp/staged/app/.heroku/g/src/github.com/jpillora/backoff
client/client.go:13:2: cannot find package "github.com/jpillora/chisel/share" in any of:
        /tmp/cache/go1.4/go/src/github.com/jpillora/chisel/share (from $GOROOT)
        /tmp/staged/app/.heroku/g/src/github.com/morikat/chisel/Godeps/_workspace/src/github.com/jpillora/chisel/share
 (from $GOPATH)
        /tmp/staged/app/.heroku/g/src/github.com/jpillora/chisel/share
client/client.go:14:2: cannot find package "golang.org/x/crypto/ssh" in any of:
        /tmp/cache/go1.4/go/src/golang.org/x/crypto/ssh (from $GOROOT)
        /tmp/staged/app/.heroku/g/src/github.com/morikat/chisel/Godeps/_workspace/src/golang.org/x/crypto/ssh (from $G
OPATH)
        /tmp/staged/app/.heroku/g/src/golang.org/x/crypto/ssh
client/client.go:15:2: cannot find package "golang.org/x/net/websocket" in any of:
        /tmp/cache/go1.4/go/src/golang.org/x/net/websocket (from $GOROOT)
        /tmp/staged/app/.heroku/g/src/github.com/morikat/chisel/Godeps/_workspace/src/golang.org/x/net/websocket (from
 $GOPATH)
        /tmp/staged/app/.heroku/g/src/golang.org/x/net/websocket
godep: go exit status 1
-----> Uploading droplet (2.2M)
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
1 of 1 instances running

App started


OK

App chisel2 was started using this command `chisel server --port $PORT --proxy http://www.google.co.jp`

Showing health and status for app chisel2 in org morika-t@hogehoge.com / space dev as morika-t@hogehoge.com...
OK

requested state: started
instances: 1/1
usage: 64M x 1 instances
urls: chisel2.mybluemix.net
package uploaded: Sat Mar 28 02:26:11 +0000 2015

     state     since                    cpu    memory        disk         details
#0   running   2015-03-28 11:28:42 AM   0.0%   3.9M of 64M   7.6M of 1G

service connection

morika-t@moog:~/chisel$ ./bin/caldecott.sh chisel2
2015/03/28 11:31:45 client: Connecting to ws://chisel2.mybluemix.net:80
2015/03/28 11:31:45 client: 192.155.243.18:5433#1: Enabled
2015/03/28 11:31:46 client: Fingerprint 68:46:db:aa:90:eb:66:9e:27:d8:85:07:09:59:5c:2b
2015/03/28 11:31:47 client: Sending configurating
2015/03/28 11:31:47 client: Connected (Latency 158.478168ms)
psql: warning: extra command-line argument "localhost" ignored
2015/03/28 11:31:48 client: 192.155.243.18:5433#1: conn#1: Open
psql (9.1.15, server 9.1.6)
Type "help" for help.

d3401296a8ecf40dda645b2f06b577bde=> \d
                       List of relations
 Schema |   Name   | Type  |               Owner
--------+----------+-------+-----------------------------------
 public | hogehoge | table | uebebf98a21da4a97afa76a77c0843664
(1 row)

d3401296a8ecf40dda645b2f06b577bde=> \d hogehoge;
          Table "public.hogehoge"
 Column |         Type          | Modifiers
--------+-----------------------+-----------
 name   | character varying(50) |
 age    | integer               |

d3401296a8ecf40dda645b2f06b577bde=> \q
2015/03/28 11:32:09 client: 192.155.243.18:5433#1: conn#1: Close (sent 2284 received 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment