@@ -38,8 +38,6 @@ import (
3838 "log"
3939 "net/http"
4040 "os"
41- "os/exec"
42- "path/filepath"
4341 "testing"
4442 "time"
4543
@@ -50,8 +48,6 @@ import (
5048
5149 "golang.org/x/crypto/ssh"
5250 "golang.org/x/net/context"
53- "golang.org/x/oauth2"
54- "golang.org/x/oauth2/google"
5551 compute "google.golang.org/api/compute/v1"
5652)
5753
7268 token = flag .String ("token" , "" , "When set, the proxy uses this Bearer token for authorization." )
7369)
7470
75- const (
76- defaultOS = "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-8-jessie-v20160329"
77- buildShLocation = "cmd/cloud_sql_proxy/build.sh"
78- )
71+ const defaultOS = "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-8-jessie-v20160329"
7972
8073type logger interface {
8174 Log (args ... interface {})
@@ -159,31 +152,6 @@ func (p *process) Close() error {
159152 return p .sess .Close ()
160153}
161154
162- func compileProxy () (string , error ) {
163- // Find the 'build.sh' script by looking for it in cwd, cwd/.., and cwd/../..
164- var buildSh string
165-
166- var parentPath []string
167- for parents := 0 ; parents < 2 ; parents ++ {
168- cur := filepath .Join (append (parentPath , buildShLocation )... )
169- if _ , err := os .Stat (cur ); err == nil {
170- buildSh = cur
171- break
172- }
173- parentPath = append (parentPath , ".." )
174- }
175- if buildSh == "" {
176- return "" , fmt .Errorf ("couldn't find %q; please cd into the local repository" , buildShLocation )
177- }
178-
179- cmd := exec .Command (buildSh )
180- if out , err := cmd .CombinedOutput (); err != nil {
181- return "" , fmt .Errorf ("error during build.sh execution: %v;\n %s" , err , out )
182- }
183-
184- return "cloud_sql_proxy" , nil
185- }
186-
187155// startProxy executes the cloud_sql_proxy via ssh. The returned ReadCloser
188156// must be serviced and closed when finished, otherwise the SSH connection may
189157// block.
@@ -410,24 +378,6 @@ func sshKey() (pubKey string, auth ssh.AuthMethod, err error) {
410378 return string (ssh .MarshalAuthorizedKey (pub )), ssh .PublicKeys (signer ), nil
411379}
412380
413- func clientFromCredentials (ctx context.Context ) (* http.Client , error ) {
414- if f := * credentialFile ; f != "" {
415- all , err := ioutil .ReadFile (f )
416- if err != nil {
417- return nil , fmt .Errorf ("invalid json file %q: %v" , f , err )
418- }
419- cfg , err := google .JWTConfigFromJSON (all , proxy .SQLScope )
420- if err != nil {
421- return nil , fmt .Errorf ("invalid json file %q: %v" , f , err )
422- }
423- return cfg .Client (ctx ), nil
424- } else if tok := * token ; tok != "" {
425- src := oauth2 .StaticTokenSource (& oauth2.Token {AccessToken : tok })
426- return oauth2 .NewClient (ctx , src ), nil
427- }
428- return google .DefaultClient (ctx , proxy .SQLScope )
429- }
430-
431381func TestMain (m * testing.M ) {
432382 flag .Parse ()
433383 switch "" {
0 commit comments