diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000000..66af146f15 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,46 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: tests +on: + pull_request: + push: + branches: + - main + +jobs: + build: + name: "unit tests" + runs-on: ubuntu-latest + environment: "Private Repos" + steps: + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: "1.18" + - name: Checkout code + uses: actions/checkout@v3 + # TODO remove this step and the following when the repo is public + - name: Checkout AlloyDB connector + uses: actions/checkout@v3 + with: + repository: "googlecloudplatform/alloydb-go-connector" + path: "alloydb-go-connector" + token: ${{ secrets.GH_PAT }} + - name: Point to local connector + run: | + go mod edit -replace=cloud.google.com/go/alloydbconn=./alloydb-go-connector + - name: Run tests + run: | + go test -v -race -cover -short ./... diff --git a/.gitignore b/.gitignore index 9c416bacaf..4e06d18d31 100644 --- a/.gitignore +++ b/.gitignore @@ -6,9 +6,6 @@ .vscode/ # Compiled binary -/cmd/cloud_sql_proxy/cloud_sql_proxy -/cloud_sql_proxy -# v2 binary -/cloudsql-proxy +/alloydb-auth-proxy /key.json diff --git a/cloudsql/cloudsql.go b/alloydb/alloydb.go similarity index 65% rename from cloudsql/cloudsql.go rename to alloydb/alloydb.go index 4e4f5371a4..d9168f1c0e 100644 --- a/cloudsql/cloudsql.go +++ b/alloydb/alloydb.go @@ -12,23 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cloudsql +package alloydb import ( "context" "io" "net" - "cloud.google.com/go/cloudsqlconn" + "cloud.google.com/go/alloydbconn" ) -// Dialer dials a Cloud SQL instance and returns its database engine version. +// Dialer dials an AlloyDB instance. type Dialer interface { // Dial returns a connection to the specified instance. - Dial(ctx context.Context, inst string, opts ...cloudsqlconn.DialOption) (net.Conn, error) - // EngineVersion retrieves the provided instance's database version (e.g., - // POSTGRES_14) - EngineVersion(ctx context.Context, inst string) (string, error) + Dial(ctx context.Context, inst string, opts ...alloydbconn.DialOption) (net.Conn, error) io.Closer } diff --git a/cmd/root.go b/cmd/root.go index dede5b78c5..8549f5b1bf 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -27,9 +27,9 @@ import ( "strings" "syscall" - "cloud.google.com/go/cloudsqlconn" - "github.com/GoogleCloudPlatform/cloudsql-proxy/v2/cloudsql" - "github.com/GoogleCloudPlatform/cloudsql-proxy/v2/internal/proxy" + "cloud.google.com/go/alloydbconn" + "github.com/GoogleCloudPlatform/alloydb-auth-proxy/alloydb" + "github.com/GoogleCloudPlatform/alloydb-auth-proxy/internal/proxy" "github.com/spf13/cobra" ) @@ -42,7 +42,7 @@ var ( func init() { versionString = strings.TrimSpace(versionString) - userAgent = "cloud-sql-auth-proxy/" + versionString + userAgent = "alloy-db-auth-proxy/" + versionString } // Execute adds all child commands to the root command and sets flags appropriately. @@ -57,7 +57,7 @@ func Execute() { } } -// Command represents an invocation of the Cloud SQL Auth Proxy. +// Command represents an invocation of the AlloyDB Auth Proxy. type Command struct { *cobra.Command conf *proxy.Config @@ -67,8 +67,8 @@ type Command struct { type Option func(*proxy.Config) // WithDialer configures the Command to use the provided dialer to connect to -// Cloud SQL instances. -func WithDialer(d cloudsql.Dialer) Option { +// AlloyDB instances. +func WithDialer(d alloydb.Dialer) Option { return func(c *proxy.Config) { c.Dialer = d } @@ -84,13 +84,13 @@ func NewCommand(opts ...Option) *Command { } cmd := &cobra.Command{ - Use: "cloud_sql_proxy instance_connection_name...", + Use: "alloydb-auth-proxy instance_connection_name...", Version: versionString, - Short: "cloud_sql_proxy provides a secure way to authorize connections to Cloud SQL.", - Long: `The Cloud SQL Auth proxy provides IAM-based authorization and encryption when -connecting to Cloud SQL instances. It listens on a local port and forwards connections -to your instance's IP address, providing a secure connection without having to manage -any client SSL certificates.`, + Short: "alloydb-auth-proxy provides a secure way to authorize connections to AlloyDB.", + Long: `The AlloyDB Auth proxy provides IAM-based authorization and encryption when +connecting to AlloyDB instances. It listens on a local port and forwards +connections to your instance's IP address, providing a secure connection +without having to manage any client SSL certificates.`, Args: func(cmd *cobra.Command, args []string) error { err := parseConfig(cmd, c.conf, args) if err != nil { @@ -113,8 +113,8 @@ any client SSL certificates.`, // Global and per instance flags cmd.PersistentFlags().StringVarP(&c.conf.Addr, "address", "a", "127.0.0.1", - "Address on which to bind Cloud SQL instance listeners.") - cmd.PersistentFlags().IntVarP(&c.conf.Port, "port", "p", 0, + "Address on which to bind AlloyDB instance listeners.") + cmd.PersistentFlags().IntVarP(&c.conf.Port, "port", "p", 5432, "Initial port to use for listeners. Subsequent listeners increment from this value.") c.Command = cmd @@ -142,7 +142,7 @@ func parseConfig(cmd *cobra.Command, conf *proxy.Config, args []string) error { case conf.CredentialsFile != "": cmd.Printf("Authorizing with the credentials file at %q\n", conf.CredentialsFile) default: - cmd.Printf("Authorizing with Application Default Credentials") + cmd.Println("Authorizing with Application Default Credentials") } var ics []proxy.InstanceConnConfig @@ -227,9 +227,9 @@ func runSignalWrapper(cmd *Command) error { // Otherwise, initialize a new one. d := cmd.conf.Dialer if d == nil { - opts := append(cmd.conf.DialerOpts(), cloudsqlconn.WithUserAgent(userAgent)) + opts := append(cmd.conf.DialerOpts(), alloydbconn.WithUserAgent(userAgent)) var err error - d, err = cloudsqlconn.NewDialer(ctx, opts...) + d, err = alloydbconn.NewDialer(ctx, opts...) if err != nil { shutdownCh <- fmt.Errorf("error initializing dialer: %v", err) return diff --git a/cmd/root_test.go b/cmd/root_test.go index 12457d4cf1..e2ae3636ab 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -17,13 +17,14 @@ package cmd import ( "context" "errors" + "fmt" "net" "sync" "testing" "time" - "cloud.google.com/go/cloudsqlconn" - "github.com/GoogleCloudPlatform/cloudsql-proxy/v2/internal/proxy" + "cloud.google.com/go/alloydbconn" + "github.com/GoogleCloudPlatform/alloydb-auth-proxy/internal/proxy" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/spf13/cobra" @@ -34,6 +35,9 @@ func TestNewCommandArguments(t *testing.T) { if c.Addr == "" { c.Addr = "127.0.0.1" } + if c.Port == 0 { + c.Port = 5432 + } if c.Instances == nil { c.Instances = []proxy.InstanceConnConfig{{}} } @@ -240,15 +244,11 @@ func (s *spyDialer) instance() string { return i } -func (*spyDialer) Dial(_ context.Context, inst string, _ ...cloudsqlconn.DialOption) (net.Conn, error) { - return nil, errors.New("spy dialer does not dial") -} - -func (s *spyDialer) EngineVersion(ctx context.Context, inst string) (string, error) { +func (s *spyDialer) Dial(_ context.Context, inst string, _ ...alloydbconn.DialOption) (net.Conn, error) { s.mu.Lock() defer s.mu.Unlock() s.got = inst - return "", nil + return nil, errors.New("spy dialer does not dial") } func (*spyDialer) Close() error { @@ -256,22 +256,58 @@ func (*spyDialer) Close() error { } func TestCommandWithCustomDialer(t *testing.T) { - want := "my-project:my-region:my-instance" + want := "my-project:my-region:my-cluster:my-instance" s := &spyDialer{} c := NewCommand(WithDialer(s)) // Keep the test output quiet c.SilenceUsage = true c.SilenceErrors = true - c.SetArgs([]string{want}) + c.SetArgs([]string{"--port", "10000", want}) - ctx, cancel := context.WithTimeout(context.Background(), time.Second) + ctx, cancel := context.WithCancel(context.Background()) defer cancel() - if err := c.ExecuteContext(ctx); !errors.As(err, &errSigInt) { - t.Fatalf("want errSigInt, got = %v", err) - } + go func() { + if err := c.ExecuteContext(ctx); !errors.As(err, &errSigInt) { + t.Fatalf("want errSigInt, got = %v", err) + } + }() - if got := s.instance(); got != want { - t.Fatalf("want = %v, got = %v", want, got) + // try will run f count times, returning early if f succeeds, or failing + // when count has been exceeded. + try := func(f func() error, count int) { + var ( + attempts int + err error + ) + for { + if attempts == count { + t.Fatal(err) + } + err = f() + if err != nil { + attempts++ + time.Sleep(time.Millisecond) + continue + } + return + } } + // give the listener some time to start + try(func() error { + conn, err := net.Dial("tcp", "127.0.0.1:10000") + if err != nil { + return err + } + defer conn.Close() + return nil + }, 10) + + // give the proxy some time to run + try(func() error { + if got := s.instance(); got != want { + return fmt.Errorf("want = %v, got = %v", want, got) + } + return nil + }, 10) } diff --git a/go.mod b/go.mod index e0d14fa86b..71a5c312f4 100644 --- a/go.mod +++ b/go.mod @@ -1,23 +1,16 @@ -module github.com/GoogleCloudPlatform/cloudsql-proxy/v2 +module github.com/GoogleCloudPlatform/alloydb-auth-proxy go 1.16 require ( - cloud.google.com/go/cloudsqlconn v0.2.1-0.20220401153611-87e713b37755 - cloud.google.com/go/compute v1.5.0 - github.com/GoogleCloudPlatform/cloudsql-proxy v1.29.0 - github.com/coreos/go-systemd/v22 v22.3.2 - github.com/denisenkom/go-mssqldb v0.12.0 - github.com/go-sql-driver/mysql v1.6.0 + cloud.google.com/go/alloydbconn v0.0.0-0.20220401153611-87e713b37755 github.com/google/go-cmp v0.5.7 - github.com/hanwen/go-fuse/v2 v2.1.0 - github.com/jackc/pgx/v4 v4.15.0 - github.com/lib/pq v1.10.5 + github.com/lib/pq v1.10.5 // indirect github.com/spf13/cobra v1.2.1 - go.uber.org/zap v1.21.0 - golang.org/x/net v0.0.0-20220325170049-de3da57026de golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a - golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12 - golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 - google.golang.org/api v0.74.0 + golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12 // indirect + google.golang.org/api v0.74.0 // indirect + google.golang.org/genproto v0.0.0-20220401170504-314d38edb7de // indirect ) + +replace cloud.google.com/go/alloydbconn => ../alloydb-go-connector diff --git a/go.sum b/go.sum index 89bd7fb980..5573cc24b7 100644 --- a/go.sum +++ b/go.sum @@ -34,10 +34,7 @@ cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvf cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/cloudsqlconn v0.2.1-0.20220401153611-87e713b37755 h1:74ZeQyxqrRSBoytWhFCDqScGNuF4PpCh7fe+BR9eX/I= -cloud.google.com/go/cloudsqlconn v0.2.1-0.20220401153611-87e713b37755/go.mod h1:y/ogms5BQof7JguwhcHsTPfskl7BFxXI8lvyXCQu/5E= cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow= -cloud.google.com/go/compute v1.2.0/go.mod h1:xlogom/6gr8RJGBe7nT2eGsQYAFUbbv8dbC29qE3Xmw= cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM= cloud.google.com/go/compute v1.5.0 h1:b1zWmYuuHz7gO9kDcM/EpHGr06UgsYNRpNJzI2kFiLM= cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= @@ -54,13 +51,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0/go.mod h1:h6H6c8enJmmocHUbLiiGY6sx7f9i+X3m1CHdd5c6Rdw= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.11.0/go.mod h1:HcM1YX14R7CJcghJGOYCgdezslRSVzqwLf/q+4Y2r/0= -github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0/go.mod h1:yqy467j36fJxcRV2TzfVZ1pCb5vxm4BtZPUdYWe/Xo8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/GoogleCloudPlatform/cloudsql-proxy v1.29.0 h1:YNu23BtH0PKF+fg3ykSorCp6jSTjcEtfnYLzbmcjVRA= -github.com/GoogleCloudPlatform/cloudsql-proxy v1.29.0/go.mod h1:spvB9eLJH9dutlbPSRmHvSXXHOwGRyeXh1jVdquA2G8= github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= @@ -68,8 +60,6 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -91,18 +81,13 @@ github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f h1:JOrtw2xFKzlg+cbHpyrpLDmnN1HqhBfnX7WDiW7eG2c= github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/denisenkom/go-mssqldb v0.12.0 h1:VtrkII767ttSPNRfFekePK3sctr+joXgO58stqQbtUA= -github.com/denisenkom/go-mssqldb v0.12.0/go.mod h1:iiK0YP1ZeepvmBQk/QpLEhhTNJgfzrpArPY/aFvc9yU= -github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -120,17 +105,11 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= -github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= -github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= -github.com/golang-sql/sqlexp v0.0.0-20170517235910-f1bb20e5a188 h1:+eHOFJl1BaXrQxKX+T06f78590z4qA2ZzBTqahsKSE4= -github.com/golang-sql/sqlexp v0.0.0-20170517235910-f1bb20e5a188/go.mod h1:vXjM/+wXQnTPR4KqTKDgJukSZ6amVRtWMPEjE6sQoK8= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -207,14 +186,9 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= -github.com/googleapis/gax-go/v2 v2.2.0 h1:s7jOdKSaksJVOxE0Y/S32otcfiP+UQ0cL8/GTKaONwE= github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/OthfcblKl4IGNaM= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/hanwen/go-fuse v1.0.0 h1:GxS9Zrn6c35/BnfiVsZVWmsG803xwE7eVRDvcf/BEVc= -github.com/hanwen/go-fuse v1.0.0/go.mod h1:unqXarDXqzAk0rt98O2tVndEPIpUgLD9+rwFisZH3Ok= -github.com/hanwen/go-fuse/v2 v2.1.0 h1:+32ffteETaLYClUj0a3aHjZ1hOPxxaNEHiZiujuDaek= -github.com/hanwen/go-fuse/v2 v2.1.0/go.mod h1:oRyA5eK+pvJyv5otpO/DgccS8y/RvYMaO00GgRLGryc= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -301,13 +275,10 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= -github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.5 h1:J+gdV2cUmX7ZqL2B0lFcW0m+egaHC2V3lpO8nWxyYiQ= github.com/lib/pq v1.10.5/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= @@ -330,10 +301,8 @@ github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= -github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -401,22 +370,16 @@ go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= -go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= -go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= -go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= @@ -425,7 +388,6 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI= @@ -503,8 +465,6 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211020060615-d418f374d309/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220325170049-de3da57026de h1:pZB1TWnKi+o4bENlbzAgLrEbY4RMYmUIRobMcSmfeYc= @@ -600,11 +560,10 @@ golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12 h1:QyVthZKMsyaQwBTJE04jdNN0Pp5Fn9Qga0mrgxyERQM= golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -725,11 +684,10 @@ google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqiv google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= -google.golang.org/api v0.66.0/go.mod h1:I1dmXYpX7HGwz/ejRxwQp2qj5bFAz93HiCU1C1oYd9M= google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g= -google.golang.org/api v0.68.0/go.mod h1:sOM8pTpwgflXRhz+oC8H2Dr+UcbMqkPPWNJo88Q7TH8= google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= google.golang.org/api v0.71.0/go.mod h1:4PyU6e6JogV1f9eA4voyrTY2batOLdgZ5qZ5HOCc4j8= +google.golang.org/api v0.73.0/go.mod h1:lbd/q6BRFJbdpV6OUCXstVeiI5mL/d3/WifG7iNKnjI= google.golang.org/api v0.74.0 h1:ExR2D+5TYIrMphWgs5JCgwRhEDlPDXXrLwHHMgPHTXE= google.golang.org/api v0.74.0/go.mod h1:ZpfMZOVRMywNyvJFeqL9HRWBgAuRfSjJFpe9QtRRyDs= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= @@ -800,18 +758,16 @@ google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ6 google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220114231437-d2e6a121cae0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220201184016-50beb8ab5c44/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220204002441-d6cc3cc0770e/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220317150908-0efb43f6373e/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= -google.golang.org/genproto v0.0.0-20220329172620-7be39ac1afc7 h1:HOL66YCI20JvN2hVk6o2YIp9i/3RvzVUz82PqNr7fXw= -google.golang.org/genproto v0.0.0-20220329172620-7be39ac1afc7/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220401170504-314d38edb7de h1:9Ti5SG2U4cAcluryUo/sFay3TQKoxiFMfaT0pbizU7k= +google.golang.org/genproto v0.0.0-20220401170504-314d38edb7de/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -865,7 +821,6 @@ gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/internal/proxy/proxy.go b/internal/proxy/proxy.go index 93b7230926..577116de8e 100644 --- a/internal/proxy/proxy.go +++ b/internal/proxy/proxy.go @@ -19,12 +19,11 @@ import ( "fmt" "io" "net" - "strings" "sync" "time" - "cloud.google.com/go/cloudsqlconn" - "github.com/GoogleCloudPlatform/cloudsql-proxy/v2/cloudsql" + "cloud.google.com/go/alloydbconn" + "github.com/GoogleCloudPlatform/alloydb-auth-proxy/alloydb" "github.com/spf13/cobra" "golang.org/x/oauth2" ) @@ -59,20 +58,20 @@ type Config struct { // configuration takes precedence over global configuration. Instances []InstanceConnConfig - // Dialer specifies the dialer to use when connecting to Cloud SQL + // Dialer specifies the dialer to use when connecting to AlloyDB // instances. - Dialer cloudsql.Dialer + Dialer alloydb.Dialer } -func (c *Config) DialerOpts() []cloudsqlconn.Option { - var opts []cloudsqlconn.Option +func (c *Config) DialerOpts() []alloydbconn.Option { + var opts []alloydbconn.Option switch { case c.Token != "": - opts = append(opts, cloudsqlconn.WithTokenSource( + opts = append(opts, alloydbconn.WithTokenSource( oauth2.StaticTokenSource(&oauth2.Token{AccessToken: c.Token}), )) case c.CredentialsFile != "": - opts = append(opts, cloudsqlconn.WithCredentialsFile( + opts = append(opts, alloydbconn.WithCredentialsFile( c.CredentialsFile, )) } @@ -80,18 +79,12 @@ func (c *Config) DialerOpts() []cloudsqlconn.Option { } type portConfig struct { - global int - postgres int - mysql int - sqlserver int + global int } func newPortConfig(global int) *portConfig { return &portConfig{ - global: global, - postgres: 5432, - mysql: 3306, - sqlserver: 1433, + global: global, } } @@ -102,44 +95,18 @@ func (c *portConfig) nextPort() int { return p } -func (c *portConfig) nextDBPort(version string) int { - switch { - case strings.HasPrefix(version, "MYSQL"): - p := c.mysql - c.mysql++ - return p - case strings.HasPrefix(version, "POSTGRES"): - p := c.postgres - c.postgres++ - return p - case strings.HasPrefix(version, "SQLSERVER"): - p := c.sqlserver - c.sqlserver++ - return p - default: - // Unexpected engine version, use global port setting instead. - return c.nextPort() - } -} - // Client represents the state of the current instantiation of the proxy. type Client struct { cmd *cobra.Command - dialer cloudsql.Dialer + dialer alloydb.Dialer // mnts is a list of all mounted sockets for this client mnts []*socketMount } // NewClient completes the initial setup required to get the proxy to a "steady" state. -func NewClient(ctx context.Context, d cloudsql.Dialer, cmd *cobra.Command, conf *Config) (*Client, error) { +func NewClient(ctx context.Context, d alloydb.Dialer, cmd *cobra.Command, conf *Config) (*Client, error) { var mnts []*socketMount - for _, inst := range conf.Instances { - go func(name string) { - // Initiate refresh operation - d.EngineVersion(ctx, name) - }(inst.Name) - } pc := newPortConfig(conf.Port) for _, inst := range conf.Instances { m := &socketMount{inst: inst.Name} @@ -147,18 +114,12 @@ func NewClient(ctx context.Context, d cloudsql.Dialer, cmd *cobra.Command, conf if inst.Addr != "" { a = inst.Addr } - version, err := d.EngineVersion(ctx, inst.Name) - if err != nil { - return nil, err - } var np int switch { case inst.Port != 0: np = inst.Port - case conf.Port != 0: + default: // use next increment from conf.Port np = pc.nextPort() - default: - np = pc.nextDBPort(version) } addr, err := m.listen(ctx, "tcp", net.JoinHostPort(a, fmt.Sprint(np))) if err != nil { @@ -207,7 +168,7 @@ func (c *Client) Close() { } // serveSocketMount persistently listens to the socketMounts listener and proxies connections to a -// given Cloud SQL instance. +// given AlloyDB instance. func (c *Client) serveSocketMount(ctx context.Context, s *socketMount) error { if s.listener == nil { return fmt.Errorf("[%s] mount doesn't have a listener set", s.inst) @@ -242,7 +203,7 @@ func (c *Client) serveSocketMount(ctx context.Context, s *socketMount) error { } } -// socketMount is a tcp/unix socket that listens for a Cloud SQL instance. +// socketMount is a tcp/unix socket that listens for an AlloyDB instance. type socketMount struct { inst string listener net.Listener diff --git a/internal/proxy/proxy_test.go b/internal/proxy/proxy_test.go index 34a490dd29..8d76ac4e26 100644 --- a/internal/proxy/proxy_test.go +++ b/internal/proxy/proxy_test.go @@ -17,43 +17,27 @@ package proxy_test import ( "context" "net" - "strings" "testing" - "github.com/GoogleCloudPlatform/cloudsql-proxy/v2/cloudsql" - "github.com/GoogleCloudPlatform/cloudsql-proxy/v2/internal/proxy" + "cloud.google.com/go/alloydbconn" + "github.com/GoogleCloudPlatform/alloydb-auth-proxy/internal/proxy" "github.com/spf13/cobra" ) -type fakeDialer struct { - cloudsql.Dialer +type fakeDialer struct{} + +func (fakeDialer) Dial(ctx context.Context, inst string, opts ...alloydbconn.DialOption) (net.Conn, error) { + return nil, nil } func (fakeDialer) Close() error { return nil } -func (fakeDialer) EngineVersion(_ context.Context, inst string) (string, error) { - switch { - case strings.Contains(inst, "pg"): - return "POSTGRES_14", nil - case strings.Contains(inst, "mysql"): - return "MYSQL_8_0", nil - case strings.Contains(inst, "sqlserver"): - return "SQLSERVER_2019_STANDARD", nil - default: - return "POSTGRES_14", nil - } -} - func TestClientInitialization(t *testing.T) { ctx := context.Background() - pg := "proj:region:pg" - pg2 := "proj:region:pg2" - mysql := "proj:region:mysql" - mysql2 := "proj:region:mysql2" - sqlserver := "proj:region:sqlserver" - sqlserver2 := "proj:region:sqlserver2" + cluster1 := "proj:region:cluster:instance1" + cluster2 := "proj:region:cluster:instance2" tcs := []struct { desc string @@ -66,12 +50,11 @@ func TestClientInitialization(t *testing.T) { Addr: "127.0.0.1", Port: 5000, Instances: []proxy.InstanceConnConfig{ - {Name: pg}, - {Name: mysql}, - {Name: sqlserver}, + {Name: cluster1}, + {Name: cluster2}, }, }, - wantAddrs: []string{"127.0.0.1:5000", "127.0.0.1:5001", "127.0.0.1:5002"}, + wantAddrs: []string{"127.0.0.1:5000", "127.0.0.1:5001"}, }, { desc: "with instance address", @@ -79,7 +62,7 @@ func TestClientInitialization(t *testing.T) { Addr: "1.1.1.1", // bad address, binding shouldn't happen here. Port: 5000, Instances: []proxy.InstanceConnConfig{ - {Addr: "0.0.0.0", Name: pg}, + {Addr: "0.0.0.0", Name: cluster1}, }, }, wantAddrs: []string{"0.0.0.0:5000"}, @@ -90,7 +73,7 @@ func TestClientInitialization(t *testing.T) { Addr: "::1", Port: 5000, Instances: []proxy.InstanceConnConfig{ - {Name: pg}, + {Name: cluster1}, }, }, wantAddrs: []string{"[::1]:5000"}, @@ -101,7 +84,7 @@ func TestClientInitialization(t *testing.T) { Addr: "127.0.0.1", Port: 5000, Instances: []proxy.InstanceConnConfig{ - {Name: pg, Port: 6000}, + {Name: cluster1, Port: 6000}, }, }, wantAddrs: []string{"127.0.0.1:6000"}, @@ -112,37 +95,28 @@ func TestClientInitialization(t *testing.T) { Addr: "127.0.0.1", Port: 5000, Instances: []proxy.InstanceConnConfig{ - {Name: pg}, - {Name: mysql, Port: 6000}, - {Name: sqlserver}, + {Name: cluster1}, + {Name: cluster2, Port: 6000}, }, }, wantAddrs: []string{ "127.0.0.1:5000", "127.0.0.1:6000", - "127.0.0.1:5001", }, }, { desc: "with incrementing automatic port selection", in: &proxy.Config{ Addr: "127.0.0.1", + Port: 5432, // default port Instances: []proxy.InstanceConnConfig{ - {Name: pg}, - {Name: pg2}, - {Name: mysql}, - {Name: mysql2}, - {Name: sqlserver}, - {Name: sqlserver2}, + {Name: cluster1}, + {Name: cluster2}, }, }, wantAddrs: []string{ "127.0.0.1:5432", "127.0.0.1:5433", - "127.0.0.1:3306", - "127.0.0.1:3307", - "127.0.0.1:1433", - "127.0.0.1:1434", }, }, } diff --git a/main.go b/main.go index 03867e9574..485e2f62cd 100644 --- a/main.go +++ b/main.go @@ -15,7 +15,7 @@ package main import ( - "github.com/GoogleCloudPlatform/cloudsql-proxy/v2/cmd" + "github.com/GoogleCloudPlatform/alloydb-auth-proxy/cmd" ) func main() { diff --git a/testsV2/postgres_test.go b/tests/alloydb_test.go similarity index 50% rename from testsV2/postgres_test.go rename to tests/alloydb_test.go index 49c769b37a..b841f64786 100644 --- a/testsV2/postgres_test.go +++ b/tests/alloydb_test.go @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// postgres_test runs various tests against a Postgres flavored Cloud SQL instance. package tests import ( @@ -21,29 +20,26 @@ import ( "os" "testing" - "cloud.google.com/go/cloudsqlconn" - "cloud.google.com/go/cloudsqlconn/postgres/pgxv4" + "cloud.google.com/go/alloydbconn/driver/pgxv4" ) var ( - postgresConnName = flag.String("postgres_conn_name", os.Getenv("POSTGRES_CONNECTION_NAME"), "Cloud SQL Postgres instance connection name, in the form of 'project:region:instance'.") - postgresUser = flag.String("postgres_user", os.Getenv("POSTGRES_USER"), "Name of database user.") - postgresPass = flag.String("postgres_pass", os.Getenv("POSTGRES_PASS"), "Password for the database user; be careful when entering a password on the command line (it may go into your terminal's history).") - postgresDB = flag.String("postgres_db", os.Getenv("POSTGRES_DB"), "Name of the database to connect to.") - - postgresIAMUser = flag.String("postgres_user_iam", os.Getenv("POSTGRES_USER_IAM"), "Name of database user configured with IAM DB Authentication.") + alloydbConnName = flag.String("alloydb_conn_name", os.Getenv("ALLOYDB_CONNECTION_NAME"), "AlloyDB instance connection name, in the form of 'project:region:instance'.") + alloydbUser = flag.String("alloydb_user", os.Getenv("ALLOYDB_USER"), "Name of database user.") + alloydbPass = flag.String("alloydb_pass", os.Getenv("ALLOYDB_PASS"), "Password for the database user; be careful when entering a password on the command line (it may go into your terminal's history).") + alloydbDB = flag.String("alloydb_db", os.Getenv("ALLOYDB_DB"), "Name of the database to connect to.") ) func requirePostgresVars(t *testing.T) { switch "" { - case *postgresConnName: - t.Fatal("'postgres_conn_name' not set") - case *postgresUser: - t.Fatal("'postgres_user' not set") - case *postgresPass: - t.Fatal("'postgres_pass' not set") - case *postgresDB: - t.Fatal("'postgres_db' not set") + case *alloydbConnName: + t.Fatal("'alloydb_conn_name' not set") + case *alloydbUser: + t.Fatal("'alloydb_user' not set") + case *alloydbPass: + t.Fatal("'alloydb_pass' not set") + case *alloydbDB: + t.Fatal("'alloydb_db' not set") } } @@ -53,15 +49,15 @@ func TestPostgresTCP(t *testing.T) { } requirePostgresVars(t) - cleanup, err := pgxv4.RegisterDriver("postgres1") + cleanup, err := pgxv4.RegisterDriver("alloydb1") if err != nil { t.Fatalf("failed to register driver: %v", err) } defer cleanup() dsn := fmt.Sprintf("host=%v user=%v password=%v database=%v sslmode=disable", - *postgresConnName, *postgresUser, *postgresPass, *postgresDB) - proxyConnTest(t, []string{*postgresConnName}, "postgres1", dsn) + *alloydbConnName, *alloydbUser, *alloydbPass, *alloydbDB) + proxyConnTest(t, []string{*alloydbConnName}, "alloydb1", dsn) } func TestPostgresAuthWithToken(t *testing.T) { @@ -69,7 +65,7 @@ func TestPostgresAuthWithToken(t *testing.T) { t.Skip("skipping Postgres integration tests") } requirePostgresVars(t) - cleanup, err := pgxv4.RegisterDriver("postgres2", cloudsqlconn.WithIAMAuthN()) + cleanup, err := pgxv4.RegisterDriver("alloydb2") if err != nil { t.Fatalf("failed to register driver: %v", err) } @@ -78,10 +74,10 @@ func TestPostgresAuthWithToken(t *testing.T) { defer cleanup2() dsn := fmt.Sprintf("host=%v user=%v password=%v database=%v sslmode=disable", - *postgresConnName, *postgresUser, *postgresPass, *postgresDB) + *alloydbConnName, *alloydbUser, *alloydbPass, *alloydbDB) proxyConnTest(t, - []string{"--token", tok.AccessToken, *postgresConnName}, - "postgres2", dsn) + []string{"--token", tok.AccessToken, *alloydbConnName}, + "alloydb2", dsn) } func TestPostgresAuthWithCredentialsFile(t *testing.T) { @@ -89,7 +85,7 @@ func TestPostgresAuthWithCredentialsFile(t *testing.T) { t.Skip("skipping Postgres integration tests") } requirePostgresVars(t) - cleanup, err := pgxv4.RegisterDriver("postgres3", cloudsqlconn.WithIAMAuthN()) + cleanup, err := pgxv4.RegisterDriver("alloydb3") if err != nil { t.Fatalf("failed to register driver: %v", err) } @@ -98,8 +94,8 @@ func TestPostgresAuthWithCredentialsFile(t *testing.T) { defer cleanup2() dsn := fmt.Sprintf("host=%v user=%v password=%v database=%v sslmode=disable", - *postgresConnName, *postgresUser, *postgresPass, *postgresDB) + *alloydbConnName, *alloydbUser, *alloydbPass, *alloydbDB) proxyConnTest(t, - []string{"--credentials-file", path, *postgresConnName}, - "postgres3", dsn) + []string{"--credentials-file", path, *alloydbConnName}, + "alloydb3", dsn) } diff --git a/testsV2/common_test.go b/tests/common_test.go similarity index 91% rename from testsV2/common_test.go rename to tests/common_test.go index f9ffa2b56c..e1e82d6c68 100644 --- a/testsV2/common_test.go +++ b/tests/common_test.go @@ -12,11 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package tests contains end to end tests meant to verify the Cloud SQL Auth proxy -// works as expected when executed as a binary. -// -// Required flags: -// -mysql_conn_name, -db_user, -db_pass +// Package tests contains end to end tests meant to verify the AlloyDB Auth +// proxy works as expected when executed as a binary. package tests import ( @@ -28,10 +25,10 @@ import ( "os" "strings" - "github.com/GoogleCloudPlatform/cloudsql-proxy/v2/cmd" + "github.com/GoogleCloudPlatform/alloydb-auth-proxy/cmd" ) -// proxyExec represents an execution of the Cloud SQL proxy. +// proxyExec represents an execution of the AlloyDB proxy. type proxyExec struct { Out io.ReadCloser diff --git a/testsV2/connection_test.go b/tests/connection_test.go similarity index 94% rename from testsV2/connection_test.go rename to tests/connection_test.go index 63e8a8bdb4..4cf9d7b3ec 100644 --- a/testsV2/connection_test.go +++ b/tests/connection_test.go @@ -23,7 +23,6 @@ import ( "golang.org/x/oauth2" "golang.org/x/oauth2/google" - "google.golang.org/api/sqladmin/v1" ) const connTestTimeout = time.Minute @@ -32,7 +31,7 @@ const connTestTimeout = time.Minute // and then unsets GOOGLE_APPLICATION_CREDENTIALS. It returns a cleanup function // that restores the original setup. func removeAuthEnvVar(t *testing.T) (*oauth2.Token, string, func()) { - ts, err := google.DefaultTokenSource(context.Background(), sqladmin.SqlserviceAdminScope) + ts, err := google.DefaultTokenSource(context.Background()) if err != nil { t.Errorf("failed to resolve token source: %v", err) } diff --git a/testsV2/other_test.go b/tests/other_test.go similarity index 100% rename from testsV2/other_test.go rename to tests/other_test.go