From 269277bf6f5f8ebf4bcc249ca2f3f42f064fa142 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Fri, 9 Sep 2022 18:39:15 +0530 Subject: [PATCH 01/39] Support Postgres as configuration store #4551 Signed-off-by: akhilac1 --- configuration/postgres/metadata.go | 22 ++ configuration/postgres/postgres.go | 296 ++++++++++++++++++++++++ configuration/postgres/postgres_test.go | 71 ++++++ 3 files changed, 389 insertions(+) create mode 100644 configuration/postgres/metadata.go create mode 100644 configuration/postgres/postgres.go create mode 100644 configuration/postgres/postgres_test.go diff --git a/configuration/postgres/metadata.go b/configuration/postgres/metadata.go new file mode 100644 index 000000000..389bf9199 --- /dev/null +++ b/configuration/postgres/metadata.go @@ -0,0 +1,22 @@ +/* +Copyright 2021 The Dapr Authors +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. +*/ + +package postgres + +import "time" + +type metadata struct { + maxIdleTime time.Duration + connectionString string + configTable string +} diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go new file mode 100644 index 000000000..ae0f29ada --- /dev/null +++ b/configuration/postgres/postgres.go @@ -0,0 +1,296 @@ +/* +Copyright 2021 The Dapr Authors +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. +*/ + +package postgres + +import ( + "context" + "database/sql" + "encoding/json" + "fmt" + "os" + "reflect" + "strings" + "sync" + "time" + + "github.com/dapr/components-contrib/configuration" + "github.com/dapr/kit/logger" + "github.com/google/uuid" + "github.com/jackc/pgconn" + "github.com/jackc/pgx/v4/pgxpool" + _ "github.com/jackc/pgx/v4/stdlib" +) + +type PostgresConfigStore struct { + metadata metadata + pool *pgxpool.Pool + logger logger.Logger + subscribeStopChanMap sync.Map +} + +const ( + configtablekey = "table" + connMaxIdleTimeKey = "connMaxIdleTime" + connectionStringKey = "connectionString" + ErrorMissingTableName = "missing postgreSQL configuration table name" + InfoStartInit = "Initializing PostgreSQL state store" + ErrorMissingConnectionString = "missing postgreSQL connection string" + ErrorAlreadyInitialized = "PostgreSQL configuration store already initialized" + ErrorMissinMaxTimeout = "missing PostgreSQL maxTimeout setting in configuration" + QueryTableExists = "SELECT EXISTS (SELECT FROM pg_tables where tablename = $1)" +) + +func NewPostgresConfigurationStore(logger logger.Logger) *PostgresConfigStore { + logger.Debug("Instantiating PostgreSQL configuration store") + return &PostgresConfigStore{ + logger: logger, + } +} + +func (p *PostgresConfigStore) Init(metadata configuration.Metadata) error { + p.logger.Debug(InfoStartInit) + if p.pool != nil { + return fmt.Errorf(ErrorAlreadyInitialized) + } + if m, err := parseMetadata(metadata); err != nil { + p.logger.Error(err) + return err + } else { + p.metadata = m + } + + ctx := context.Background() + pool, err := Connect(ctx, p.metadata.connectionString) + if err != nil { + return err + } + p.pool = pool + pingErr := p.pool.Ping(ctx) + if pingErr != nil { + return pingErr + } + + // check if table exists + exists := false + err = p.pool.QueryRow(ctx, QueryTableExists, p.metadata.configTable).Scan(&exists) + if err != nil { + return err + } + return nil +} + +func (p *PostgresConfigStore) Get(ctx context.Context, req *configuration.GetRequest) (*configuration.GetResponse, error) { + query, err := buildQuery(req, p.metadata.configTable) + if err != nil { + p.logger.Error(err) + return nil, err + } + + rows, err := p.pool.Query(ctx, query) + if err != nil { + // If no rows exist, return an empty response, otherwise return the error. + if err == sql.ErrNoRows { + return &configuration.GetResponse{}, nil + } + return nil, err + } + response := configuration.GetResponse{} + for i := 0; rows.Next(); i++ { + var item configuration.Item + var key string + var metadata []byte + var v = make(map[string]string) + + if err := rows.Scan(key, &item.Value, &item.Version, &metadata); err != nil { + return nil, err + } + if err := json.Unmarshal(metadata, &v); err != nil { + return nil, err + } + item.Metadata = v + response.Items[key] = &item + } + return &response, nil +} + +func (p *PostgresConfigStore) Subscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler) (string, error) { + subscribeID := uuid.New().String() + key := "listen " + p.metadata.configTable + // subscribe to events raised on the configTable + if oldStopChan, ok := p.subscribeStopChanMap.Load(key); ok { + close(oldStopChan.(chan struct{})) + } + stop := make(chan struct{}) + p.subscribeStopChanMap.Store(subscribeID, stop) + go p.doSubscribe(ctx, req, handler, key, subscribeID, stop) + return subscribeID, nil +} + +func (p *PostgresConfigStore) Unsubscribe(ctx context.Context, req *configuration.UnsubscribeRequest) error { + if oldStopChan, ok := p.subscribeStopChanMap.Load(req.ID); ok { + p.subscribeStopChanMap.Delete(req.ID) + close(oldStopChan.(chan struct{})) + } + return nil +} + +func (p *PostgresConfigStore) doSubscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler, channel string, id string, stop chan struct{}) { + conn, err := p.pool.Acquire(ctx) + if err != nil { + fmt.Fprintln(os.Stderr, "Error acquiring connection:", err) + } + defer conn.Release() + + _, err = conn.Exec(context.Background(), channel) + if err != nil { + p.logger.Errorf("Error listening to channel:", err) + return + } + + for { + notification, err := conn.Conn().WaitForNotification(ctx) + if err != nil { + p.logger.Errorf("Error waiting for notification:", err) + return + } + p.handleSubscribedChange(ctx, handler, notification, id) + } +} + +func (p *PostgresConfigStore) handleSubscribedChange(ctx context.Context, handler configuration.UpdateHandler, msg *pgconn.Notification, id string) { + defer func() { + if err := recover(); err != nil { + p.logger.Errorf("panic in handleSubscribedChange()method and recovered: %s", err) + } + }() + payload := make(map[string]interface{}) + err := json.Unmarshal([]byte(msg.Payload), &payload) + if err != nil { + p.logger.Errorf("Error in UnMarshall: ", err) + return + } + + var key, value, version string + m := make(map[string]string) + // trigger should encapsulate the row in "data" field in the notification + row := reflect.ValueOf(payload["data"]) + if row.Kind() == reflect.Map { + for _, k := range row.MapKeys() { + v := row.MapIndex(k) + strKey := k.Interface().(string) + switch strings.ToLower(strKey) { + case "key": + key = v.Interface().(string) + case "value": + value = v.Interface().(string) + case "version": + version = v.Interface().(string) + case "metadata": + a := v.Interface().(map[string]interface{}) + for k, v := range a { + m[k] = v.(string) + } + } + } + } + e := &configuration.UpdateEvent{ + Items: map[string]*configuration.Item{ + key: { + Value: value, + Version: version, + Metadata: m, + }, + }, + ID: id, + } + err = handler(ctx, e) + if err != nil { + p.logger.Errorf("fail to call handler to notify event for configuration update subscribe: %s", err) + } +} + +func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { + m := metadata{} + + if val, ok := cmetadata.Properties[connectionStringKey]; ok && val != "" { + m.connectionString = val + } else { + return m, fmt.Errorf(ErrorMissingConnectionString) + } + + if tbl, ok := cmetadata.Properties[configtablekey]; ok && tbl != "" { + m.configTable = tbl + } else { + return m, fmt.Errorf(ErrorMissingTableName) + } + + // configure maxTimeout if provided + if mxTimeout, ok := cmetadata.Properties[connMaxIdleTimeKey]; ok && mxTimeout != "" { + if t, err := time.ParseDuration(mxTimeout); err == nil { + m.maxIdleTime = t + } else { + return m, fmt.Errorf(ErrorMissinMaxTimeout) + } + } + return m, nil +} + +func Connect(ctx context.Context, conn string) (*pgxpool.Pool, error) { + pool, err := pgxpool.Connect(ctx, conn) + if err != nil { + return nil, fmt.Errorf("postgres configuration store connection error : %s", err) + } + pingErr := pool.Ping(context.Background()) + if pingErr != nil { + return nil, fmt.Errorf("postgres configuration store ping error : %s", pingErr) + } + return pool, nil +} + +func buildQuery(req *configuration.GetRequest, configTable string) (string, error) { + var query string + if len(req.Keys) == 0 { + query = "SELECT * FROM " + configTable + } else { + var queryBuilder strings.Builder + queryBuilder.WriteString("SELECT * FROM " + configTable + " WHERE KEY IN ('") + queryBuilder.WriteString(strings.Join(req.Keys, "','")) + queryBuilder.WriteString("')") + query = queryBuilder.String() + } + + if len(req.Metadata) > 0 { + var s strings.Builder + i, j := len(req.Metadata), 0 + s.WriteString(" AND ") + for k, v := range req.Metadata { + temp := k + "='" + v + "'" + s.WriteString(temp) + if j++; j < i { + s.WriteString(" AND ") + } + } + query += s.String() + } + return query, nil +} + +func QueryRow(ctx context.Context, p *pgxpool.Pool, query string, tbl string) error { + exists := false + err := p.QueryRow(ctx, query, tbl).Scan(&exists) + if err != nil { + return fmt.Errorf("postgres configuration store query error : %s", err) + } + return nil +} diff --git a/configuration/postgres/postgres_test.go b/configuration/postgres/postgres_test.go new file mode 100644 index 000000000..73a2362b1 --- /dev/null +++ b/configuration/postgres/postgres_test.go @@ -0,0 +1,71 @@ +/* +Copyright 2021 The Dapr Authors +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. +*/ + +package postgres + +import ( + "context" + "regexp" + "testing" + + "github.com/dapr/components-contrib/configuration" + "github.com/pashagolub/pgxmock" +) + +func TestPostgresbuildQuery(t *testing.T) { + g := &configuration.GetRequest{ + Keys: []string{"someKey"}, + Metadata: map[string]string{ + "Version": "1.0", + }, + } + + query, err := buildQuery(g, "cfgtbl") + if err != nil { + t.Errorf("Error building query: %v ", err) + } + expected := "SELECT * FROM cfgtbl WHERE KEY IN ('someKey') AND Version='1.0'" + if query != expected { + t.Errorf("Did not get expected result. Got: '%v' , Expected: '%v'", query, expected) + } +} + +func TestConnectAndQuery(t *testing.T) { + m := metadata{ + connectionString: "mockConnectionString", + configTable: "mockConfigTable", + } + + mock, err := pgxmock.NewPool() + if err != nil { + t.Fatalf("an error '%s' was not expected when opening a stub database connection", err) + } + defer mock.Close() + + query := "SELECT EXISTS (SELECT FROM pg_tables where tablename = '" + m.configTable + "'" + mock.ExpectQuery(regexp.QuoteMeta(query)). + WillReturnRows(pgxmock.NewRows( + []string{"exists"}). + AddRow(string("t")), + ) + rows := mock.QueryRow(context.Background(), query) + var id string + err = rows.Scan(&id) + if err != nil { + t.Error(err) + } + if err := mock.ExpectationsWereMet(); err != nil { + t.Errorf("there were unfulfilled expectations: %s", err) + } + +} From e6a8156c4b6ff6d1d18d6c76a29f4b3ca16d48b8 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Fri, 9 Sep 2022 20:30:07 +0530 Subject: [PATCH 02/39] Support Postgres config store Signed-off-by: akhilac1 --- go.mod | 11 ++++++----- go.sum | 21 ++++++++++++--------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index baca6ea27..965ed4085 100644 --- a/go.mod +++ b/go.mod @@ -80,7 +80,7 @@ require ( github.com/imkira/go-interpol v1.1.0 // indirect github.com/influxdata/influxdb-client-go v1.4.0 github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097 // indirect - github.com/jackc/pgx/v4 v4.15.0 + github.com/jackc/pgx/v4 v4.17.0 github.com/jcmturner/gofork v1.0.0 // indirect github.com/json-iterator/go v1.1.12 github.com/kataras/go-errors v0.0.3 // indirect @@ -98,6 +98,7 @@ require ( github.com/nats-io/nats.go v1.13.1-0.20220308171302-2f2f6968e98d github.com/nats-io/stan.go v0.8.3 github.com/open-policy-agent/opa v0.42.0 + github.com/pashagolub/pgxmock v1.8.0 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/pkg/errors v0.9.1 github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 // indirect @@ -120,7 +121,7 @@ require ( github.com/yuin/gopher-lua v0.0.0-20200603152657-dc2b0ca8b37e // indirect go.mongodb.org/mongo-driver v1.5.1 go.opencensus.io v0.23.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa golang.org/x/net v0.0.0-20220630215102-69896b714898 golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a google.golang.org/api v0.74.0 @@ -469,12 +470,12 @@ require ( github.com/hashicorp/go-uuid v1.0.2 // indirect github.com/hashicorp/serf v0.9.6 // indirect github.com/jackc/chunkreader/v2 v2.0.1 // indirect - github.com/jackc/pgconn v1.11.0 // indirect + github.com/jackc/pgconn v1.13.0 github.com/jackc/pgio v1.0.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect - github.com/jackc/pgproto3/v2 v2.2.0 // indirect + github.com/jackc/pgproto3/v2 v2.3.1 // indirect github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect - github.com/jackc/pgtype v1.10.0 // indirect + github.com/jackc/pgtype v1.12.0 // indirect github.com/jackc/puddle v1.2.1 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jpillora/backoff v1.0.0 // indirect diff --git a/go.sum b/go.sum index e5bfc6022..4806d5534 100644 --- a/go.sum +++ b/go.sum @@ -1555,8 +1555,8 @@ github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsU github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= -github.com/jackc/pgconn v1.11.0 h1:HiHArx4yFbwl91X3qqIHtUFoiIfLNJXCQRsnzkiwwaQ= -github.com/jackc/pgconn v1.11.0/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= +github.com/jackc/pgconn v1.13.0 h1:3L1XMNV2Zvca/8BYhzcRFS70Lr0WlDg16Di6SFGAbys= +github.com/jackc/pgconn v1.13.0/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI= github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= @@ -1572,22 +1572,22 @@ github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvW github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.2.0 h1:r7JypeP2D3onoQTCxWdTpCtJ4D+qpKr0TxvoyMhZ5ns= -github.com/jackc/pgproto3/v2 v2.2.0/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.3.1 h1:nwj7qwf0S+Q7ISFfBndqeLwSwxs+4DPsbRFjECT1Y4Y= +github.com/jackc/pgproto3/v2 v2.3.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= -github.com/jackc/pgtype v1.10.0 h1:ILnBWrRMSXGczYvmkYD6PsYyVFUNLTnIUJHHDLmqk38= -github.com/jackc/pgtype v1.10.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= +github.com/jackc/pgtype v1.12.0 h1:Dlq8Qvcch7kiehm8wPGIW0W3KsCCHJnRacKW0UM8n5w= +github.com/jackc/pgtype v1.12.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= -github.com/jackc/pgx/v4 v4.15.0 h1:B7dTkXsdILD3MF987WGGCcg+tvLW6bZJdEcqVFeU//w= -github.com/jackc/pgx/v4 v4.15.0/go.mod h1:D/zyOyXiaM1TmVWnOM18p0xdDtdakRBa0RsVGI3U3bw= +github.com/jackc/pgx/v4 v4.17.0 h1:Hsx+baY8/zU2WtPLQyZi8WbecgcsWEeyoK1jvg/WgIo= +github.com/jackc/pgx/v4 v4.17.0/go.mod h1:Gd6RmOhtFLTu8cp/Fhq4kP195KrshxYJH3oW8AWJ1pw= github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= @@ -2488,6 +2488,8 @@ github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIw github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pashagolub/pgxmock v1.8.0 h1:05JB+jng7yPdeC6i04i8TC4H1Kr7TfcFeQyf4JP6534= +github.com/pashagolub/pgxmock v1.8.0/go.mod h1:kDkER7/KJdD3HQjNvFw5siwR7yREKmMvwf8VhAgTK5o= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= @@ -3126,8 +3128,9 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= From cc81a9e26a13b731b03fbbb899a58ede530a8c62 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Fri, 9 Sep 2022 21:26:47 +0530 Subject: [PATCH 03/39] Support for Postgres configuration store Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index ae0f29ada..31c156d7d 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -32,9 +32,9 @@ import ( _ "github.com/jackc/pgx/v4/stdlib" ) -type PostgresConfigStore struct { +type ConfigurationStore struct { metadata metadata - pool *pgxpool.Pool + client *pgxpool.Pool logger logger.Logger subscribeStopChanMap sync.Map } @@ -51,16 +51,16 @@ const ( QueryTableExists = "SELECT EXISTS (SELECT FROM pg_tables where tablename = $1)" ) -func NewPostgresConfigurationStore(logger logger.Logger) *PostgresConfigStore { +func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store { logger.Debug("Instantiating PostgreSQL configuration store") - return &PostgresConfigStore{ + return &ConfigurationStore{ logger: logger, } } -func (p *PostgresConfigStore) Init(metadata configuration.Metadata) error { +func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { p.logger.Debug(InfoStartInit) - if p.pool != nil { + if p.client != nil { return fmt.Errorf(ErrorAlreadyInitialized) } if m, err := parseMetadata(metadata); err != nil { @@ -71,33 +71,33 @@ func (p *PostgresConfigStore) Init(metadata configuration.Metadata) error { } ctx := context.Background() - pool, err := Connect(ctx, p.metadata.connectionString) + client, err := Connect(ctx, p.metadata.connectionString) if err != nil { return err } - p.pool = pool - pingErr := p.pool.Ping(ctx) + p.client = client + pingErr := p.client.Ping(ctx) if pingErr != nil { return pingErr } // check if table exists exists := false - err = p.pool.QueryRow(ctx, QueryTableExists, p.metadata.configTable).Scan(&exists) + err = p.client.QueryRow(ctx, QueryTableExists, p.metadata.configTable).Scan(&exists) if err != nil { return err } return nil } -func (p *PostgresConfigStore) Get(ctx context.Context, req *configuration.GetRequest) (*configuration.GetResponse, error) { +func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequest) (*configuration.GetResponse, error) { query, err := buildQuery(req, p.metadata.configTable) if err != nil { p.logger.Error(err) return nil, err } - rows, err := p.pool.Query(ctx, query) + rows, err := p.client.Query(ctx, query) if err != nil { // If no rows exist, return an empty response, otherwise return the error. if err == sql.ErrNoRows { @@ -124,7 +124,7 @@ func (p *PostgresConfigStore) Get(ctx context.Context, req *configuration.GetReq return &response, nil } -func (p *PostgresConfigStore) Subscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler) (string, error) { +func (p *ConfigurationStore) Subscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler) (string, error) { subscribeID := uuid.New().String() key := "listen " + p.metadata.configTable // subscribe to events raised on the configTable @@ -137,7 +137,7 @@ func (p *PostgresConfigStore) Subscribe(ctx context.Context, req *configuration. return subscribeID, nil } -func (p *PostgresConfigStore) Unsubscribe(ctx context.Context, req *configuration.UnsubscribeRequest) error { +func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration.UnsubscribeRequest) error { if oldStopChan, ok := p.subscribeStopChanMap.Load(req.ID); ok { p.subscribeStopChanMap.Delete(req.ID) close(oldStopChan.(chan struct{})) @@ -145,8 +145,8 @@ func (p *PostgresConfigStore) Unsubscribe(ctx context.Context, req *configuratio return nil } -func (p *PostgresConfigStore) doSubscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler, channel string, id string, stop chan struct{}) { - conn, err := p.pool.Acquire(ctx) +func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler, channel string, id string, stop chan struct{}) { + conn, err := p.client.Acquire(ctx) if err != nil { fmt.Fprintln(os.Stderr, "Error acquiring connection:", err) } @@ -168,7 +168,7 @@ func (p *PostgresConfigStore) doSubscribe(ctx context.Context, req *configuratio } } -func (p *PostgresConfigStore) handleSubscribedChange(ctx context.Context, handler configuration.UpdateHandler, msg *pgconn.Notification, id string) { +func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler configuration.UpdateHandler, msg *pgconn.Notification, id string) { defer func() { if err := recover(); err != nil { p.logger.Errorf("panic in handleSubscribedChange()method and recovered: %s", err) From c63868c88545498db66bdb18847df2b4d4c1ba83 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Mon, 12 Sep 2022 18:16:15 +0530 Subject: [PATCH 04/39] updating review comments Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 36 +++++++++++++++++-------- configuration/postgres/postgres_test.go | 1 - 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index 31c156d7d..f8be9799f 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -17,6 +17,7 @@ import ( "context" "database/sql" "encoding/json" + "errors" "fmt" "os" "reflect" @@ -30,6 +31,7 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4/pgxpool" _ "github.com/jackc/pgx/v4/stdlib" + "golang.org/x/exp/utf8string" ) type ConfigurationStore struct { @@ -49,6 +51,8 @@ const ( ErrorAlreadyInitialized = "PostgreSQL configuration store already initialized" ErrorMissinMaxTimeout = "missing PostgreSQL maxTimeout setting in configuration" QueryTableExists = "SELECT EXISTS (SELECT FROM pg_tables where tablename = $1)" + maxIdentifierLength = 64 // https://www.postgresql.org/docs/current/limits.html + ErrorTooLongFieldLength = "field name is too long" ) func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store { @@ -70,8 +74,9 @@ func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { p.metadata = m } - ctx := context.Background() - client, err := Connect(ctx, p.metadata.connectionString) + ctx, cancel := context.WithTimeout(context.Background(), p.metadata.maxIdleTime) + defer cancel() + client, err := Connect(ctx, p.metadata.connectionString, p.metadata.maxIdleTime) if err != nil { return err } @@ -110,7 +115,7 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ var item configuration.Item var key string var metadata []byte - var v = make(map[string]string) + v := make(map[string]string) if err := rows.Scan(key, &item.Value, &item.Version, &metadata); err != nil { return nil, err @@ -151,17 +156,20 @@ func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration fmt.Fprintln(os.Stderr, "Error acquiring connection:", err) } defer conn.Release() - - _, err = conn.Exec(context.Background(), channel) + ctxTimeout, cancel := context.WithTimeout(ctx, p.metadata.maxIdleTime) + defer cancel() + _, err = conn.Exec(ctxTimeout, channel) if err != nil { p.logger.Errorf("Error listening to channel:", err) return } for { - notification, err := conn.Conn().WaitForNotification(ctx) + notification, err := conn.Conn().WaitForNotification(ctxTimeout) if err != nil { - p.logger.Errorf("Error waiting for notification:", err) + if !(pgconn.Timeout(err) || errors.Is(ctxTimeout.Err(), context.Canceled)) { + p.logger.Errorf("Error waiting for notification:", err) + } return } p.handleSubscribedChange(ctx, handler, notification, id) @@ -171,13 +179,13 @@ func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler configuration.UpdateHandler, msg *pgconn.Notification, id string) { defer func() { if err := recover(); err != nil { - p.logger.Errorf("panic in handleSubscribedChange()method and recovered: %s", err) + p.logger.Errorf("panic in handleSubscribedChange method and recovered: %s", err) } }() payload := make(map[string]interface{}) err := json.Unmarshal([]byte(msg.Payload), &payload) if err != nil { - p.logger.Errorf("Error in UnMarshall: ", err) + p.logger.Errorf("Error in UnMarshal: ", err) return } @@ -230,6 +238,12 @@ func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { } if tbl, ok := cmetadata.Properties[configtablekey]; ok && tbl != "" { + if !utf8string.NewString(tbl).IsASCII() { + return m, fmt.Errorf("invalid table name : '%v'. non-ascii characters are not supported", tbl) + } + if len(tbl) > maxIdentifierLength { + return m, fmt.Errorf(ErrorTooLongFieldLength+" - tableName : '%v'. max allowed field length is %v ", tbl, maxIdentifierLength) + } m.configTable = tbl } else { return m, fmt.Errorf(ErrorMissingTableName) @@ -246,12 +260,12 @@ func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { return m, nil } -func Connect(ctx context.Context, conn string) (*pgxpool.Pool, error) { +func Connect(ctx context.Context, conn string, maxTimeout time.Duration) (*pgxpool.Pool, error) { pool, err := pgxpool.Connect(ctx, conn) if err != nil { return nil, fmt.Errorf("postgres configuration store connection error : %s", err) } - pingErr := pool.Ping(context.Background()) + pingErr := pool.Ping(ctx) if pingErr != nil { return nil, fmt.Errorf("postgres configuration store ping error : %s", pingErr) } diff --git a/configuration/postgres/postgres_test.go b/configuration/postgres/postgres_test.go index 73a2362b1..2f954c7a6 100644 --- a/configuration/postgres/postgres_test.go +++ b/configuration/postgres/postgres_test.go @@ -67,5 +67,4 @@ func TestConnectAndQuery(t *testing.T) { if err := mock.ExpectationsWereMet(); err != nil { t.Errorf("there were unfulfilled expectations: %s", err) } - } From ff828777d2af2ed0078a16d970676f898ad2d900 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Tue, 13 Sep 2022 17:20:49 +0530 Subject: [PATCH 05/39] fixing lint errors Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 18 +++++++++++++++--- configuration/postgres/postgres_test.go | 3 ++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index f8be9799f..9b7283e4c 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -25,13 +25,15 @@ import ( "sync" "time" - "github.com/dapr/components-contrib/configuration" - "github.com/dapr/kit/logger" "github.com/google/uuid" "github.com/jackc/pgconn" + "github.com/jackc/pgx" "github.com/jackc/pgx/v4/pgxpool" _ "github.com/jackc/pgx/v4/stdlib" "golang.org/x/exp/utf8string" + + "github.com/dapr/components-contrib/configuration" + "github.com/dapr/kit/logger" ) type ConfigurationStore struct { @@ -55,6 +57,10 @@ const ( ErrorTooLongFieldLength = "field name is too long" ) +const ( + queryKey = `SELECT * ` +) + func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store { logger.Debug("Instantiating PostgreSQL configuration store") return &ConfigurationStore{ @@ -101,7 +107,6 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ p.logger.Error(err) return nil, err } - rows, err := p.client.Query(ctx, query) if err != nil { // If no rows exist, return an empty response, otherwise return the error. @@ -261,6 +266,13 @@ func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { } func Connect(ctx context.Context, conn string, maxTimeout time.Duration) (*pgxpool.Pool, error) { + cfg, err := pgxpool.ParseConfig(conn) + if err != nil { + return nil, fmt.Errorf("postgres configuration store configuration error : %s", err) + } + cfg.AfterConnect = func(ctx context.Context, conn *pgx.Conn) { + + } pool, err := pgxpool.Connect(ctx, conn) if err != nil { return nil, fmt.Errorf("postgres configuration store connection error : %s", err) diff --git a/configuration/postgres/postgres_test.go b/configuration/postgres/postgres_test.go index 2f954c7a6..faceae11f 100644 --- a/configuration/postgres/postgres_test.go +++ b/configuration/postgres/postgres_test.go @@ -18,8 +18,9 @@ import ( "regexp" "testing" - "github.com/dapr/components-contrib/configuration" "github.com/pashagolub/pgxmock" + + "github.com/dapr/components-contrib/configuration" ) func TestPostgresbuildQuery(t *testing.T) { From 874b7b5980d6dd42b07d5f8a0725d8d5d6dfc323 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Thu, 15 Sep 2022 14:13:33 +0530 Subject: [PATCH 06/39] fixed errors identified during functional testing Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 144 +++++++++++++++++++---------- 1 file changed, 96 insertions(+), 48 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index 9b7283e4c..cdd217051 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -19,7 +19,6 @@ import ( "encoding/json" "errors" "fmt" - "os" "reflect" "strings" "sync" @@ -27,7 +26,6 @@ import ( "github.com/google/uuid" "github.com/jackc/pgconn" - "github.com/jackc/pgx" "github.com/jackc/pgx/v4/pgxpool" _ "github.com/jackc/pgx/v4/stdlib" "golang.org/x/exp/utf8string" @@ -41,6 +39,13 @@ type ConfigurationStore struct { client *pgxpool.Pool logger logger.Logger subscribeStopChanMap sync.Map + ActiveSubscriptions map[string]*subscription +} + +type subscription struct { + uuid string + trigger string + keys []string } const ( @@ -48,7 +53,7 @@ const ( connMaxIdleTimeKey = "connMaxIdleTime" connectionStringKey = "connectionString" ErrorMissingTableName = "missing postgreSQL configuration table name" - InfoStartInit = "Initializing PostgreSQL state store" + InfoStartInit = "Initializing postgreSQL configuration store" ErrorMissingConnectionString = "missing postgreSQL connection string" ErrorAlreadyInitialized = "PostgreSQL configuration store already initialized" ErrorMissinMaxTimeout = "missing PostgreSQL maxTimeout setting in configuration" @@ -57,10 +62,6 @@ const ( ErrorTooLongFieldLength = "field name is too long" ) -const ( - queryKey = `SELECT * ` -) - func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store { logger.Debug("Instantiating PostgreSQL configuration store") return &ConfigurationStore{ @@ -70,6 +71,7 @@ func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store { func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { p.logger.Debug(InfoStartInit) + if p.client != nil { return fmt.Errorf(ErrorAlreadyInitialized) } @@ -79,7 +81,7 @@ func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { } else { p.metadata = m } - + p.ActiveSubscriptions = make(map[string]*subscription) ctx, cancel := context.WithTimeout(context.Background(), p.metadata.maxIdleTime) defer cancel() client, err := Connect(ctx, p.metadata.connectionString, p.metadata.maxIdleTime) @@ -91,7 +93,6 @@ func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { if pingErr != nil { return pingErr } - // check if table exists exists := false err = p.client.QueryRow(ctx, QueryTableExists, p.metadata.configTable).Scan(&exists) @@ -115,14 +116,14 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ } return nil, err } - response := configuration.GetResponse{} + response := configuration.GetResponse{make(map[string]*configuration.Item)} for i := 0; rows.Next(); i++ { var item configuration.Item var key string var metadata []byte v := make(map[string]string) - if err := rows.Scan(key, &item.Value, &item.Version, &metadata); err != nil { + if err := rows.Scan(&key, &item.Value, &item.Version, &metadata); err != nil { return nil, err } if err := json.Unmarshal(metadata, &v); err != nil { @@ -135,53 +136,79 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ } func (p *ConfigurationStore) Subscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler) (string, error) { - subscribeID := uuid.New().String() - key := "listen " + p.metadata.configTable - // subscribe to events raised on the configTable - if oldStopChan, ok := p.subscribeStopChanMap.Load(key); ok { - close(oldStopChan.(chan struct{})) + var triggers []string //req.Metadata + for k, v := range req.Metadata { + if k == strings.ToLower("trigger") { + triggers = append(triggers, v) + } + } + + if len(triggers) == 0 { + return "", fmt.Errorf("cannot subscribe to empty trigger") + } + + var subscribeID string + for _, trigger := range triggers { + key := "listen " + trigger + if sub, isActive := p.isSubscriptionActive(req); isActive { + //unsubscribe the previous subscription + if oldStopChan, ok := p.subscribeStopChanMap.Load(sub); ok { + close(oldStopChan.(chan struct{})) + } + } + stop := make(chan struct{}) + subscribeID = uuid.New().String() + p.subscribeStopChanMap.Store(subscribeID, stop) + p.ActiveSubscriptions[trigger] = &subscription{ + uuid: subscribeID, + trigger: trigger, + keys: req.Keys, + } + go p.doSubscribe(ctx, req, handler, key, trigger, subscribeID, stop) } - stop := make(chan struct{}) - p.subscribeStopChanMap.Store(subscribeID, stop) - go p.doSubscribe(ctx, req, handler, key, subscribeID, stop) return subscribeID, nil } func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration.UnsubscribeRequest) error { if oldStopChan, ok := p.subscribeStopChanMap.Load(req.ID); ok { p.subscribeStopChanMap.Delete(req.ID) + for k, v := range p.ActiveSubscriptions { + if v.uuid == req.ID { + delete(p.ActiveSubscriptions, k) + } + } close(oldStopChan.(chan struct{})) + return nil } - return nil + return fmt.Errorf("unable to find subscription with ID : %v", req.ID) } -func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler, channel string, id string, stop chan struct{}) { +func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler, channel string, trigger string, subscription string, stop chan struct{}) { conn, err := p.client.Acquire(ctx) if err != nil { - fmt.Fprintln(os.Stderr, "Error acquiring connection:", err) + p.logger.Errorf("Error acquiring connection:", err) + return } defer conn.Release() - ctxTimeout, cancel := context.WithTimeout(ctx, p.metadata.maxIdleTime) - defer cancel() - _, err = conn.Exec(ctxTimeout, channel) + _, err = conn.Exec(ctx, channel) if err != nil { p.logger.Errorf("Error listening to channel:", err) return } for { - notification, err := conn.Conn().WaitForNotification(ctxTimeout) + notification, err := conn.Conn().WaitForNotification(ctx) if err != nil { - if !(pgconn.Timeout(err) || errors.Is(ctxTimeout.Err(), context.Canceled)) { + if !(pgconn.Timeout(err) || errors.Is(ctx.Err(), context.Canceled)) { p.logger.Errorf("Error waiting for notification:", err) } return } - p.handleSubscribedChange(ctx, handler, notification, id) + p.handleSubscribedChange(ctx, handler, notification, trigger, subscription) } } -func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler configuration.UpdateHandler, msg *pgconn.Notification, id string) { +func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler configuration.UpdateHandler, msg *pgconn.Notification, trigger string, subscription string) { defer func() { if err := recover(); err != nil { p.logger.Errorf("panic in handleSubscribedChange method and recovered: %s", err) @@ -205,6 +232,10 @@ func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler switch strings.ToLower(strKey) { case "key": key = v.Interface().(string) + if yes := p.isSubscribed(trigger, key, subscription); !yes { + p.logger.Debugf("Ignoring notification for %v", key) + return + } case "value": value = v.Interface().(string) case "version": @@ -225,7 +256,7 @@ func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler Metadata: m, }, }, - ID: id, + ID: subscription, } err = handler(ctx, e) if err != nil { @@ -266,13 +297,6 @@ func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { } func Connect(ctx context.Context, conn string, maxTimeout time.Duration) (*pgxpool.Pool, error) { - cfg, err := pgxpool.ParseConfig(conn) - if err != nil { - return nil, fmt.Errorf("postgres configuration store configuration error : %s", err) - } - cfg.AfterConnect = func(ctx context.Context, conn *pgx.Conn) { - - } pool, err := pgxpool.Connect(ctx, conn) if err != nil { return nil, fmt.Errorf("postgres configuration store connection error : %s", err) @@ -294,20 +318,20 @@ func buildQuery(req *configuration.GetRequest, configTable string) (string, erro queryBuilder.WriteString(strings.Join(req.Keys, "','")) queryBuilder.WriteString("')") query = queryBuilder.String() - } - if len(req.Metadata) > 0 { - var s strings.Builder - i, j := len(req.Metadata), 0 - s.WriteString(" AND ") - for k, v := range req.Metadata { - temp := k + "='" + v + "'" - s.WriteString(temp) - if j++; j < i { - s.WriteString(" AND ") + if len(req.Metadata) > 0 { + var s strings.Builder + i, j := len(req.Metadata), 0 + s.WriteString(" AND ") + for k, v := range req.Metadata { + temp := k + "='" + v + "'" + s.WriteString(temp) + if j++; j < i { + s.WriteString(" AND ") + } } + query += s.String() } - query += s.String() } return query, nil } @@ -320,3 +344,27 @@ func QueryRow(ctx context.Context, p *pgxpool.Pool, query string, tbl string) er } return nil } + +func (p *ConfigurationStore) isSubscriptionActive(req *configuration.SubscribeRequest) (string, bool) { + for _, trigger := range req.Metadata { + for key2, sub := range p.ActiveSubscriptions { + if strings.ToLower(trigger) == strings.ToLower(key2) { + return sub.uuid, true + } + } + } + return " ", false +} + +func (p *ConfigurationStore) isSubscribed(trigger string, key string, subscription string) bool { + for t, s := range p.ActiveSubscriptions { + if t == trigger && s.uuid == subscription { + for _, k := range s.keys { + if k == key { + return true + } + } + } + } + return false +} From c8d69ad4652a214705f5ee3b7d46554a4498dda4 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Thu, 15 Sep 2022 15:22:31 +0530 Subject: [PATCH 07/39] fixed errors identified during functional testing Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index cdd217051..f163f8b34 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -116,7 +116,7 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ } return nil, err } - response := configuration.GetResponse{make(map[string]*configuration.Item)} + items := make(map[string]*configuration.Item) for i := 0; rows.Next(); i++ { var item configuration.Item var key string @@ -130,15 +130,19 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ return nil, err } item.Metadata = v - response.Items[key] = &item + if item.Value != "" { + items[key] = &item + } } - return &response, nil + return &configuration.GetResponse{ + Items: items, + }, nil } func (p *ConfigurationStore) Subscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler) (string, error) { - var triggers []string //req.Metadata + var triggers []string for k, v := range req.Metadata { - if k == strings.ToLower("trigger") { + if res := strings.EqualFold("trigger", k); res { triggers = append(triggers, v) } } @@ -151,7 +155,6 @@ func (p *ConfigurationStore) Subscribe(ctx context.Context, req *configuration.S for _, trigger := range triggers { key := "listen " + trigger if sub, isActive := p.isSubscriptionActive(req); isActive { - //unsubscribe the previous subscription if oldStopChan, ok := p.subscribeStopChanMap.Load(sub); ok { close(oldStopChan.(chan struct{})) } @@ -348,7 +351,7 @@ func QueryRow(ctx context.Context, p *pgxpool.Pool, query string, tbl string) er func (p *ConfigurationStore) isSubscriptionActive(req *configuration.SubscribeRequest) (string, bool) { for _, trigger := range req.Metadata { for key2, sub := range p.ActiveSubscriptions { - if strings.ToLower(trigger) == strings.ToLower(key2) { + if res := strings.EqualFold(trigger, key2); res { return sub.uuid, true } } From 4788ac86aad1dcc51cc9d8c1f1cf151a026ec7c2 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Fri, 16 Sep 2022 12:06:13 +0530 Subject: [PATCH 08/39] fixed SQL injection review comments Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 52 +++++++++++++++++++------ configuration/postgres/postgres_test.go | 27 ++++++++++++- 2 files changed, 65 insertions(+), 14 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index f163f8b34..ce73a3054 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -20,6 +20,8 @@ import ( "errors" "fmt" "reflect" + "regexp" + "strconv" "strings" "sync" "time" @@ -28,7 +30,6 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4/pgxpool" _ "github.com/jackc/pgx/v4/stdlib" - "golang.org/x/exp/utf8string" "github.com/dapr/components-contrib/configuration" "github.com/dapr/kit/logger" @@ -53,7 +54,7 @@ const ( connMaxIdleTimeKey = "connMaxIdleTime" connectionStringKey = "connectionString" ErrorMissingTableName = "missing postgreSQL configuration table name" - InfoStartInit = "Initializing postgreSQL configuration store" + InfoStartInit = "initializing postgreSQL configuration store" ErrorMissingConnectionString = "missing postgreSQL connection string" ErrorAlreadyInitialized = "PostgreSQL configuration store already initialized" ErrorMissinMaxTimeout = "missing PostgreSQL maxTimeout setting in configuration" @@ -103,12 +104,16 @@ func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { } func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequest) (*configuration.GetResponse, error) { - query, err := buildQuery(req, p.metadata.configTable) + if err := validateInput(req.Keys); err != nil { + p.logger.Error(err) + return nil, err + } + query, params, err := buildQuery(req, p.metadata.configTable) if err != nil { p.logger.Error(err) return nil, err } - rows, err := p.client.Query(ctx, query) + rows, err := p.client.Query(ctx, query, params...) if err != nil { // If no rows exist, return an empty response, otherwise return the error. if err == sql.ErrNoRows { @@ -277,8 +282,8 @@ func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { } if tbl, ok := cmetadata.Properties[configtablekey]; ok && tbl != "" { - if !utf8string.NewString(tbl).IsASCII() { - return m, fmt.Errorf("invalid table name : '%v'. non-ascii characters are not supported", tbl) + if !regexp.MustCompile(`^[a-zA-Z0-9]*$`).MatchString(tbl) { + return m, fmt.Errorf("invalid table name : '%v'. non-alphanumerics are not supported", tbl) } if len(tbl) > maxIdentifierLength { return m, fmt.Errorf(ErrorTooLongFieldLength+" - tableName : '%v'. max allowed field length is %v ", tbl, maxIdentifierLength) @@ -311,15 +316,24 @@ func Connect(ctx context.Context, conn string, maxTimeout time.Duration) (*pgxpo return pool, nil } -func buildQuery(req *configuration.GetRequest, configTable string) (string, error) { +func buildQuery(req *configuration.GetRequest, configTable string) (string, []interface{}, error) { var query string + var params []interface{} if len(req.Keys) == 0 { query = "SELECT * FROM " + configTable } else { var queryBuilder strings.Builder - queryBuilder.WriteString("SELECT * FROM " + configTable + " WHERE KEY IN ('") - queryBuilder.WriteString(strings.Join(req.Keys, "','")) - queryBuilder.WriteString("')") + queryBuilder.WriteString("SELECT * FROM " + configTable + " WHERE KEY IN (") + var paramWildcard []string + paramPosition := 1 + for _, v := range req.Keys { + paramWildcard = append(paramWildcard, "$"+strconv.Itoa(paramPosition)) + params = append(params, v) + paramPosition++ + } + queryBuilder.WriteString(strings.Join(paramWildcard, " , ")) + queryBuilder.WriteString(")") + query = queryBuilder.String() if len(req.Metadata) > 0 { @@ -327,8 +341,10 @@ func buildQuery(req *configuration.GetRequest, configTable string) (string, erro i, j := len(req.Metadata), 0 s.WriteString(" AND ") for k, v := range req.Metadata { - temp := k + "='" + v + "'" + temp := "$" + strconv.Itoa(paramPosition) + " = " + "$" + strconv.Itoa(paramPosition+1) s.WriteString(temp) + params = append(params, k, v) + paramPosition += 2 if j++; j < i { s.WriteString(" AND ") } @@ -336,7 +352,7 @@ func buildQuery(req *configuration.GetRequest, configTable string) (string, erro query += s.String() } } - return query, nil + return query, params, nil } func QueryRow(ctx context.Context, p *pgxpool.Pool, query string, tbl string) error { @@ -371,3 +387,15 @@ func (p *ConfigurationStore) isSubscribed(trigger string, key string, subscripti } return false } + +func validateInput(keys []string) error { + if len(keys) == 0 { + return nil + } + for _, key := range keys { + if !regexp.MustCompile(`^[a-zA-Z0-9]*$`).MatchString(key) { + return fmt.Errorf("invalid key : '%v'", key) + } + } + return nil +} diff --git a/configuration/postgres/postgres_test.go b/configuration/postgres/postgres_test.go index faceae11f..3962fd871 100644 --- a/configuration/postgres/postgres_test.go +++ b/configuration/postgres/postgres_test.go @@ -31,14 +31,37 @@ func TestPostgresbuildQuery(t *testing.T) { }, } - query, err := buildQuery(g, "cfgtbl") + query, params, err := buildQuery(g, "cfgtbl") + _ = params if err != nil { t.Errorf("Error building query: %v ", err) } - expected := "SELECT * FROM cfgtbl WHERE KEY IN ('someKey') AND Version='1.0'" + expected := "SELECT * FROM cfgtbl WHERE KEY IN ($1) AND $2 = $3" if query != expected { t.Errorf("Did not get expected result. Got: '%v' , Expected: '%v'", query, expected) } + i := 0 + for _, v := range params { + got := v.(string) + switch i { + case 0: + expected := "someKey" + if expected != got { + t.Errorf("Did not get expected result. Got: '%v' , Expected: '%v'", got, expected) + } + case 1: + expected := "Version" + if expected != got { + t.Errorf("Did not get expected result. Got: '%v' , Expected: '%v'", got, expected) + } + case 2: + expected := "1.0" + if expected != got { + t.Errorf("Did not get expected result. Got: '%v' , Expected: '%v'", got, expected) + } + } + i++ + } } func TestConnectAndQuery(t *testing.T) { From cb22194e6985a0d4e6a50aea8ede7f1bac02022f Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Fri, 9 Sep 2022 18:39:15 +0530 Subject: [PATCH 09/39] Support Postgres as configuration store #4551 Signed-off-by: akhilac1 --- configuration/postgres/metadata.go | 22 ++ configuration/postgres/postgres.go | 296 ++++++++++++++++++++++++ configuration/postgres/postgres_test.go | 71 ++++++ 3 files changed, 389 insertions(+) create mode 100644 configuration/postgres/metadata.go create mode 100644 configuration/postgres/postgres.go create mode 100644 configuration/postgres/postgres_test.go diff --git a/configuration/postgres/metadata.go b/configuration/postgres/metadata.go new file mode 100644 index 000000000..389bf9199 --- /dev/null +++ b/configuration/postgres/metadata.go @@ -0,0 +1,22 @@ +/* +Copyright 2021 The Dapr Authors +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. +*/ + +package postgres + +import "time" + +type metadata struct { + maxIdleTime time.Duration + connectionString string + configTable string +} diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go new file mode 100644 index 000000000..ae0f29ada --- /dev/null +++ b/configuration/postgres/postgres.go @@ -0,0 +1,296 @@ +/* +Copyright 2021 The Dapr Authors +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. +*/ + +package postgres + +import ( + "context" + "database/sql" + "encoding/json" + "fmt" + "os" + "reflect" + "strings" + "sync" + "time" + + "github.com/dapr/components-contrib/configuration" + "github.com/dapr/kit/logger" + "github.com/google/uuid" + "github.com/jackc/pgconn" + "github.com/jackc/pgx/v4/pgxpool" + _ "github.com/jackc/pgx/v4/stdlib" +) + +type PostgresConfigStore struct { + metadata metadata + pool *pgxpool.Pool + logger logger.Logger + subscribeStopChanMap sync.Map +} + +const ( + configtablekey = "table" + connMaxIdleTimeKey = "connMaxIdleTime" + connectionStringKey = "connectionString" + ErrorMissingTableName = "missing postgreSQL configuration table name" + InfoStartInit = "Initializing PostgreSQL state store" + ErrorMissingConnectionString = "missing postgreSQL connection string" + ErrorAlreadyInitialized = "PostgreSQL configuration store already initialized" + ErrorMissinMaxTimeout = "missing PostgreSQL maxTimeout setting in configuration" + QueryTableExists = "SELECT EXISTS (SELECT FROM pg_tables where tablename = $1)" +) + +func NewPostgresConfigurationStore(logger logger.Logger) *PostgresConfigStore { + logger.Debug("Instantiating PostgreSQL configuration store") + return &PostgresConfigStore{ + logger: logger, + } +} + +func (p *PostgresConfigStore) Init(metadata configuration.Metadata) error { + p.logger.Debug(InfoStartInit) + if p.pool != nil { + return fmt.Errorf(ErrorAlreadyInitialized) + } + if m, err := parseMetadata(metadata); err != nil { + p.logger.Error(err) + return err + } else { + p.metadata = m + } + + ctx := context.Background() + pool, err := Connect(ctx, p.metadata.connectionString) + if err != nil { + return err + } + p.pool = pool + pingErr := p.pool.Ping(ctx) + if pingErr != nil { + return pingErr + } + + // check if table exists + exists := false + err = p.pool.QueryRow(ctx, QueryTableExists, p.metadata.configTable).Scan(&exists) + if err != nil { + return err + } + return nil +} + +func (p *PostgresConfigStore) Get(ctx context.Context, req *configuration.GetRequest) (*configuration.GetResponse, error) { + query, err := buildQuery(req, p.metadata.configTable) + if err != nil { + p.logger.Error(err) + return nil, err + } + + rows, err := p.pool.Query(ctx, query) + if err != nil { + // If no rows exist, return an empty response, otherwise return the error. + if err == sql.ErrNoRows { + return &configuration.GetResponse{}, nil + } + return nil, err + } + response := configuration.GetResponse{} + for i := 0; rows.Next(); i++ { + var item configuration.Item + var key string + var metadata []byte + var v = make(map[string]string) + + if err := rows.Scan(key, &item.Value, &item.Version, &metadata); err != nil { + return nil, err + } + if err := json.Unmarshal(metadata, &v); err != nil { + return nil, err + } + item.Metadata = v + response.Items[key] = &item + } + return &response, nil +} + +func (p *PostgresConfigStore) Subscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler) (string, error) { + subscribeID := uuid.New().String() + key := "listen " + p.metadata.configTable + // subscribe to events raised on the configTable + if oldStopChan, ok := p.subscribeStopChanMap.Load(key); ok { + close(oldStopChan.(chan struct{})) + } + stop := make(chan struct{}) + p.subscribeStopChanMap.Store(subscribeID, stop) + go p.doSubscribe(ctx, req, handler, key, subscribeID, stop) + return subscribeID, nil +} + +func (p *PostgresConfigStore) Unsubscribe(ctx context.Context, req *configuration.UnsubscribeRequest) error { + if oldStopChan, ok := p.subscribeStopChanMap.Load(req.ID); ok { + p.subscribeStopChanMap.Delete(req.ID) + close(oldStopChan.(chan struct{})) + } + return nil +} + +func (p *PostgresConfigStore) doSubscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler, channel string, id string, stop chan struct{}) { + conn, err := p.pool.Acquire(ctx) + if err != nil { + fmt.Fprintln(os.Stderr, "Error acquiring connection:", err) + } + defer conn.Release() + + _, err = conn.Exec(context.Background(), channel) + if err != nil { + p.logger.Errorf("Error listening to channel:", err) + return + } + + for { + notification, err := conn.Conn().WaitForNotification(ctx) + if err != nil { + p.logger.Errorf("Error waiting for notification:", err) + return + } + p.handleSubscribedChange(ctx, handler, notification, id) + } +} + +func (p *PostgresConfigStore) handleSubscribedChange(ctx context.Context, handler configuration.UpdateHandler, msg *pgconn.Notification, id string) { + defer func() { + if err := recover(); err != nil { + p.logger.Errorf("panic in handleSubscribedChange()method and recovered: %s", err) + } + }() + payload := make(map[string]interface{}) + err := json.Unmarshal([]byte(msg.Payload), &payload) + if err != nil { + p.logger.Errorf("Error in UnMarshall: ", err) + return + } + + var key, value, version string + m := make(map[string]string) + // trigger should encapsulate the row in "data" field in the notification + row := reflect.ValueOf(payload["data"]) + if row.Kind() == reflect.Map { + for _, k := range row.MapKeys() { + v := row.MapIndex(k) + strKey := k.Interface().(string) + switch strings.ToLower(strKey) { + case "key": + key = v.Interface().(string) + case "value": + value = v.Interface().(string) + case "version": + version = v.Interface().(string) + case "metadata": + a := v.Interface().(map[string]interface{}) + for k, v := range a { + m[k] = v.(string) + } + } + } + } + e := &configuration.UpdateEvent{ + Items: map[string]*configuration.Item{ + key: { + Value: value, + Version: version, + Metadata: m, + }, + }, + ID: id, + } + err = handler(ctx, e) + if err != nil { + p.logger.Errorf("fail to call handler to notify event for configuration update subscribe: %s", err) + } +} + +func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { + m := metadata{} + + if val, ok := cmetadata.Properties[connectionStringKey]; ok && val != "" { + m.connectionString = val + } else { + return m, fmt.Errorf(ErrorMissingConnectionString) + } + + if tbl, ok := cmetadata.Properties[configtablekey]; ok && tbl != "" { + m.configTable = tbl + } else { + return m, fmt.Errorf(ErrorMissingTableName) + } + + // configure maxTimeout if provided + if mxTimeout, ok := cmetadata.Properties[connMaxIdleTimeKey]; ok && mxTimeout != "" { + if t, err := time.ParseDuration(mxTimeout); err == nil { + m.maxIdleTime = t + } else { + return m, fmt.Errorf(ErrorMissinMaxTimeout) + } + } + return m, nil +} + +func Connect(ctx context.Context, conn string) (*pgxpool.Pool, error) { + pool, err := pgxpool.Connect(ctx, conn) + if err != nil { + return nil, fmt.Errorf("postgres configuration store connection error : %s", err) + } + pingErr := pool.Ping(context.Background()) + if pingErr != nil { + return nil, fmt.Errorf("postgres configuration store ping error : %s", pingErr) + } + return pool, nil +} + +func buildQuery(req *configuration.GetRequest, configTable string) (string, error) { + var query string + if len(req.Keys) == 0 { + query = "SELECT * FROM " + configTable + } else { + var queryBuilder strings.Builder + queryBuilder.WriteString("SELECT * FROM " + configTable + " WHERE KEY IN ('") + queryBuilder.WriteString(strings.Join(req.Keys, "','")) + queryBuilder.WriteString("')") + query = queryBuilder.String() + } + + if len(req.Metadata) > 0 { + var s strings.Builder + i, j := len(req.Metadata), 0 + s.WriteString(" AND ") + for k, v := range req.Metadata { + temp := k + "='" + v + "'" + s.WriteString(temp) + if j++; j < i { + s.WriteString(" AND ") + } + } + query += s.String() + } + return query, nil +} + +func QueryRow(ctx context.Context, p *pgxpool.Pool, query string, tbl string) error { + exists := false + err := p.QueryRow(ctx, query, tbl).Scan(&exists) + if err != nil { + return fmt.Errorf("postgres configuration store query error : %s", err) + } + return nil +} diff --git a/configuration/postgres/postgres_test.go b/configuration/postgres/postgres_test.go new file mode 100644 index 000000000..73a2362b1 --- /dev/null +++ b/configuration/postgres/postgres_test.go @@ -0,0 +1,71 @@ +/* +Copyright 2021 The Dapr Authors +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. +*/ + +package postgres + +import ( + "context" + "regexp" + "testing" + + "github.com/dapr/components-contrib/configuration" + "github.com/pashagolub/pgxmock" +) + +func TestPostgresbuildQuery(t *testing.T) { + g := &configuration.GetRequest{ + Keys: []string{"someKey"}, + Metadata: map[string]string{ + "Version": "1.0", + }, + } + + query, err := buildQuery(g, "cfgtbl") + if err != nil { + t.Errorf("Error building query: %v ", err) + } + expected := "SELECT * FROM cfgtbl WHERE KEY IN ('someKey') AND Version='1.0'" + if query != expected { + t.Errorf("Did not get expected result. Got: '%v' , Expected: '%v'", query, expected) + } +} + +func TestConnectAndQuery(t *testing.T) { + m := metadata{ + connectionString: "mockConnectionString", + configTable: "mockConfigTable", + } + + mock, err := pgxmock.NewPool() + if err != nil { + t.Fatalf("an error '%s' was not expected when opening a stub database connection", err) + } + defer mock.Close() + + query := "SELECT EXISTS (SELECT FROM pg_tables where tablename = '" + m.configTable + "'" + mock.ExpectQuery(regexp.QuoteMeta(query)). + WillReturnRows(pgxmock.NewRows( + []string{"exists"}). + AddRow(string("t")), + ) + rows := mock.QueryRow(context.Background(), query) + var id string + err = rows.Scan(&id) + if err != nil { + t.Error(err) + } + if err := mock.ExpectationsWereMet(); err != nil { + t.Errorf("there were unfulfilled expectations: %s", err) + } + +} From e8707925958eb803d456a685e5cdb7ce6e5b6488 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Fri, 9 Sep 2022 20:30:07 +0530 Subject: [PATCH 10/39] Support Postgres config store Signed-off-by: akhilac1 --- go.mod | 11 ++++++----- go.sum | 21 ++++++++++++--------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index b0e55db13..4079212ba 100644 --- a/go.mod +++ b/go.mod @@ -80,7 +80,7 @@ require ( github.com/imkira/go-interpol v1.1.0 // indirect github.com/influxdata/influxdb-client-go v1.4.0 github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097 // indirect - github.com/jackc/pgx/v4 v4.15.0 + github.com/jackc/pgx/v4 v4.17.0 github.com/jcmturner/gofork v1.0.0 // indirect github.com/json-iterator/go v1.1.12 github.com/kataras/go-errors v0.0.3 // indirect @@ -98,6 +98,7 @@ require ( github.com/nats-io/nats.go v1.13.1-0.20220308171302-2f2f6968e98d github.com/nats-io/stan.go v0.8.3 github.com/open-policy-agent/opa v0.42.0 + github.com/pashagolub/pgxmock v1.8.0 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/pkg/errors v0.9.1 github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 // indirect @@ -120,7 +121,7 @@ require ( github.com/yuin/gopher-lua v0.0.0-20200603152657-dc2b0ca8b37e // indirect go.mongodb.org/mongo-driver v1.5.1 go.opencensus.io v0.23.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa golang.org/x/net v0.0.0-20220630215102-69896b714898 golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a google.golang.org/api v0.74.0 @@ -472,12 +473,12 @@ require ( github.com/hashicorp/go-uuid v1.0.2 // indirect github.com/hashicorp/serf v0.9.6 // indirect github.com/jackc/chunkreader/v2 v2.0.1 // indirect - github.com/jackc/pgconn v1.11.0 // indirect + github.com/jackc/pgconn v1.13.0 github.com/jackc/pgio v1.0.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect - github.com/jackc/pgproto3/v2 v2.2.0 // indirect + github.com/jackc/pgproto3/v2 v2.3.1 // indirect github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect - github.com/jackc/pgtype v1.10.0 // indirect + github.com/jackc/pgtype v1.12.0 // indirect github.com/jackc/puddle v1.2.1 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jpillora/backoff v1.0.0 // indirect diff --git a/go.sum b/go.sum index 52605a20e..63e3a51b8 100644 --- a/go.sum +++ b/go.sum @@ -1556,8 +1556,8 @@ github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsU github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= -github.com/jackc/pgconn v1.11.0 h1:HiHArx4yFbwl91X3qqIHtUFoiIfLNJXCQRsnzkiwwaQ= -github.com/jackc/pgconn v1.11.0/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= +github.com/jackc/pgconn v1.13.0 h1:3L1XMNV2Zvca/8BYhzcRFS70Lr0WlDg16Di6SFGAbys= +github.com/jackc/pgconn v1.13.0/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI= github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= @@ -1573,22 +1573,22 @@ github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvW github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.2.0 h1:r7JypeP2D3onoQTCxWdTpCtJ4D+qpKr0TxvoyMhZ5ns= -github.com/jackc/pgproto3/v2 v2.2.0/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.3.1 h1:nwj7qwf0S+Q7ISFfBndqeLwSwxs+4DPsbRFjECT1Y4Y= +github.com/jackc/pgproto3/v2 v2.3.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= -github.com/jackc/pgtype v1.10.0 h1:ILnBWrRMSXGczYvmkYD6PsYyVFUNLTnIUJHHDLmqk38= -github.com/jackc/pgtype v1.10.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= +github.com/jackc/pgtype v1.12.0 h1:Dlq8Qvcch7kiehm8wPGIW0W3KsCCHJnRacKW0UM8n5w= +github.com/jackc/pgtype v1.12.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= -github.com/jackc/pgx/v4 v4.15.0 h1:B7dTkXsdILD3MF987WGGCcg+tvLW6bZJdEcqVFeU//w= -github.com/jackc/pgx/v4 v4.15.0/go.mod h1:D/zyOyXiaM1TmVWnOM18p0xdDtdakRBa0RsVGI3U3bw= +github.com/jackc/pgx/v4 v4.17.0 h1:Hsx+baY8/zU2WtPLQyZi8WbecgcsWEeyoK1jvg/WgIo= +github.com/jackc/pgx/v4 v4.17.0/go.mod h1:Gd6RmOhtFLTu8cp/Fhq4kP195KrshxYJH3oW8AWJ1pw= github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= @@ -2489,6 +2489,8 @@ github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIw github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pashagolub/pgxmock v1.8.0 h1:05JB+jng7yPdeC6i04i8TC4H1Kr7TfcFeQyf4JP6534= +github.com/pashagolub/pgxmock v1.8.0/go.mod h1:kDkER7/KJdD3HQjNvFw5siwR7yREKmMvwf8VhAgTK5o= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= @@ -3137,8 +3139,9 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= From ddc130640e34c8f05937d915b07a5653f617f122 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Fri, 9 Sep 2022 21:26:47 +0530 Subject: [PATCH 11/39] Support for Postgres configuration store Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 34 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index ae0f29ada..31c156d7d 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -32,9 +32,9 @@ import ( _ "github.com/jackc/pgx/v4/stdlib" ) -type PostgresConfigStore struct { +type ConfigurationStore struct { metadata metadata - pool *pgxpool.Pool + client *pgxpool.Pool logger logger.Logger subscribeStopChanMap sync.Map } @@ -51,16 +51,16 @@ const ( QueryTableExists = "SELECT EXISTS (SELECT FROM pg_tables where tablename = $1)" ) -func NewPostgresConfigurationStore(logger logger.Logger) *PostgresConfigStore { +func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store { logger.Debug("Instantiating PostgreSQL configuration store") - return &PostgresConfigStore{ + return &ConfigurationStore{ logger: logger, } } -func (p *PostgresConfigStore) Init(metadata configuration.Metadata) error { +func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { p.logger.Debug(InfoStartInit) - if p.pool != nil { + if p.client != nil { return fmt.Errorf(ErrorAlreadyInitialized) } if m, err := parseMetadata(metadata); err != nil { @@ -71,33 +71,33 @@ func (p *PostgresConfigStore) Init(metadata configuration.Metadata) error { } ctx := context.Background() - pool, err := Connect(ctx, p.metadata.connectionString) + client, err := Connect(ctx, p.metadata.connectionString) if err != nil { return err } - p.pool = pool - pingErr := p.pool.Ping(ctx) + p.client = client + pingErr := p.client.Ping(ctx) if pingErr != nil { return pingErr } // check if table exists exists := false - err = p.pool.QueryRow(ctx, QueryTableExists, p.metadata.configTable).Scan(&exists) + err = p.client.QueryRow(ctx, QueryTableExists, p.metadata.configTable).Scan(&exists) if err != nil { return err } return nil } -func (p *PostgresConfigStore) Get(ctx context.Context, req *configuration.GetRequest) (*configuration.GetResponse, error) { +func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequest) (*configuration.GetResponse, error) { query, err := buildQuery(req, p.metadata.configTable) if err != nil { p.logger.Error(err) return nil, err } - rows, err := p.pool.Query(ctx, query) + rows, err := p.client.Query(ctx, query) if err != nil { // If no rows exist, return an empty response, otherwise return the error. if err == sql.ErrNoRows { @@ -124,7 +124,7 @@ func (p *PostgresConfigStore) Get(ctx context.Context, req *configuration.GetReq return &response, nil } -func (p *PostgresConfigStore) Subscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler) (string, error) { +func (p *ConfigurationStore) Subscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler) (string, error) { subscribeID := uuid.New().String() key := "listen " + p.metadata.configTable // subscribe to events raised on the configTable @@ -137,7 +137,7 @@ func (p *PostgresConfigStore) Subscribe(ctx context.Context, req *configuration. return subscribeID, nil } -func (p *PostgresConfigStore) Unsubscribe(ctx context.Context, req *configuration.UnsubscribeRequest) error { +func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration.UnsubscribeRequest) error { if oldStopChan, ok := p.subscribeStopChanMap.Load(req.ID); ok { p.subscribeStopChanMap.Delete(req.ID) close(oldStopChan.(chan struct{})) @@ -145,8 +145,8 @@ func (p *PostgresConfigStore) Unsubscribe(ctx context.Context, req *configuratio return nil } -func (p *PostgresConfigStore) doSubscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler, channel string, id string, stop chan struct{}) { - conn, err := p.pool.Acquire(ctx) +func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler, channel string, id string, stop chan struct{}) { + conn, err := p.client.Acquire(ctx) if err != nil { fmt.Fprintln(os.Stderr, "Error acquiring connection:", err) } @@ -168,7 +168,7 @@ func (p *PostgresConfigStore) doSubscribe(ctx context.Context, req *configuratio } } -func (p *PostgresConfigStore) handleSubscribedChange(ctx context.Context, handler configuration.UpdateHandler, msg *pgconn.Notification, id string) { +func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler configuration.UpdateHandler, msg *pgconn.Notification, id string) { defer func() { if err := recover(); err != nil { p.logger.Errorf("panic in handleSubscribedChange()method and recovered: %s", err) From cf413bf8fc8c60f9cd7e1f38fdad68cde206235a Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Mon, 12 Sep 2022 18:16:15 +0530 Subject: [PATCH 12/39] updating review comments Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 36 +++++++++++++++++-------- configuration/postgres/postgres_test.go | 1 - 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index 31c156d7d..f8be9799f 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -17,6 +17,7 @@ import ( "context" "database/sql" "encoding/json" + "errors" "fmt" "os" "reflect" @@ -30,6 +31,7 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4/pgxpool" _ "github.com/jackc/pgx/v4/stdlib" + "golang.org/x/exp/utf8string" ) type ConfigurationStore struct { @@ -49,6 +51,8 @@ const ( ErrorAlreadyInitialized = "PostgreSQL configuration store already initialized" ErrorMissinMaxTimeout = "missing PostgreSQL maxTimeout setting in configuration" QueryTableExists = "SELECT EXISTS (SELECT FROM pg_tables where tablename = $1)" + maxIdentifierLength = 64 // https://www.postgresql.org/docs/current/limits.html + ErrorTooLongFieldLength = "field name is too long" ) func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store { @@ -70,8 +74,9 @@ func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { p.metadata = m } - ctx := context.Background() - client, err := Connect(ctx, p.metadata.connectionString) + ctx, cancel := context.WithTimeout(context.Background(), p.metadata.maxIdleTime) + defer cancel() + client, err := Connect(ctx, p.metadata.connectionString, p.metadata.maxIdleTime) if err != nil { return err } @@ -110,7 +115,7 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ var item configuration.Item var key string var metadata []byte - var v = make(map[string]string) + v := make(map[string]string) if err := rows.Scan(key, &item.Value, &item.Version, &metadata); err != nil { return nil, err @@ -151,17 +156,20 @@ func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration fmt.Fprintln(os.Stderr, "Error acquiring connection:", err) } defer conn.Release() - - _, err = conn.Exec(context.Background(), channel) + ctxTimeout, cancel := context.WithTimeout(ctx, p.metadata.maxIdleTime) + defer cancel() + _, err = conn.Exec(ctxTimeout, channel) if err != nil { p.logger.Errorf("Error listening to channel:", err) return } for { - notification, err := conn.Conn().WaitForNotification(ctx) + notification, err := conn.Conn().WaitForNotification(ctxTimeout) if err != nil { - p.logger.Errorf("Error waiting for notification:", err) + if !(pgconn.Timeout(err) || errors.Is(ctxTimeout.Err(), context.Canceled)) { + p.logger.Errorf("Error waiting for notification:", err) + } return } p.handleSubscribedChange(ctx, handler, notification, id) @@ -171,13 +179,13 @@ func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler configuration.UpdateHandler, msg *pgconn.Notification, id string) { defer func() { if err := recover(); err != nil { - p.logger.Errorf("panic in handleSubscribedChange()method and recovered: %s", err) + p.logger.Errorf("panic in handleSubscribedChange method and recovered: %s", err) } }() payload := make(map[string]interface{}) err := json.Unmarshal([]byte(msg.Payload), &payload) if err != nil { - p.logger.Errorf("Error in UnMarshall: ", err) + p.logger.Errorf("Error in UnMarshal: ", err) return } @@ -230,6 +238,12 @@ func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { } if tbl, ok := cmetadata.Properties[configtablekey]; ok && tbl != "" { + if !utf8string.NewString(tbl).IsASCII() { + return m, fmt.Errorf("invalid table name : '%v'. non-ascii characters are not supported", tbl) + } + if len(tbl) > maxIdentifierLength { + return m, fmt.Errorf(ErrorTooLongFieldLength+" - tableName : '%v'. max allowed field length is %v ", tbl, maxIdentifierLength) + } m.configTable = tbl } else { return m, fmt.Errorf(ErrorMissingTableName) @@ -246,12 +260,12 @@ func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { return m, nil } -func Connect(ctx context.Context, conn string) (*pgxpool.Pool, error) { +func Connect(ctx context.Context, conn string, maxTimeout time.Duration) (*pgxpool.Pool, error) { pool, err := pgxpool.Connect(ctx, conn) if err != nil { return nil, fmt.Errorf("postgres configuration store connection error : %s", err) } - pingErr := pool.Ping(context.Background()) + pingErr := pool.Ping(ctx) if pingErr != nil { return nil, fmt.Errorf("postgres configuration store ping error : %s", pingErr) } diff --git a/configuration/postgres/postgres_test.go b/configuration/postgres/postgres_test.go index 73a2362b1..2f954c7a6 100644 --- a/configuration/postgres/postgres_test.go +++ b/configuration/postgres/postgres_test.go @@ -67,5 +67,4 @@ func TestConnectAndQuery(t *testing.T) { if err := mock.ExpectationsWereMet(); err != nil { t.Errorf("there were unfulfilled expectations: %s", err) } - } From 584c80a66722fcf59049bc832fc8e732a1e2c898 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Tue, 13 Sep 2022 17:20:49 +0530 Subject: [PATCH 13/39] fixing lint errors Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 18 +++++++++++++++--- configuration/postgres/postgres_test.go | 3 ++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index f8be9799f..9b7283e4c 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -25,13 +25,15 @@ import ( "sync" "time" - "github.com/dapr/components-contrib/configuration" - "github.com/dapr/kit/logger" "github.com/google/uuid" "github.com/jackc/pgconn" + "github.com/jackc/pgx" "github.com/jackc/pgx/v4/pgxpool" _ "github.com/jackc/pgx/v4/stdlib" "golang.org/x/exp/utf8string" + + "github.com/dapr/components-contrib/configuration" + "github.com/dapr/kit/logger" ) type ConfigurationStore struct { @@ -55,6 +57,10 @@ const ( ErrorTooLongFieldLength = "field name is too long" ) +const ( + queryKey = `SELECT * ` +) + func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store { logger.Debug("Instantiating PostgreSQL configuration store") return &ConfigurationStore{ @@ -101,7 +107,6 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ p.logger.Error(err) return nil, err } - rows, err := p.client.Query(ctx, query) if err != nil { // If no rows exist, return an empty response, otherwise return the error. @@ -261,6 +266,13 @@ func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { } func Connect(ctx context.Context, conn string, maxTimeout time.Duration) (*pgxpool.Pool, error) { + cfg, err := pgxpool.ParseConfig(conn) + if err != nil { + return nil, fmt.Errorf("postgres configuration store configuration error : %s", err) + } + cfg.AfterConnect = func(ctx context.Context, conn *pgx.Conn) { + + } pool, err := pgxpool.Connect(ctx, conn) if err != nil { return nil, fmt.Errorf("postgres configuration store connection error : %s", err) diff --git a/configuration/postgres/postgres_test.go b/configuration/postgres/postgres_test.go index 2f954c7a6..faceae11f 100644 --- a/configuration/postgres/postgres_test.go +++ b/configuration/postgres/postgres_test.go @@ -18,8 +18,9 @@ import ( "regexp" "testing" - "github.com/dapr/components-contrib/configuration" "github.com/pashagolub/pgxmock" + + "github.com/dapr/components-contrib/configuration" ) func TestPostgresbuildQuery(t *testing.T) { From 1e5c5a4ba8868e2c5a788f07a346ef60d3835e08 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Thu, 15 Sep 2022 14:13:33 +0530 Subject: [PATCH 14/39] fixed errors identified during functional testing Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 144 +++++++++++++++++++---------- 1 file changed, 96 insertions(+), 48 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index 9b7283e4c..cdd217051 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -19,7 +19,6 @@ import ( "encoding/json" "errors" "fmt" - "os" "reflect" "strings" "sync" @@ -27,7 +26,6 @@ import ( "github.com/google/uuid" "github.com/jackc/pgconn" - "github.com/jackc/pgx" "github.com/jackc/pgx/v4/pgxpool" _ "github.com/jackc/pgx/v4/stdlib" "golang.org/x/exp/utf8string" @@ -41,6 +39,13 @@ type ConfigurationStore struct { client *pgxpool.Pool logger logger.Logger subscribeStopChanMap sync.Map + ActiveSubscriptions map[string]*subscription +} + +type subscription struct { + uuid string + trigger string + keys []string } const ( @@ -48,7 +53,7 @@ const ( connMaxIdleTimeKey = "connMaxIdleTime" connectionStringKey = "connectionString" ErrorMissingTableName = "missing postgreSQL configuration table name" - InfoStartInit = "Initializing PostgreSQL state store" + InfoStartInit = "Initializing postgreSQL configuration store" ErrorMissingConnectionString = "missing postgreSQL connection string" ErrorAlreadyInitialized = "PostgreSQL configuration store already initialized" ErrorMissinMaxTimeout = "missing PostgreSQL maxTimeout setting in configuration" @@ -57,10 +62,6 @@ const ( ErrorTooLongFieldLength = "field name is too long" ) -const ( - queryKey = `SELECT * ` -) - func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store { logger.Debug("Instantiating PostgreSQL configuration store") return &ConfigurationStore{ @@ -70,6 +71,7 @@ func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store { func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { p.logger.Debug(InfoStartInit) + if p.client != nil { return fmt.Errorf(ErrorAlreadyInitialized) } @@ -79,7 +81,7 @@ func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { } else { p.metadata = m } - + p.ActiveSubscriptions = make(map[string]*subscription) ctx, cancel := context.WithTimeout(context.Background(), p.metadata.maxIdleTime) defer cancel() client, err := Connect(ctx, p.metadata.connectionString, p.metadata.maxIdleTime) @@ -91,7 +93,6 @@ func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { if pingErr != nil { return pingErr } - // check if table exists exists := false err = p.client.QueryRow(ctx, QueryTableExists, p.metadata.configTable).Scan(&exists) @@ -115,14 +116,14 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ } return nil, err } - response := configuration.GetResponse{} + response := configuration.GetResponse{make(map[string]*configuration.Item)} for i := 0; rows.Next(); i++ { var item configuration.Item var key string var metadata []byte v := make(map[string]string) - if err := rows.Scan(key, &item.Value, &item.Version, &metadata); err != nil { + if err := rows.Scan(&key, &item.Value, &item.Version, &metadata); err != nil { return nil, err } if err := json.Unmarshal(metadata, &v); err != nil { @@ -135,53 +136,79 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ } func (p *ConfigurationStore) Subscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler) (string, error) { - subscribeID := uuid.New().String() - key := "listen " + p.metadata.configTable - // subscribe to events raised on the configTable - if oldStopChan, ok := p.subscribeStopChanMap.Load(key); ok { - close(oldStopChan.(chan struct{})) + var triggers []string //req.Metadata + for k, v := range req.Metadata { + if k == strings.ToLower("trigger") { + triggers = append(triggers, v) + } + } + + if len(triggers) == 0 { + return "", fmt.Errorf("cannot subscribe to empty trigger") + } + + var subscribeID string + for _, trigger := range triggers { + key := "listen " + trigger + if sub, isActive := p.isSubscriptionActive(req); isActive { + //unsubscribe the previous subscription + if oldStopChan, ok := p.subscribeStopChanMap.Load(sub); ok { + close(oldStopChan.(chan struct{})) + } + } + stop := make(chan struct{}) + subscribeID = uuid.New().String() + p.subscribeStopChanMap.Store(subscribeID, stop) + p.ActiveSubscriptions[trigger] = &subscription{ + uuid: subscribeID, + trigger: trigger, + keys: req.Keys, + } + go p.doSubscribe(ctx, req, handler, key, trigger, subscribeID, stop) } - stop := make(chan struct{}) - p.subscribeStopChanMap.Store(subscribeID, stop) - go p.doSubscribe(ctx, req, handler, key, subscribeID, stop) return subscribeID, nil } func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration.UnsubscribeRequest) error { if oldStopChan, ok := p.subscribeStopChanMap.Load(req.ID); ok { p.subscribeStopChanMap.Delete(req.ID) + for k, v := range p.ActiveSubscriptions { + if v.uuid == req.ID { + delete(p.ActiveSubscriptions, k) + } + } close(oldStopChan.(chan struct{})) + return nil } - return nil + return fmt.Errorf("unable to find subscription with ID : %v", req.ID) } -func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler, channel string, id string, stop chan struct{}) { +func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler, channel string, trigger string, subscription string, stop chan struct{}) { conn, err := p.client.Acquire(ctx) if err != nil { - fmt.Fprintln(os.Stderr, "Error acquiring connection:", err) + p.logger.Errorf("Error acquiring connection:", err) + return } defer conn.Release() - ctxTimeout, cancel := context.WithTimeout(ctx, p.metadata.maxIdleTime) - defer cancel() - _, err = conn.Exec(ctxTimeout, channel) + _, err = conn.Exec(ctx, channel) if err != nil { p.logger.Errorf("Error listening to channel:", err) return } for { - notification, err := conn.Conn().WaitForNotification(ctxTimeout) + notification, err := conn.Conn().WaitForNotification(ctx) if err != nil { - if !(pgconn.Timeout(err) || errors.Is(ctxTimeout.Err(), context.Canceled)) { + if !(pgconn.Timeout(err) || errors.Is(ctx.Err(), context.Canceled)) { p.logger.Errorf("Error waiting for notification:", err) } return } - p.handleSubscribedChange(ctx, handler, notification, id) + p.handleSubscribedChange(ctx, handler, notification, trigger, subscription) } } -func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler configuration.UpdateHandler, msg *pgconn.Notification, id string) { +func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler configuration.UpdateHandler, msg *pgconn.Notification, trigger string, subscription string) { defer func() { if err := recover(); err != nil { p.logger.Errorf("panic in handleSubscribedChange method and recovered: %s", err) @@ -205,6 +232,10 @@ func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler switch strings.ToLower(strKey) { case "key": key = v.Interface().(string) + if yes := p.isSubscribed(trigger, key, subscription); !yes { + p.logger.Debugf("Ignoring notification for %v", key) + return + } case "value": value = v.Interface().(string) case "version": @@ -225,7 +256,7 @@ func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler Metadata: m, }, }, - ID: id, + ID: subscription, } err = handler(ctx, e) if err != nil { @@ -266,13 +297,6 @@ func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { } func Connect(ctx context.Context, conn string, maxTimeout time.Duration) (*pgxpool.Pool, error) { - cfg, err := pgxpool.ParseConfig(conn) - if err != nil { - return nil, fmt.Errorf("postgres configuration store configuration error : %s", err) - } - cfg.AfterConnect = func(ctx context.Context, conn *pgx.Conn) { - - } pool, err := pgxpool.Connect(ctx, conn) if err != nil { return nil, fmt.Errorf("postgres configuration store connection error : %s", err) @@ -294,20 +318,20 @@ func buildQuery(req *configuration.GetRequest, configTable string) (string, erro queryBuilder.WriteString(strings.Join(req.Keys, "','")) queryBuilder.WriteString("')") query = queryBuilder.String() - } - if len(req.Metadata) > 0 { - var s strings.Builder - i, j := len(req.Metadata), 0 - s.WriteString(" AND ") - for k, v := range req.Metadata { - temp := k + "='" + v + "'" - s.WriteString(temp) - if j++; j < i { - s.WriteString(" AND ") + if len(req.Metadata) > 0 { + var s strings.Builder + i, j := len(req.Metadata), 0 + s.WriteString(" AND ") + for k, v := range req.Metadata { + temp := k + "='" + v + "'" + s.WriteString(temp) + if j++; j < i { + s.WriteString(" AND ") + } } + query += s.String() } - query += s.String() } return query, nil } @@ -320,3 +344,27 @@ func QueryRow(ctx context.Context, p *pgxpool.Pool, query string, tbl string) er } return nil } + +func (p *ConfigurationStore) isSubscriptionActive(req *configuration.SubscribeRequest) (string, bool) { + for _, trigger := range req.Metadata { + for key2, sub := range p.ActiveSubscriptions { + if strings.ToLower(trigger) == strings.ToLower(key2) { + return sub.uuid, true + } + } + } + return " ", false +} + +func (p *ConfigurationStore) isSubscribed(trigger string, key string, subscription string) bool { + for t, s := range p.ActiveSubscriptions { + if t == trigger && s.uuid == subscription { + for _, k := range s.keys { + if k == key { + return true + } + } + } + } + return false +} From 3935f058dba52b1028f3d231ca067f5dfa3eacba Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Thu, 15 Sep 2022 15:22:31 +0530 Subject: [PATCH 15/39] fixed errors identified during functional testing Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index cdd217051..f163f8b34 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -116,7 +116,7 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ } return nil, err } - response := configuration.GetResponse{make(map[string]*configuration.Item)} + items := make(map[string]*configuration.Item) for i := 0; rows.Next(); i++ { var item configuration.Item var key string @@ -130,15 +130,19 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ return nil, err } item.Metadata = v - response.Items[key] = &item + if item.Value != "" { + items[key] = &item + } } - return &response, nil + return &configuration.GetResponse{ + Items: items, + }, nil } func (p *ConfigurationStore) Subscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler) (string, error) { - var triggers []string //req.Metadata + var triggers []string for k, v := range req.Metadata { - if k == strings.ToLower("trigger") { + if res := strings.EqualFold("trigger", k); res { triggers = append(triggers, v) } } @@ -151,7 +155,6 @@ func (p *ConfigurationStore) Subscribe(ctx context.Context, req *configuration.S for _, trigger := range triggers { key := "listen " + trigger if sub, isActive := p.isSubscriptionActive(req); isActive { - //unsubscribe the previous subscription if oldStopChan, ok := p.subscribeStopChanMap.Load(sub); ok { close(oldStopChan.(chan struct{})) } @@ -348,7 +351,7 @@ func QueryRow(ctx context.Context, p *pgxpool.Pool, query string, tbl string) er func (p *ConfigurationStore) isSubscriptionActive(req *configuration.SubscribeRequest) (string, bool) { for _, trigger := range req.Metadata { for key2, sub := range p.ActiveSubscriptions { - if strings.ToLower(trigger) == strings.ToLower(key2) { + if res := strings.EqualFold(trigger, key2); res { return sub.uuid, true } } From c3d9e844a7bb987b8fce6819bd50770317e5f992 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Fri, 16 Sep 2022 12:06:13 +0530 Subject: [PATCH 16/39] fixed SQL injection review comments Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 52 +++++++++++++++++++------ configuration/postgres/postgres_test.go | 27 ++++++++++++- 2 files changed, 65 insertions(+), 14 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index f163f8b34..ce73a3054 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -20,6 +20,8 @@ import ( "errors" "fmt" "reflect" + "regexp" + "strconv" "strings" "sync" "time" @@ -28,7 +30,6 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4/pgxpool" _ "github.com/jackc/pgx/v4/stdlib" - "golang.org/x/exp/utf8string" "github.com/dapr/components-contrib/configuration" "github.com/dapr/kit/logger" @@ -53,7 +54,7 @@ const ( connMaxIdleTimeKey = "connMaxIdleTime" connectionStringKey = "connectionString" ErrorMissingTableName = "missing postgreSQL configuration table name" - InfoStartInit = "Initializing postgreSQL configuration store" + InfoStartInit = "initializing postgreSQL configuration store" ErrorMissingConnectionString = "missing postgreSQL connection string" ErrorAlreadyInitialized = "PostgreSQL configuration store already initialized" ErrorMissinMaxTimeout = "missing PostgreSQL maxTimeout setting in configuration" @@ -103,12 +104,16 @@ func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { } func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequest) (*configuration.GetResponse, error) { - query, err := buildQuery(req, p.metadata.configTable) + if err := validateInput(req.Keys); err != nil { + p.logger.Error(err) + return nil, err + } + query, params, err := buildQuery(req, p.metadata.configTable) if err != nil { p.logger.Error(err) return nil, err } - rows, err := p.client.Query(ctx, query) + rows, err := p.client.Query(ctx, query, params...) if err != nil { // If no rows exist, return an empty response, otherwise return the error. if err == sql.ErrNoRows { @@ -277,8 +282,8 @@ func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { } if tbl, ok := cmetadata.Properties[configtablekey]; ok && tbl != "" { - if !utf8string.NewString(tbl).IsASCII() { - return m, fmt.Errorf("invalid table name : '%v'. non-ascii characters are not supported", tbl) + if !regexp.MustCompile(`^[a-zA-Z0-9]*$`).MatchString(tbl) { + return m, fmt.Errorf("invalid table name : '%v'. non-alphanumerics are not supported", tbl) } if len(tbl) > maxIdentifierLength { return m, fmt.Errorf(ErrorTooLongFieldLength+" - tableName : '%v'. max allowed field length is %v ", tbl, maxIdentifierLength) @@ -311,15 +316,24 @@ func Connect(ctx context.Context, conn string, maxTimeout time.Duration) (*pgxpo return pool, nil } -func buildQuery(req *configuration.GetRequest, configTable string) (string, error) { +func buildQuery(req *configuration.GetRequest, configTable string) (string, []interface{}, error) { var query string + var params []interface{} if len(req.Keys) == 0 { query = "SELECT * FROM " + configTable } else { var queryBuilder strings.Builder - queryBuilder.WriteString("SELECT * FROM " + configTable + " WHERE KEY IN ('") - queryBuilder.WriteString(strings.Join(req.Keys, "','")) - queryBuilder.WriteString("')") + queryBuilder.WriteString("SELECT * FROM " + configTable + " WHERE KEY IN (") + var paramWildcard []string + paramPosition := 1 + for _, v := range req.Keys { + paramWildcard = append(paramWildcard, "$"+strconv.Itoa(paramPosition)) + params = append(params, v) + paramPosition++ + } + queryBuilder.WriteString(strings.Join(paramWildcard, " , ")) + queryBuilder.WriteString(")") + query = queryBuilder.String() if len(req.Metadata) > 0 { @@ -327,8 +341,10 @@ func buildQuery(req *configuration.GetRequest, configTable string) (string, erro i, j := len(req.Metadata), 0 s.WriteString(" AND ") for k, v := range req.Metadata { - temp := k + "='" + v + "'" + temp := "$" + strconv.Itoa(paramPosition) + " = " + "$" + strconv.Itoa(paramPosition+1) s.WriteString(temp) + params = append(params, k, v) + paramPosition += 2 if j++; j < i { s.WriteString(" AND ") } @@ -336,7 +352,7 @@ func buildQuery(req *configuration.GetRequest, configTable string) (string, erro query += s.String() } } - return query, nil + return query, params, nil } func QueryRow(ctx context.Context, p *pgxpool.Pool, query string, tbl string) error { @@ -371,3 +387,15 @@ func (p *ConfigurationStore) isSubscribed(trigger string, key string, subscripti } return false } + +func validateInput(keys []string) error { + if len(keys) == 0 { + return nil + } + for _, key := range keys { + if !regexp.MustCompile(`^[a-zA-Z0-9]*$`).MatchString(key) { + return fmt.Errorf("invalid key : '%v'", key) + } + } + return nil +} diff --git a/configuration/postgres/postgres_test.go b/configuration/postgres/postgres_test.go index faceae11f..3962fd871 100644 --- a/configuration/postgres/postgres_test.go +++ b/configuration/postgres/postgres_test.go @@ -31,14 +31,37 @@ func TestPostgresbuildQuery(t *testing.T) { }, } - query, err := buildQuery(g, "cfgtbl") + query, params, err := buildQuery(g, "cfgtbl") + _ = params if err != nil { t.Errorf("Error building query: %v ", err) } - expected := "SELECT * FROM cfgtbl WHERE KEY IN ('someKey') AND Version='1.0'" + expected := "SELECT * FROM cfgtbl WHERE KEY IN ($1) AND $2 = $3" if query != expected { t.Errorf("Did not get expected result. Got: '%v' , Expected: '%v'", query, expected) } + i := 0 + for _, v := range params { + got := v.(string) + switch i { + case 0: + expected := "someKey" + if expected != got { + t.Errorf("Did not get expected result. Got: '%v' , Expected: '%v'", got, expected) + } + case 1: + expected := "Version" + if expected != got { + t.Errorf("Did not get expected result. Got: '%v' , Expected: '%v'", got, expected) + } + case 2: + expected := "1.0" + if expected != got { + t.Errorf("Did not get expected result. Got: '%v' , Expected: '%v'", got, expected) + } + } + i++ + } } func TestConnectAndQuery(t *testing.T) { From 1e1fa2ccfa66712ae1cec11c9adc369eb432b539 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Mon, 19 Sep 2022 10:50:39 +0530 Subject: [PATCH 17/39] Fixing mod tidy Signed-off-by: akhilac1 --- .../bindings/alicloud/dubbo/go.mod | 2 +- .../bindings/alicloud/dubbo/go.sum | 4 ++-- .../bindings/azure/blobstorage/go.mod | 2 +- .../bindings/azure/blobstorage/go.sum | 4 ++-- .../bindings/azure/cosmosdb/go.mod | 2 +- .../bindings/azure/cosmosdb/go.sum | 4 ++-- .../bindings/azure/eventhubs/go.mod | 2 +- .../bindings/azure/eventhubs/go.sum | 4 ++-- .../bindings/azure/servicebusqueues/go.mod | 2 +- .../bindings/azure/servicebusqueues/go.sum | 4 ++-- .../bindings/azure/storagequeues/go.mod | 2 +- .../bindings/azure/storagequeues/go.sum | 4 ++-- tests/certification/bindings/kafka/go.mod | 2 +- tests/certification/bindings/kafka/go.sum | 4 ++-- tests/certification/bindings/postgres/go.mod | 10 +++++----- tests/certification/bindings/postgres/go.sum | 20 +++++++++---------- .../pubsub/azure/eventhubs/go.mod | 2 +- .../pubsub/azure/eventhubs/go.sum | 4 ++-- .../pubsub/azure/servicebus/go.mod | 2 +- .../pubsub/azure/servicebus/go.sum | 4 ++-- tests/certification/pubsub/kafka/go.mod | 2 +- tests/certification/pubsub/kafka/go.sum | 4 ++-- .../secretstores/azure/keyvault/go.mod | 2 +- .../secretstores/azure/keyvault/go.sum | 4 ++-- .../state/azure/blobstorage/go.mod | 2 +- .../state/azure/blobstorage/go.sum | 4 ++-- .../certification/state/azure/cosmosdb/go.mod | 2 +- .../certification/state/azure/cosmosdb/go.sum | 4 ++-- .../state/azure/tablestorage/go.mod | 2 +- .../state/azure/tablestorage/go.sum | 4 ++-- tests/certification/state/mongodb/go.mod | 2 +- tests/certification/state/mongodb/go.sum | 4 ++-- tests/certification/state/postgresql/go.mod | 10 +++++----- tests/certification/state/postgresql/go.sum | 20 +++++++++---------- tests/certification/state/sqlserver/go.mod | 2 +- tests/certification/state/sqlserver/go.sum | 4 ++-- tests/e2e/pubsub/jetstream/go.mod | 2 +- tests/e2e/pubsub/jetstream/go.sum | 4 ++-- 38 files changed, 81 insertions(+), 81 deletions(-) diff --git a/tests/certification/bindings/alicloud/dubbo/go.mod b/tests/certification/bindings/alicloud/dubbo/go.mod index 0be072a8d..058a234fe 100644 --- a/tests/certification/bindings/alicloud/dubbo/go.mod +++ b/tests/certification/bindings/alicloud/dubbo/go.mod @@ -129,7 +129,7 @@ require ( go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect go.uber.org/zap v1.21.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/bindings/alicloud/dubbo/go.sum b/tests/certification/bindings/alicloud/dubbo/go.sum index 1782a9a23..be8b5c742 100644 --- a/tests/certification/bindings/alicloud/dubbo/go.sum +++ b/tests/certification/bindings/alicloud/dubbo/go.sum @@ -1062,8 +1062,8 @@ golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= diff --git a/tests/certification/bindings/azure/blobstorage/go.mod b/tests/certification/bindings/azure/blobstorage/go.mod index d1f5dae40..67fc96aa1 100644 --- a/tests/certification/bindings/azure/blobstorage/go.mod +++ b/tests/certification/bindings/azure/blobstorage/go.mod @@ -116,7 +116,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/bindings/azure/blobstorage/go.sum b/tests/certification/bindings/azure/blobstorage/go.sum index 9efddea3f..db2804c26 100644 --- a/tests/certification/bindings/azure/blobstorage/go.sum +++ b/tests/certification/bindings/azure/blobstorage/go.sum @@ -779,8 +779,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/bindings/azure/cosmosdb/go.mod b/tests/certification/bindings/azure/cosmosdb/go.mod index d0d38a609..82233b189 100644 --- a/tests/certification/bindings/azure/cosmosdb/go.mod +++ b/tests/certification/bindings/azure/cosmosdb/go.mod @@ -118,7 +118,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/bindings/azure/cosmosdb/go.sum b/tests/certification/bindings/azure/cosmosdb/go.sum index 6673dbcb1..8f0969438 100644 --- a/tests/certification/bindings/azure/cosmosdb/go.sum +++ b/tests/certification/bindings/azure/cosmosdb/go.sum @@ -784,8 +784,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/bindings/azure/eventhubs/go.mod b/tests/certification/bindings/azure/eventhubs/go.mod index c635844f8..be98cced0 100644 --- a/tests/certification/bindings/azure/eventhubs/go.mod +++ b/tests/certification/bindings/azure/eventhubs/go.mod @@ -125,7 +125,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/bindings/azure/eventhubs/go.sum b/tests/certification/bindings/azure/eventhubs/go.sum index 560dc475b..3cce980b7 100644 --- a/tests/certification/bindings/azure/eventhubs/go.sum +++ b/tests/certification/bindings/azure/eventhubs/go.sum @@ -806,8 +806,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/bindings/azure/servicebusqueues/go.mod b/tests/certification/bindings/azure/servicebusqueues/go.mod index 0b46ff534..923b2a8b8 100644 --- a/tests/certification/bindings/azure/servicebusqueues/go.mod +++ b/tests/certification/bindings/azure/servicebusqueues/go.mod @@ -122,7 +122,7 @@ require ( go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/ratelimit v0.2.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/bindings/azure/servicebusqueues/go.sum b/tests/certification/bindings/azure/servicebusqueues/go.sum index 769f79677..bdf9b6359 100644 --- a/tests/certification/bindings/azure/servicebusqueues/go.sum +++ b/tests/certification/bindings/azure/servicebusqueues/go.sum @@ -794,8 +794,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/bindings/azure/storagequeues/go.mod b/tests/certification/bindings/azure/storagequeues/go.mod index 51ec41b0c..09894e380 100644 --- a/tests/certification/bindings/azure/storagequeues/go.mod +++ b/tests/certification/bindings/azure/storagequeues/go.mod @@ -118,7 +118,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/bindings/azure/storagequeues/go.sum b/tests/certification/bindings/azure/storagequeues/go.sum index d7af5f82a..25313f9e4 100644 --- a/tests/certification/bindings/azure/storagequeues/go.sum +++ b/tests/certification/bindings/azure/storagequeues/go.sum @@ -781,8 +781,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/bindings/kafka/go.mod b/tests/certification/bindings/kafka/go.mod index cd4efd7ce..9779cd964 100644 --- a/tests/certification/bindings/kafka/go.mod +++ b/tests/certification/bindings/kafka/go.mod @@ -113,7 +113,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/bindings/kafka/go.sum b/tests/certification/bindings/kafka/go.sum index 1f54f5c77..69c7c797f 100644 --- a/tests/certification/bindings/kafka/go.sum +++ b/tests/certification/bindings/kafka/go.sum @@ -737,8 +737,8 @@ golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/bindings/postgres/go.mod b/tests/certification/bindings/postgres/go.mod index d14c151db..5f89d3026 100644 --- a/tests/certification/bindings/postgres/go.mod +++ b/tests/certification/bindings/postgres/go.mod @@ -57,13 +57,13 @@ require ( github.com/hashicorp/serf v0.9.6 // indirect github.com/imdario/mergo v0.3.12 // indirect github.com/jackc/chunkreader/v2 v2.0.1 // indirect - github.com/jackc/pgconn v1.11.0 // indirect + github.com/jackc/pgconn v1.13.0 // indirect github.com/jackc/pgio v1.0.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect - github.com/jackc/pgproto3/v2 v2.2.0 // indirect + github.com/jackc/pgproto3/v2 v2.3.1 // indirect github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect - github.com/jackc/pgtype v1.10.0 // indirect - github.com/jackc/pgx/v4 v4.15.0 // indirect + github.com/jackc/pgtype v1.12.0 // indirect + github.com/jackc/pgx/v4 v4.17.0 // indirect github.com/jackc/puddle v1.2.1 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.15.1 // indirect @@ -104,7 +104,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/bindings/postgres/go.sum b/tests/certification/bindings/postgres/go.sum index 1d1bd9a90..4aa6f73f6 100644 --- a/tests/certification/bindings/postgres/go.sum +++ b/tests/certification/bindings/postgres/go.sum @@ -400,8 +400,8 @@ github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsU github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= -github.com/jackc/pgconn v1.11.0 h1:HiHArx4yFbwl91X3qqIHtUFoiIfLNJXCQRsnzkiwwaQ= -github.com/jackc/pgconn v1.11.0/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= +github.com/jackc/pgconn v1.13.0 h1:3L1XMNV2Zvca/8BYhzcRFS70Lr0WlDg16Di6SFGAbys= +github.com/jackc/pgconn v1.13.0/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI= github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= @@ -417,22 +417,22 @@ github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvW github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.2.0 h1:r7JypeP2D3onoQTCxWdTpCtJ4D+qpKr0TxvoyMhZ5ns= -github.com/jackc/pgproto3/v2 v2.2.0/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.3.1 h1:nwj7qwf0S+Q7ISFfBndqeLwSwxs+4DPsbRFjECT1Y4Y= +github.com/jackc/pgproto3/v2 v2.3.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= -github.com/jackc/pgtype v1.10.0 h1:ILnBWrRMSXGczYvmkYD6PsYyVFUNLTnIUJHHDLmqk38= -github.com/jackc/pgtype v1.10.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= +github.com/jackc/pgtype v1.12.0 h1:Dlq8Qvcch7kiehm8wPGIW0W3KsCCHJnRacKW0UM8n5w= +github.com/jackc/pgtype v1.12.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= -github.com/jackc/pgx/v4 v4.15.0 h1:B7dTkXsdILD3MF987WGGCcg+tvLW6bZJdEcqVFeU//w= -github.com/jackc/pgx/v4 v4.15.0/go.mod h1:D/zyOyXiaM1TmVWnOM18p0xdDtdakRBa0RsVGI3U3bw= +github.com/jackc/pgx/v4 v4.17.0 h1:Hsx+baY8/zU2WtPLQyZi8WbecgcsWEeyoK1jvg/WgIo= +github.com/jackc/pgx/v4 v4.17.0/go.mod h1:Gd6RmOhtFLTu8cp/Fhq4kP195KrshxYJH3oW8AWJ1pw= github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= @@ -800,8 +800,8 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/pubsub/azure/eventhubs/go.mod b/tests/certification/pubsub/azure/eventhubs/go.mod index 6e84d371c..287261542 100644 --- a/tests/certification/pubsub/azure/eventhubs/go.mod +++ b/tests/certification/pubsub/azure/eventhubs/go.mod @@ -124,7 +124,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/pubsub/azure/eventhubs/go.sum b/tests/certification/pubsub/azure/eventhubs/go.sum index 1d8ed42bb..4e799f846 100644 --- a/tests/certification/pubsub/azure/eventhubs/go.sum +++ b/tests/certification/pubsub/azure/eventhubs/go.sum @@ -804,8 +804,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/pubsub/azure/servicebus/go.mod b/tests/certification/pubsub/azure/servicebus/go.mod index e63bf90ff..b6049e5c7 100644 --- a/tests/certification/pubsub/azure/servicebus/go.mod +++ b/tests/certification/pubsub/azure/servicebus/go.mod @@ -122,7 +122,7 @@ require ( go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/ratelimit v0.2.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/pubsub/azure/servicebus/go.sum b/tests/certification/pubsub/azure/servicebus/go.sum index 135c0e558..5e0c99e36 100644 --- a/tests/certification/pubsub/azure/servicebus/go.sum +++ b/tests/certification/pubsub/azure/servicebus/go.sum @@ -791,8 +791,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/pubsub/kafka/go.mod b/tests/certification/pubsub/kafka/go.mod index b5be1ff23..c9514c87a 100644 --- a/tests/certification/pubsub/kafka/go.mod +++ b/tests/certification/pubsub/kafka/go.mod @@ -113,7 +113,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/pubsub/kafka/go.sum b/tests/certification/pubsub/kafka/go.sum index 1f54f5c77..69c7c797f 100644 --- a/tests/certification/pubsub/kafka/go.sum +++ b/tests/certification/pubsub/kafka/go.sum @@ -737,8 +737,8 @@ golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/secretstores/azure/keyvault/go.mod b/tests/certification/secretstores/azure/keyvault/go.mod index f24474d1f..585695042 100644 --- a/tests/certification/secretstores/azure/keyvault/go.mod +++ b/tests/certification/secretstores/azure/keyvault/go.mod @@ -117,7 +117,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/secretstores/azure/keyvault/go.sum b/tests/certification/secretstores/azure/keyvault/go.sum index 4c253aa07..68afde36a 100644 --- a/tests/certification/secretstores/azure/keyvault/go.sum +++ b/tests/certification/secretstores/azure/keyvault/go.sum @@ -781,8 +781,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/state/azure/blobstorage/go.mod b/tests/certification/state/azure/blobstorage/go.mod index a77252c61..b52d63446 100644 --- a/tests/certification/state/azure/blobstorage/go.mod +++ b/tests/certification/state/azure/blobstorage/go.mod @@ -116,7 +116,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/state/azure/blobstorage/go.sum b/tests/certification/state/azure/blobstorage/go.sum index 070b8b9e2..d538f6cd4 100644 --- a/tests/certification/state/azure/blobstorage/go.sum +++ b/tests/certification/state/azure/blobstorage/go.sum @@ -778,8 +778,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/state/azure/cosmosdb/go.mod b/tests/certification/state/azure/cosmosdb/go.mod index 25381a4e7..0f9e5727c 100644 --- a/tests/certification/state/azure/cosmosdb/go.mod +++ b/tests/certification/state/azure/cosmosdb/go.mod @@ -117,7 +117,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/state/azure/cosmosdb/go.sum b/tests/certification/state/azure/cosmosdb/go.sum index 5e26f12a9..2da7f5181 100644 --- a/tests/certification/state/azure/cosmosdb/go.sum +++ b/tests/certification/state/azure/cosmosdb/go.sum @@ -782,8 +782,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/state/azure/tablestorage/go.mod b/tests/certification/state/azure/tablestorage/go.mod index 5789bef80..c550ba24f 100644 --- a/tests/certification/state/azure/tablestorage/go.mod +++ b/tests/certification/state/azure/tablestorage/go.mod @@ -116,7 +116,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/state/azure/tablestorage/go.sum b/tests/certification/state/azure/tablestorage/go.sum index 3b9bf7316..2e07a6473 100644 --- a/tests/certification/state/azure/tablestorage/go.sum +++ b/tests/certification/state/azure/tablestorage/go.sum @@ -779,8 +779,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/state/mongodb/go.mod b/tests/certification/state/mongodb/go.mod index 3c46d127e..c37511a2e 100644 --- a/tests/certification/state/mongodb/go.mod +++ b/tests/certification/state/mongodb/go.mod @@ -104,7 +104,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/state/mongodb/go.sum b/tests/certification/state/mongodb/go.sum index 928ca7325..3027f584a 100644 --- a/tests/certification/state/mongodb/go.sum +++ b/tests/certification/state/mongodb/go.sum @@ -774,8 +774,8 @@ golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/state/postgresql/go.mod b/tests/certification/state/postgresql/go.mod index 66bc0d3f7..661d47682 100644 --- a/tests/certification/state/postgresql/go.mod +++ b/tests/certification/state/postgresql/go.mod @@ -57,13 +57,13 @@ require ( github.com/hashicorp/serf v0.9.6 // indirect github.com/imdario/mergo v0.3.12 // indirect github.com/jackc/chunkreader/v2 v2.0.1 // indirect - github.com/jackc/pgconn v1.11.0 // indirect + github.com/jackc/pgconn v1.13.0 // indirect github.com/jackc/pgio v1.0.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect - github.com/jackc/pgproto3/v2 v2.2.0 // indirect + github.com/jackc/pgproto3/v2 v2.3.1 // indirect github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect - github.com/jackc/pgtype v1.10.0 // indirect - github.com/jackc/pgx/v4 v4.15.0 // indirect + github.com/jackc/pgtype v1.12.0 // indirect + github.com/jackc/pgx/v4 v4.17.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.15.1 // indirect github.com/mattn/go-colorable v0.1.12 // indirect @@ -102,7 +102,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/state/postgresql/go.sum b/tests/certification/state/postgresql/go.sum index b4ab0413c..d6da3dee1 100644 --- a/tests/certification/state/postgresql/go.sum +++ b/tests/certification/state/postgresql/go.sum @@ -403,8 +403,8 @@ github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsU github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= -github.com/jackc/pgconn v1.11.0 h1:HiHArx4yFbwl91X3qqIHtUFoiIfLNJXCQRsnzkiwwaQ= -github.com/jackc/pgconn v1.11.0/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= +github.com/jackc/pgconn v1.13.0 h1:3L1XMNV2Zvca/8BYhzcRFS70Lr0WlDg16Di6SFGAbys= +github.com/jackc/pgconn v1.13.0/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI= github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= @@ -420,22 +420,22 @@ github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvW github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.2.0 h1:r7JypeP2D3onoQTCxWdTpCtJ4D+qpKr0TxvoyMhZ5ns= -github.com/jackc/pgproto3/v2 v2.2.0/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.3.1 h1:nwj7qwf0S+Q7ISFfBndqeLwSwxs+4DPsbRFjECT1Y4Y= +github.com/jackc/pgproto3/v2 v2.3.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= -github.com/jackc/pgtype v1.10.0 h1:ILnBWrRMSXGczYvmkYD6PsYyVFUNLTnIUJHHDLmqk38= -github.com/jackc/pgtype v1.10.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= +github.com/jackc/pgtype v1.12.0 h1:Dlq8Qvcch7kiehm8wPGIW0W3KsCCHJnRacKW0UM8n5w= +github.com/jackc/pgtype v1.12.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= -github.com/jackc/pgx/v4 v4.15.0 h1:B7dTkXsdILD3MF987WGGCcg+tvLW6bZJdEcqVFeU//w= -github.com/jackc/pgx/v4 v4.15.0/go.mod h1:D/zyOyXiaM1TmVWnOM18p0xdDtdakRBa0RsVGI3U3bw= +github.com/jackc/pgx/v4 v4.17.0 h1:Hsx+baY8/zU2WtPLQyZi8WbecgcsWEeyoK1jvg/WgIo= +github.com/jackc/pgx/v4 v4.17.0/go.mod h1:Gd6RmOhtFLTu8cp/Fhq4kP195KrshxYJH3oW8AWJ1pw= github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= @@ -800,8 +800,8 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/state/sqlserver/go.mod b/tests/certification/state/sqlserver/go.mod index fe10da779..c4bbd6443 100644 --- a/tests/certification/state/sqlserver/go.mod +++ b/tests/certification/state/sqlserver/go.mod @@ -97,7 +97,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/state/sqlserver/go.sum b/tests/certification/state/sqlserver/go.sum index 18d245921..bc0fd5bb3 100644 --- a/tests/certification/state/sqlserver/go.sum +++ b/tests/certification/state/sqlserver/go.sum @@ -719,8 +719,8 @@ golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/e2e/pubsub/jetstream/go.mod b/tests/e2e/pubsub/jetstream/go.mod index 77900f4b8..5498f24fe 100644 --- a/tests/e2e/pubsub/jetstream/go.mod +++ b/tests/e2e/pubsub/jetstream/go.mod @@ -16,7 +16,7 @@ require ( github.com/nats-io/nuid v1.0.1 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/sirupsen/logrus v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect ) diff --git a/tests/e2e/pubsub/jetstream/go.sum b/tests/e2e/pubsub/jetstream/go.sum index d2bc796ec..7e63e0a29 100644 --- a/tests/e2e/pubsub/jetstream/go.sum +++ b/tests/e2e/pubsub/jetstream/go.sum @@ -30,8 +30,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ= From 724e529b9542b462cee8af43f1289e878fce387f Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Mon, 19 Sep 2022 16:44:01 +0530 Subject: [PATCH 18/39] Fixing Commits Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 31 ++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index ce73a3054..439197355 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -39,6 +39,7 @@ type ConfigurationStore struct { metadata metadata client *pgxpool.Pool logger logger.Logger + configLock sync.Mutex subscribeStopChanMap sync.Map ActiveSubscriptions map[string]*subscription } @@ -63,10 +64,14 @@ const ( ErrorTooLongFieldLength = "field name is too long" ) +var allowedChars = regexp.MustCompile(`^[a-zA-Z0-9./_]*$`) + func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store { logger.Debug("Instantiating PostgreSQL configuration store") return &ConfigurationStore{ - logger: logger, + logger: logger, + subscribeStopChanMap: sync.Map{}, + configLock: sync.Mutex{}, } } @@ -157,8 +162,9 @@ func (p *ConfigurationStore) Subscribe(ctx context.Context, req *configuration.S } var subscribeID string + p.configLock.Lock() for _, trigger := range triggers { - key := "listen " + trigger + notificationChannel := "listen " + trigger if sub, isActive := p.isSubscriptionActive(req); isActive { if oldStopChan, ok := p.subscribeStopChanMap.Load(sub); ok { close(oldStopChan.(chan struct{})) @@ -172,20 +178,33 @@ func (p *ConfigurationStore) Subscribe(ctx context.Context, req *configuration.S trigger: trigger, keys: req.Keys, } - go p.doSubscribe(ctx, req, handler, key, trigger, subscribeID, stop) + go p.doSubscribe(ctx, req, handler, notificationChannel, trigger, subscribeID, stop) } + p.configLock.Unlock() return subscribeID, nil } func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration.UnsubscribeRequest) error { + p.configLock.Lock() + defer p.configLock.Unlock() if oldStopChan, ok := p.subscribeStopChanMap.Load(req.ID); ok { p.subscribeStopChanMap.Delete(req.ID) + close(oldStopChan.(chan struct{})) for k, v := range p.ActiveSubscriptions { if v.uuid == req.ID { + channel := "unlisten " + v.trigger + conn, err := p.client.Acquire(ctx) + if err != nil { + return fmt.Errorf("Error acquiring connection: %v", err) + } + defer conn.Release() + _, err = conn.Exec(ctx, channel) + if err != nil { + return fmt.Errorf("Error unlistening to channel: %v", err) + } delete(p.ActiveSubscriptions, k) } } - close(oldStopChan.(chan struct{})) return nil } return fmt.Errorf("unable to find subscription with ID : %v", req.ID) @@ -282,7 +301,7 @@ func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { } if tbl, ok := cmetadata.Properties[configtablekey]; ok && tbl != "" { - if !regexp.MustCompile(`^[a-zA-Z0-9]*$`).MatchString(tbl) { + if !allowedChars.MatchString(tbl) { return m, fmt.Errorf("invalid table name : '%v'. non-alphanumerics are not supported", tbl) } if len(tbl) > maxIdentifierLength { @@ -393,7 +412,7 @@ func validateInput(keys []string) error { return nil } for _, key := range keys { - if !regexp.MustCompile(`^[a-zA-Z0-9]*$`).MatchString(key) { + if !allowedChars.MatchString(key) { return fmt.Errorf("invalid key : '%v'", key) } } From 4f64eefae64507ca5cfd5f11044283816b126d4a Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Mon, 19 Sep 2022 16:47:02 +0530 Subject: [PATCH 19/39] Fixing make modtidy-all Signed-off-by: akhilac1 --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index a6e61e070..a0930e7cf 100644 --- a/go.mod +++ b/go.mod @@ -97,8 +97,8 @@ require ( github.com/nats-io/nats-streaming-server v0.21.2 // indirect github.com/nats-io/nats.go v1.13.1-0.20220308171302-2f2f6968e98d github.com/nats-io/stan.go v0.8.3 - github.com/pashagolub/pgxmock v1.8.0 github.com/open-policy-agent/opa v0.43.1 + github.com/pashagolub/pgxmock v1.8.0 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/pkg/errors v0.9.1 github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 // indirect From bebe2c63e0ad49199a686de2c17380d83cd7a660 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Mon, 19 Sep 2022 23:03:28 +0530 Subject: [PATCH 20/39] removed dead code Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index 439197355..68347714b 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -374,15 +374,6 @@ func buildQuery(req *configuration.GetRequest, configTable string) (string, []in return query, params, nil } -func QueryRow(ctx context.Context, p *pgxpool.Pool, query string, tbl string) error { - exists := false - err := p.QueryRow(ctx, query, tbl).Scan(&exists) - if err != nil { - return fmt.Errorf("postgres configuration store query error : %s", err) - } - return nil -} - func (p *ConfigurationStore) isSubscriptionActive(req *configuration.SubscribeRequest) (string, bool) { for _, trigger := range req.Metadata { for key2, sub := range p.ActiveSubscriptions { From b14100eb4e417acc865458cbcba9a9d6ca47bf3e Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Mon, 19 Sep 2022 23:25:05 +0530 Subject: [PATCH 21/39] change sync.Map to map Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index 68347714b..63d3bdd30 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -40,7 +40,7 @@ type ConfigurationStore struct { client *pgxpool.Pool logger logger.Logger configLock sync.Mutex - subscribeStopChanMap sync.Map + subscribeStopChanMap map[string]interface{} ActiveSubscriptions map[string]*subscription } @@ -55,6 +55,7 @@ const ( connMaxIdleTimeKey = "connMaxIdleTime" connectionStringKey = "connectionString" ErrorMissingTableName = "missing postgreSQL configuration table name" + ErrorMissingTable = "postgreSQL configuration table - '%v' does not exist" InfoStartInit = "initializing postgreSQL configuration store" ErrorMissingConnectionString = "missing postgreSQL connection string" ErrorAlreadyInitialized = "PostgreSQL configuration store already initialized" @@ -70,7 +71,7 @@ func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store { logger.Debug("Instantiating PostgreSQL configuration store") return &ConfigurationStore{ logger: logger, - subscribeStopChanMap: sync.Map{}, + subscribeStopChanMap: make(map[string]interface{}), configLock: sync.Mutex{}, } } @@ -103,6 +104,9 @@ func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { exists := false err = p.client.QueryRow(ctx, QueryTableExists, p.metadata.configTable).Scan(&exists) if err != nil { + if err == sql.ErrNoRows { + return fmt.Errorf(ErrorMissingTable, p.metadata.configTable) + } return err } return nil @@ -166,13 +170,13 @@ func (p *ConfigurationStore) Subscribe(ctx context.Context, req *configuration.S for _, trigger := range triggers { notificationChannel := "listen " + trigger if sub, isActive := p.isSubscriptionActive(req); isActive { - if oldStopChan, ok := p.subscribeStopChanMap.Load(sub); ok { + if oldStopChan, ok := p.subscribeStopChanMap[sub]; ok { close(oldStopChan.(chan struct{})) } } stop := make(chan struct{}) subscribeID = uuid.New().String() - p.subscribeStopChanMap.Store(subscribeID, stop) + p.subscribeStopChanMap[subscribeID] = stop p.ActiveSubscriptions[trigger] = &subscription{ uuid: subscribeID, trigger: trigger, @@ -187,8 +191,8 @@ func (p *ConfigurationStore) Subscribe(ctx context.Context, req *configuration.S func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration.UnsubscribeRequest) error { p.configLock.Lock() defer p.configLock.Unlock() - if oldStopChan, ok := p.subscribeStopChanMap.Load(req.ID); ok { - p.subscribeStopChanMap.Delete(req.ID) + if oldStopChan, ok := p.subscribeStopChanMap[req.ID]; ok { + delete(p.subscribeStopChanMap, req.ID) close(oldStopChan.(chan struct{})) for k, v := range p.ActiveSubscriptions { if v.uuid == req.ID { From 6ddc42d3bd24279f8a84fe1597760d1b7d6cb66d Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Tue, 20 Sep 2022 15:20:25 +0530 Subject: [PATCH 22/39] fixed review comments Signed-off-by: akhilac1 --- configuration/postgres/metadata.go | 2 +- configuration/postgres/postgres.go | 129 ++++++++++++------------ configuration/postgres/postgres_test.go | 46 ++++++--- go.mod | 8 +- go.sum | 11 +- 5 files changed, 111 insertions(+), 85 deletions(-) diff --git a/configuration/postgres/metadata.go b/configuration/postgres/metadata.go index 389bf9199..a1c4296e9 100644 --- a/configuration/postgres/metadata.go +++ b/configuration/postgres/metadata.go @@ -1,5 +1,5 @@ /* -Copyright 2021 The Dapr Authors +Copyright 2022 The Dapr Authors 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 diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index 63d3bdd30..294e08019 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -1,5 +1,5 @@ /* -Copyright 2021 The Dapr Authors +Copyright 2022 The Dapr Authors 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 @@ -27,9 +27,8 @@ import ( "time" "github.com/google/uuid" - "github.com/jackc/pgconn" - "github.com/jackc/pgx/v4/pgxpool" - _ "github.com/jackc/pgx/v4/stdlib" + "github.com/jackc/pgx/v5/pgconn" + "github.com/jackc/pgx/v5/pgxpool" "github.com/dapr/components-contrib/configuration" "github.com/dapr/kit/logger" @@ -58,11 +57,11 @@ const ( ErrorMissingTable = "postgreSQL configuration table - '%v' does not exist" InfoStartInit = "initializing postgreSQL configuration store" ErrorMissingConnectionString = "missing postgreSQL connection string" - ErrorAlreadyInitialized = "PostgreSQL configuration store already initialized" - ErrorMissinMaxTimeout = "missing PostgreSQL maxTimeout setting in configuration" + ErrorAlreadyInitialized = "postgreSQL configuration store already initialized" + ErrorMissingMaxTimeout = "missing PostgreSQL maxTimeout setting in configuration" QueryTableExists = "SELECT EXISTS (SELECT FROM pg_tables where tablename = $1)" - maxIdentifierLength = 64 // https://www.postgresql.org/docs/current/limits.html ErrorTooLongFieldLength = "field name is too long" + maxIdentifierLength = 64 // https://www.postgresql.org/docs/current/limits.html ) var allowedChars = regexp.MustCompile(`^[a-zA-Z0-9./_]*$`) @@ -78,7 +77,6 @@ func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store { func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { p.logger.Debug(InfoStartInit) - if p.client != nil { return fmt.Errorf(ErrorAlreadyInitialized) } @@ -93,12 +91,12 @@ func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { defer cancel() client, err := Connect(ctx, p.metadata.connectionString, p.metadata.maxIdleTime) if err != nil { - return err + return fmt.Errorf("error connecting to configuration store: '%s'", err) } p.client = client pingErr := p.client.Ping(ctx) if pingErr != nil { - return pingErr + return fmt.Errorf("unable to connect to configuration store: '%s'", pingErr) } // check if table exists exists := false @@ -107,7 +105,7 @@ func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { if err == sql.ErrNoRows { return fmt.Errorf(ErrorMissingTable, p.metadata.configTable) } - return err + return fmt.Errorf("error in checking if configtable exists - '%v'", p.metadata.configTable) } return nil } @@ -120,7 +118,7 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ query, params, err := buildQuery(req, p.metadata.configTable) if err != nil { p.logger.Error(err) - return nil, err + return nil, fmt.Errorf("error in configuration store query: '%s' ", err) } rows, err := p.client.Query(ctx, query, params...) if err != nil { @@ -128,7 +126,7 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ if err == sql.ErrNoRows { return &configuration.GetResponse{}, nil } - return nil, err + return nil, fmt.Errorf("error in querying configuration store: '%s'", err) } items := make(map[string]*configuration.Item) for i := 0; rows.Next(); i++ { @@ -136,12 +134,11 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ var key string var metadata []byte v := make(map[string]string) - if err := rows.Scan(&key, &item.Value, &item.Version, &metadata); err != nil { - return nil, err + return nil, fmt.Errorf("error in reading data from configuration store: '%s'", err) } if err := json.Unmarshal(metadata, &v); err != nil { - return nil, err + return nil, fmt.Errorf("error in unmarshalling response from configuration store: '%s'", err) } item.Metadata = v if item.Value != "" { @@ -160,32 +157,10 @@ func (p *ConfigurationStore) Subscribe(ctx context.Context, req *configuration.S triggers = append(triggers, v) } } - if len(triggers) == 0 { return "", fmt.Errorf("cannot subscribe to empty trigger") } - - var subscribeID string - p.configLock.Lock() - for _, trigger := range triggers { - notificationChannel := "listen " + trigger - if sub, isActive := p.isSubscriptionActive(req); isActive { - if oldStopChan, ok := p.subscribeStopChanMap[sub]; ok { - close(oldStopChan.(chan struct{})) - } - } - stop := make(chan struct{}) - subscribeID = uuid.New().String() - p.subscribeStopChanMap[subscribeID] = stop - p.ActiveSubscriptions[trigger] = &subscription{ - uuid: subscribeID, - trigger: trigger, - keys: req.Keys, - } - go p.doSubscribe(ctx, req, handler, notificationChannel, trigger, subscribeID, stop) - } - p.configLock.Unlock() - return subscribeID, nil + return p.subscribeToChannel(ctx, triggers, req, handler) } func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration.UnsubscribeRequest) error { @@ -199,12 +174,14 @@ func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration channel := "unlisten " + v.trigger conn, err := p.client.Acquire(ctx) if err != nil { - return fmt.Errorf("Error acquiring connection: %v", err) + p.logger.Errorf("error acquiring connection:", err) + return fmt.Errorf("error acquiring connection: %s ", err) } defer conn.Release() _, err = conn.Exec(ctx, channel) if err != nil { - return fmt.Errorf("Error unlistening to channel: %v", err) + p.logger.Errorf("error listening to channel:", err) + return fmt.Errorf("error listening to channel: %s", err) } delete(p.ActiveSubscriptions, k) } @@ -217,16 +194,15 @@ func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler, channel string, trigger string, subscription string, stop chan struct{}) { conn, err := p.client.Acquire(ctx) if err != nil { - p.logger.Errorf("Error acquiring connection:", err) + p.logger.Errorf("error acquiring connection:", err) return } defer conn.Release() _, err = conn.Exec(ctx, channel) if err != nil { - p.logger.Errorf("Error listening to channel:", err) + p.logger.Errorf("error listening to channel:", err) return } - for { notification, err := conn.Conn().WaitForNotification(ctx) if err != nil { @@ -251,7 +227,6 @@ func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler p.logger.Errorf("Error in UnMarshal: ", err) return } - var key, value, version string m := make(map[string]string) // trigger should encapsulate the row in "data" field in the notification @@ -278,32 +253,32 @@ func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler } } } - } - e := &configuration.UpdateEvent{ - Items: map[string]*configuration.Item{ - key: { - Value: value, - Version: version, - Metadata: m, + e := &configuration.UpdateEvent{ + Items: map[string]*configuration.Item{ + key: { + Value: value, + Version: version, + Metadata: m, + }, }, - }, - ID: subscription, - } - err = handler(ctx, e) - if err != nil { - p.logger.Errorf("fail to call handler to notify event for configuration update subscribe: %s", err) + ID: subscription, + } + err = handler(ctx, e) + if err != nil { + p.logger.Errorf("fail to call handler to notify event for configuration update subscribe: %s", err) + } + } else { + p.logger.Info("unknown format of data received in notify event - '%s'", msg.Payload) } } func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { m := metadata{} - if val, ok := cmetadata.Properties[connectionStringKey]; ok && val != "" { m.connectionString = val } else { return m, fmt.Errorf(ErrorMissingConnectionString) } - if tbl, ok := cmetadata.Properties[configtablekey]; ok && tbl != "" { if !allowedChars.MatchString(tbl) { return m, fmt.Errorf("invalid table name : '%v'. non-alphanumerics are not supported", tbl) @@ -315,20 +290,23 @@ func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { } else { return m, fmt.Errorf(ErrorMissingTableName) } - // configure maxTimeout if provided if mxTimeout, ok := cmetadata.Properties[connMaxIdleTimeKey]; ok && mxTimeout != "" { if t, err := time.ParseDuration(mxTimeout); err == nil { m.maxIdleTime = t } else { - return m, fmt.Errorf(ErrorMissinMaxTimeout) + return m, fmt.Errorf(ErrorMissingMaxTimeout) } } return m, nil } func Connect(ctx context.Context, conn string, maxTimeout time.Duration) (*pgxpool.Pool, error) { - pool, err := pgxpool.Connect(ctx, conn) + config, err := pgxpool.ParseConfig(conn) + if err != nil { + return nil, fmt.Errorf("postgres configuration store connection error : %s", err) + } + pool, err := pgxpool.NewWithConfig(ctx, config) if err != nil { return nil, fmt.Errorf("postgres configuration store connection error : %s", err) } @@ -356,7 +334,6 @@ func buildQuery(req *configuration.GetRequest, configTable string) (string, []in } queryBuilder.WriteString(strings.Join(paramWildcard, " , ")) queryBuilder.WriteString(")") - query = queryBuilder.String() if len(req.Metadata) > 0 { @@ -413,3 +390,27 @@ func validateInput(keys []string) error { } return nil } + +func (p *ConfigurationStore) subscribeToChannel(ctx context.Context, triggers []string, req *configuration.SubscribeRequest, handler configuration.UpdateHandler) (string, error) { + p.configLock.Lock() + var subscribeID string + for _, trigger := range triggers { + notificationChannel := "listen " + trigger + if sub, isActive := p.isSubscriptionActive(req); isActive { + if oldStopChan, ok := p.subscribeStopChanMap[sub]; ok { + close(oldStopChan.(chan struct{})) + } + } + stop := make(chan struct{}) + subscribeID = uuid.New().String() + p.subscribeStopChanMap[subscribeID] = stop + p.ActiveSubscriptions[trigger] = &subscription{ + uuid: subscribeID, + trigger: trigger, + keys: req.Keys, + } + go p.doSubscribe(ctx, req, handler, notificationChannel, trigger, subscribeID, stop) + } + p.configLock.Unlock() + return subscribeID, nil +} diff --git a/configuration/postgres/postgres_test.go b/configuration/postgres/postgres_test.go index 3962fd871..6db16ec8f 100644 --- a/configuration/postgres/postgres_test.go +++ b/configuration/postgres/postgres_test.go @@ -1,5 +1,5 @@ /* -Copyright 2021 The Dapr Authors +Copyright 2022 The Dapr Authors 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 @@ -18,11 +18,34 @@ import ( "regexp" "testing" - "github.com/pashagolub/pgxmock" + "github.com/pashagolub/pgxmock/v2" + "github.com/stretchr/testify/assert" "github.com/dapr/components-contrib/configuration" ) +func TestSelectAllQuery(t *testing.T) { + g := &configuration.GetRequest{} + expected := "SELECT * FROM cfgtbl" + query, _, err := buildQuery(g, "cfgtbl") + if err != nil { + t.Errorf("Error building query: %v ", err) + } + assert.Equal(t, expected, query, "did not get expected result. Got: '%v' , Expected: '%v'", query, expected) + + g = &configuration.GetRequest{ + Keys: []string{}, + Metadata: map[string]string{ + "Version": "1.0", + }, + } + query, _, err = buildQuery(g, "cfgtbl") + if err != nil { + t.Errorf("Error building query: %v ", err) + } + assert.Equal(t, expected, query, "did not get expected result. Got: '%v' , Expected: '%v'", query, expected) +} + func TestPostgresbuildQuery(t *testing.T) { g := &configuration.GetRequest{ Keys: []string{"someKey"}, @@ -37,28 +60,23 @@ func TestPostgresbuildQuery(t *testing.T) { t.Errorf("Error building query: %v ", err) } expected := "SELECT * FROM cfgtbl WHERE KEY IN ($1) AND $2 = $3" - if query != expected { - t.Errorf("Did not get expected result. Got: '%v' , Expected: '%v'", query, expected) - } + assert.Equal(t, expected, query, "did not get expected result. Got: '%v' , Expected: '%v'", query, expected) + // if query != expected { + // t.Errorf("did not get expected result. Got: '%v' , Expected: '%v'", query, expected) + // } i := 0 for _, v := range params { got := v.(string) switch i { case 0: expected := "someKey" - if expected != got { - t.Errorf("Did not get expected result. Got: '%v' , Expected: '%v'", got, expected) - } + assert.Equal(t, expected, got, "Did not get expected result. Got: '%v' , Expected: '%v'", got, expected) case 1: expected := "Version" - if expected != got { - t.Errorf("Did not get expected result. Got: '%v' , Expected: '%v'", got, expected) - } + assert.Equal(t, expected, got, "Did not get expected result. Got: '%v' , Expected: '%v'", got, expected) case 2: expected := "1.0" - if expected != got { - t.Errorf("Did not get expected result. Got: '%v' , Expected: '%v'", got, expected) - } + assert.Equal(t, expected, got, "Did not get expected result. Got: '%v' , Expected: '%v'", got, expected) } i++ } diff --git a/go.mod b/go.mod index a0930e7cf..163fca2e2 100644 --- a/go.mod +++ b/go.mod @@ -98,7 +98,6 @@ require ( github.com/nats-io/nats.go v1.13.1-0.20220308171302-2f2f6968e98d github.com/nats-io/stan.go v0.8.3 github.com/open-policy-agent/opa v0.43.1 - github.com/pashagolub/pgxmock v1.8.0 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/pkg/errors v0.9.1 github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 // indirect @@ -121,7 +120,7 @@ require ( github.com/yuin/gopher-lua v0.0.0-20200603152657-dc2b0ca8b37e // indirect go.mongodb.org/mongo-driver v1.5.1 go.opencensus.io v0.23.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 golang.org/x/net v0.0.0-20220630215102-69896b714898 golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a google.golang.org/api v0.74.0 @@ -167,11 +166,13 @@ require ( github.com/ipfs/go-ipfs-http-client v0.4.0 github.com/ipfs/interface-go-ipfs-core v0.7.0 github.com/ipfs/kubo v0.15.0-rc1 + github.com/jackc/pgx/v5 v5.0.0 github.com/labd/commercetools-go-sdk v0.3.2 github.com/libp2p/go-libp2p-core v0.19.1 github.com/multiformats/go-multiaddr v0.6.0 github.com/multiformats/go-multihash v0.2.1 github.com/nacos-group/nacos-sdk-go/v2 v2.0.1 + github.com/pashagolub/pgxmock/v2 v2.0.0-beta2 github.com/rabbitmq/amqp091-go v1.3.4 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.476 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ssm v1.0.476 @@ -290,6 +291,7 @@ require ( github.com/ipld/edelweiss v0.1.4 // indirect github.com/ipld/go-codec-dagpb v1.4.1 // indirect github.com/ipld/go-ipld-prime v0.17.0 // indirect + github.com/jackc/puddle/v2 v2.0.0 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect github.com/jbenet/goprocess v0.1.4 // indirect @@ -473,7 +475,7 @@ require ( github.com/hashicorp/go-uuid v1.0.2 // indirect github.com/hashicorp/serf v0.9.6 // indirect github.com/jackc/chunkreader/v2 v2.0.1 // indirect - github.com/jackc/pgconn v1.13.0 + github.com/jackc/pgconn v1.13.0 // indirect github.com/jackc/pgio v1.0.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgproto3/v2 v2.3.1 // indirect diff --git a/go.sum b/go.sum index 555b2e68f..06e4b124e 100644 --- a/go.sum +++ b/go.sum @@ -1589,11 +1589,15 @@ github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQ github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= github.com/jackc/pgx/v4 v4.17.0 h1:Hsx+baY8/zU2WtPLQyZi8WbecgcsWEeyoK1jvg/WgIo= github.com/jackc/pgx/v4 v4.17.0/go.mod h1:Gd6RmOhtFLTu8cp/Fhq4kP195KrshxYJH3oW8AWJ1pw= +github.com/jackc/pgx/v5 v5.0.0 h1:3UdmB3yUeTnJtZ+nDv3Mxzd4GHHvHkl9XN3oboIbOrY= +github.com/jackc/pgx/v5 v5.0.0/go.mod h1:JBbvW3Hdw77jKl9uJrEDATUZIFM2VFPzRq4RWIhkF4o= github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.2.1 h1:gI8os0wpRXFd4FiAY2dWiqRK037tjj3t7rKFeO4X5iw= github.com/jackc/puddle v1.2.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle/v2 v2.0.0 h1:Kwk/AlLigcnZsDssc3Zun1dk1tAtQNPaBBxBHWn0Mjc= +github.com/jackc/puddle/v2 v2.0.0/go.mod h1:itE7ZJY8xnoo0JqJEpSMprN0f+NQkMCuEV/N9j8h0oc= github.com/jackpal/gateway v1.0.5/go.mod h1:lTpwd4ACLXmpyiCTRtfiNyVnUmqT9RivzCDQetPfnjA= github.com/jackpal/go-nat-pmp v1.0.1/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= @@ -2489,8 +2493,8 @@ github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIw github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pashagolub/pgxmock v1.8.0 h1:05JB+jng7yPdeC6i04i8TC4H1Kr7TfcFeQyf4JP6534= -github.com/pashagolub/pgxmock v1.8.0/go.mod h1:kDkER7/KJdD3HQjNvFw5siwR7yREKmMvwf8VhAgTK5o= +github.com/pashagolub/pgxmock/v2 v2.0.0-beta2 h1:rE2t+DWZMsYK5mWo9HHGiW6bT5UNqzYSufeZoqKVZgw= +github.com/pashagolub/pgxmock/v2 v2.0.0-beta2/go.mod h1:EtBHVYgdXScsC19CLlUFk/IZA1rjY8UaRPKE1XxyM6w= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= @@ -3140,8 +3144,9 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= From 367ed0fb897b52f8a979a48a46950826deae157a Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Tue, 20 Sep 2022 15:30:54 +0530 Subject: [PATCH 23/39] fixing review comments Signed-off-by: akhilac1 --- configuration/postgres/metadata.go | 2 +- configuration/postgres/postgres.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configuration/postgres/metadata.go b/configuration/postgres/metadata.go index a1c4296e9..456ce6570 100644 --- a/configuration/postgres/metadata.go +++ b/configuration/postgres/metadata.go @@ -16,7 +16,7 @@ package postgres import "time" type metadata struct { - maxIdleTime time.Duration + maxIdleTimeout time.Duration connectionString string configTable string } diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index 294e08019..6d85646c9 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -87,9 +87,9 @@ func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { p.metadata = m } p.ActiveSubscriptions = make(map[string]*subscription) - ctx, cancel := context.WithTimeout(context.Background(), p.metadata.maxIdleTime) + ctx, cancel := context.WithTimeout(context.Background(), p.metadata.maxIdleTimeout) defer cancel() - client, err := Connect(ctx, p.metadata.connectionString, p.metadata.maxIdleTime) + client, err := Connect(ctx, p.metadata.connectionString, p.metadata.maxIdleTimeout) if err != nil { return fmt.Errorf("error connecting to configuration store: '%s'", err) } @@ -293,7 +293,7 @@ func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { // configure maxTimeout if provided if mxTimeout, ok := cmetadata.Properties[connMaxIdleTimeKey]; ok && mxTimeout != "" { if t, err := time.ParseDuration(mxTimeout); err == nil { - m.maxIdleTime = t + m.maxIdleTimeout = t } else { return m, fmt.Errorf(ErrorMissingMaxTimeout) } From 674668056832cc7ac9e0767f2b7334c6b9eae110 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Tue, 20 Sep 2022 17:16:03 +0530 Subject: [PATCH 24/39] fixing review comments Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 38 ++++++++++++++++++++---------- go.mod | 2 +- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index 6d85646c9..b31cbfbb3 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -29,6 +29,7 @@ import ( "github.com/google/uuid" "github.com/jackc/pgx/v5/pgconn" "github.com/jackc/pgx/v5/pgxpool" + "k8s.io/utils/strings/slices" "github.com/dapr/components-contrib/configuration" "github.com/dapr/kit/logger" @@ -65,6 +66,7 @@ const ( ) var allowedChars = regexp.MustCompile(`^[a-zA-Z0-9./_]*$`) +var defaultMaxConnIdleTime = time.Minute * 30 func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store { logger.Debug("Instantiating PostgreSQL configuration store") @@ -72,6 +74,11 @@ func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store { logger: logger, subscribeStopChanMap: make(map[string]interface{}), configLock: sync.Mutex{}, + metadata: metadata{ + maxIdleTimeout: 0, + connectionString: "", + configTable: "", + }, } } @@ -166,6 +173,13 @@ func (p *ConfigurationStore) Subscribe(ctx context.Context, req *configuration.S func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration.UnsubscribeRequest) error { p.configLock.Lock() defer p.configLock.Unlock() + for _, v := range p.ActiveSubscriptions { + if v.uuid == req.ID { + break + } else { + return fmt.Errorf("unable to find subscription with ID : %v", req.ID) + } + } if oldStopChan, ok := p.subscribeStopChanMap[req.ID]; ok { delete(p.subscribeStopChanMap, req.ID) close(oldStopChan.(chan struct{})) @@ -207,7 +221,7 @@ func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration notification, err := conn.Conn().WaitForNotification(ctx) if err != nil { if !(pgconn.Timeout(err) || errors.Is(ctx.Err(), context.Canceled)) { - p.logger.Errorf("Error waiting for notification:", err) + p.logger.Errorf("error waiting for notification:", err) } return } @@ -218,13 +232,13 @@ func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler configuration.UpdateHandler, msg *pgconn.Notification, trigger string, subscription string) { defer func() { if err := recover(); err != nil { - p.logger.Errorf("panic in handleSubscribedChange method and recovered: %s", err) + p.logger.Errorf("panic in handlesubscribedchange method and recovered: %s", err) } }() payload := make(map[string]interface{}) err := json.Unmarshal([]byte(msg.Payload), &payload) if err != nil { - p.logger.Errorf("Error in UnMarshal: ", err) + p.logger.Errorf("error in unmarshal: ", err) return } var key, value, version string @@ -239,7 +253,7 @@ func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler case "key": key = v.Interface().(string) if yes := p.isSubscribed(trigger, key, subscription); !yes { - p.logger.Debugf("Ignoring notification for %v", key) + p.logger.Debugf("ignoring notification for %v", key) return } case "value": @@ -294,10 +308,11 @@ func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { if mxTimeout, ok := cmetadata.Properties[connMaxIdleTimeKey]; ok && mxTimeout != "" { if t, err := time.ParseDuration(mxTimeout); err == nil { m.maxIdleTimeout = t - } else { - return m, fmt.Errorf(ErrorMissingMaxTimeout) } } + if m.maxIdleTimeout == 0 { + m.maxIdleTimeout = defaultMaxConnIdleTime + } return m, nil } @@ -367,13 +382,9 @@ func (p *ConfigurationStore) isSubscriptionActive(req *configuration.SubscribeRe } func (p *ConfigurationStore) isSubscribed(trigger string, key string, subscription string) bool { - for t, s := range p.ActiveSubscriptions { - if t == trigger && s.uuid == subscription { - for _, k := range s.keys { - if k == key { - return true - } - } + if val, yes := p.ActiveSubscriptions[trigger]; yes { + if val.uuid == subscription && slices.Contains(val.keys, key) { + return true } } return false @@ -399,6 +410,7 @@ func (p *ConfigurationStore) subscribeToChannel(ctx context.Context, triggers [] if sub, isActive := p.isSubscriptionActive(req); isActive { if oldStopChan, ok := p.subscribeStopChanMap[sub]; ok { close(oldStopChan.(chan struct{})) + delete(p.subscribeStopChanMap, sub) } } stop := make(chan struct{}) diff --git a/go.mod b/go.mod index 163fca2e2..2bb2f996f 100644 --- a/go.mod +++ b/go.mod @@ -540,7 +540,7 @@ require ( gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect k8s.io/klog/v2 v2.30.0 // indirect - k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b // indirect + k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b nhooyr.io/websocket v1.8.7 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.0 // indirect sigs.k8s.io/yaml v1.3.0 // indirect From 37fffb8f893858f4251cee757191ec510e8b38fd Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Tue, 20 Sep 2022 20:28:57 +0530 Subject: [PATCH 25/39] renamed trigger to channel Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 80 ++++++++++++++++-------------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index b31cbfbb3..d6dc6c6d5 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -45,15 +45,18 @@ type ConfigurationStore struct { } type subscription struct { - uuid string - trigger string - keys []string + uuid string + keys []string } const ( configtablekey = "table" connMaxIdleTimeKey = "connMaxIdleTime" connectionStringKey = "connectionString" + pgNotifyChannelKey = "pgNotifyChannel" + listenTemplate = "listen %s" + unlistenTemplate = "unlisten %s" + payloadDataKey = "data" ErrorMissingTableName = "missing postgreSQL configuration table name" ErrorMissingTable = "postgreSQL configuration table - '%v' does not exist" InfoStartInit = "initializing postgreSQL configuration store" @@ -65,8 +68,10 @@ const ( maxIdentifierLength = 64 // https://www.postgresql.org/docs/current/limits.html ) -var allowedChars = regexp.MustCompile(`^[a-zA-Z0-9./_]*$`) -var defaultMaxConnIdleTime = time.Minute * 30 +var ( + allowedChars = regexp.MustCompile(`^[a-zA-Z0-9./_]*$`) + defaultMaxConnIdleTime = time.Minute * 30 +) func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store { logger.Debug("Instantiating PostgreSQL configuration store") @@ -158,16 +163,16 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ } func (p *ConfigurationStore) Subscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler) (string, error) { - var triggers []string + var pgNotifyChannels []string for k, v := range req.Metadata { - if res := strings.EqualFold("trigger", k); res { - triggers = append(triggers, v) + if res := strings.EqualFold(pgNotifyChannelKey, k) && !slices.Contains(pgNotifyChannels, v); res { + pgNotifyChannels = append(pgNotifyChannels, v) //append unique channel names only } } - if len(triggers) == 0 { - return "", fmt.Errorf("cannot subscribe to empty trigger") + if len(pgNotifyChannels) == 0 { + return "", fmt.Errorf("cannot subscribe to empty channel") } - return p.subscribeToChannel(ctx, triggers, req, handler) + return p.subscribeToChannel(ctx, pgNotifyChannels, req, handler) } func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration.UnsubscribeRequest) error { @@ -185,14 +190,14 @@ func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration close(oldStopChan.(chan struct{})) for k, v := range p.ActiveSubscriptions { if v.uuid == req.ID { - channel := "unlisten " + v.trigger + pgChannel := fmt.Sprintf(unlistenTemplate, k) conn, err := p.client.Acquire(ctx) if err != nil { p.logger.Errorf("error acquiring connection:", err) return fmt.Errorf("error acquiring connection: %s ", err) } defer conn.Release() - _, err = conn.Exec(ctx, channel) + _, err = conn.Exec(ctx, pgChannel) if err != nil { p.logger.Errorf("error listening to channel:", err) return fmt.Errorf("error listening to channel: %s", err) @@ -205,22 +210,21 @@ func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration return fmt.Errorf("unable to find subscription with ID : %v", req.ID) } -func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler, channel string, trigger string, subscription string, stop chan struct{}) { +func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler, command string, trigger string, subscription string, stop chan struct{}) { conn, err := p.client.Acquire(ctx) if err != nil { p.logger.Errorf("error acquiring connection:", err) return } defer conn.Release() - _, err = conn.Exec(ctx, channel) - if err != nil { + if _, err = conn.Exec(ctx, command); err != nil { p.logger.Errorf("error listening to channel:", err) return } for { notification, err := conn.Conn().WaitForNotification(ctx) if err != nil { - if !(pgconn.Timeout(err) || errors.Is(ctx.Err(), context.Canceled)) { + if !pgconn.Timeout(err) && !errors.Is(ctx.Err(), context.Canceled) { p.logger.Errorf("error waiting for notification:", err) } return @@ -229,7 +233,7 @@ func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration } } -func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler configuration.UpdateHandler, msg *pgconn.Notification, trigger string, subscription string) { +func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler configuration.UpdateHandler, msg *pgconn.Notification, channel string, subscriptionID string) { defer func() { if err := recover(); err != nil { p.logger.Errorf("panic in handlesubscribedchange method and recovered: %s", err) @@ -244,7 +248,7 @@ func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler var key, value, version string m := make(map[string]string) // trigger should encapsulate the row in "data" field in the notification - row := reflect.ValueOf(payload["data"]) + row := reflect.ValueOf(payload[payloadDataKey]) if row.Kind() == reflect.Map { for _, k := range row.MapKeys() { v := row.MapIndex(k) @@ -252,7 +256,7 @@ func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler switch strings.ToLower(strKey) { case "key": key = v.Interface().(string) - if yes := p.isSubscribed(trigger, key, subscription); !yes { + if yes := p.isSubscribed(subscriptionID, channel, key); !yes { p.logger.Debugf("ignoring notification for %v", key) return } @@ -275,7 +279,7 @@ func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler Metadata: m, }, }, - ID: subscription, + ID: subscriptionID, } err = handler(ctx, e) if err != nil { @@ -371,9 +375,9 @@ func buildQuery(req *configuration.GetRequest, configTable string) (string, []in } func (p *ConfigurationStore) isSubscriptionActive(req *configuration.SubscribeRequest) (string, bool) { - for _, trigger := range req.Metadata { + for _, channel := range req.Metadata { for key2, sub := range p.ActiveSubscriptions { - if res := strings.EqualFold(trigger, key2); res { + if res := strings.EqualFold(channel, key2); res { return sub.uuid, true } } @@ -381,9 +385,9 @@ func (p *ConfigurationStore) isSubscriptionActive(req *configuration.SubscribeRe return " ", false } -func (p *ConfigurationStore) isSubscribed(trigger string, key string, subscription string) bool { - if val, yes := p.ActiveSubscriptions[trigger]; yes { - if val.uuid == subscription && slices.Contains(val.keys, key) { +func (p *ConfigurationStore) isSubscribed(subscriptionID string, channel string, key string) bool { + if val, yes := p.ActiveSubscriptions[channel]; yes { + if val.uuid == subscriptionID && slices.Contains(val.keys, key) { return true } } @@ -402,26 +406,26 @@ func validateInput(keys []string) error { return nil } -func (p *ConfigurationStore) subscribeToChannel(ctx context.Context, triggers []string, req *configuration.SubscribeRequest, handler configuration.UpdateHandler) (string, error) { +func (p *ConfigurationStore) subscribeToChannel(ctx context.Context, pgNotifyChanList []string, req *configuration.SubscribeRequest, handler configuration.UpdateHandler) (string, error) { p.configLock.Lock() - var subscribeID string - for _, trigger := range triggers { - notificationChannel := "listen " + trigger + var subscribeID string // TO_DO - duplicate trigger + for _, channel := range pgNotifyChanList { + pgNotifyCmd := fmt.Sprintf(listenTemplate, channel) if sub, isActive := p.isSubscriptionActive(req); isActive { - if oldStopChan, ok := p.subscribeStopChanMap[sub]; ok { - close(oldStopChan.(chan struct{})) - delete(p.subscribeStopChanMap, sub) + p.configLock.Unlock() + if err := p.Unsubscribe(ctx, &configuration.UnsubscribeRequest{ID: sub}); err != nil { + return "", fmt.Errorf("error in unsubscribing from existing channel: '%s' ", channel) } + p.configLock.Lock() } stop := make(chan struct{}) subscribeID = uuid.New().String() p.subscribeStopChanMap[subscribeID] = stop - p.ActiveSubscriptions[trigger] = &subscription{ - uuid: subscribeID, - trigger: trigger, - keys: req.Keys, + p.ActiveSubscriptions[channel] = &subscription{ + uuid: subscribeID, + keys: req.Keys, } - go p.doSubscribe(ctx, req, handler, notificationChannel, trigger, subscribeID, stop) + go p.doSubscribe(ctx, req, handler, pgNotifyCmd, channel, subscribeID, stop) } p.configLock.Unlock() return subscribeID, nil From b8574c0ce9e8a534a7e9c32279464d4a58553e47 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Tue, 20 Sep 2022 22:54:45 +0530 Subject: [PATCH 26/39] correcting name from trigger to channel to match with standard postgres terminology Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index d6dc6c6d5..1d3e74b6b 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -166,7 +166,7 @@ func (p *ConfigurationStore) Subscribe(ctx context.Context, req *configuration.S var pgNotifyChannels []string for k, v := range req.Metadata { if res := strings.EqualFold(pgNotifyChannelKey, k) && !slices.Contains(pgNotifyChannels, v); res { - pgNotifyChannels = append(pgNotifyChannels, v) //append unique channel names only + pgNotifyChannels = append(pgNotifyChannels, v) // append unique channel names only } } if len(pgNotifyChannels) == 0 { @@ -210,7 +210,7 @@ func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration return fmt.Errorf("unable to find subscription with ID : %v", req.ID) } -func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler, command string, trigger string, subscription string, stop chan struct{}) { +func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration.SubscribeRequest, handler configuration.UpdateHandler, command string, channel string, subscription string, stop chan struct{}) { conn, err := p.client.Acquire(ctx) if err != nil { p.logger.Errorf("error acquiring connection:", err) @@ -229,7 +229,7 @@ func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration } return } - p.handleSubscribedChange(ctx, handler, notification, trigger, subscription) + p.handleSubscribedChange(ctx, handler, notification, channel, subscription) } } @@ -412,11 +412,11 @@ func (p *ConfigurationStore) subscribeToChannel(ctx context.Context, pgNotifyCha for _, channel := range pgNotifyChanList { pgNotifyCmd := fmt.Sprintf(listenTemplate, channel) if sub, isActive := p.isSubscriptionActive(req); isActive { - p.configLock.Unlock() - if err := p.Unsubscribe(ctx, &configuration.UnsubscribeRequest{ID: sub}); err != nil { - return "", fmt.Errorf("error in unsubscribing from existing channel: '%s' ", channel) + if oldStopChan, ok := p.subscribeStopChanMap[sub]; ok { + close(oldStopChan.(chan struct{})) + delete(p.subscribeStopChanMap, sub) + delete(p.ActiveSubscriptions, channel) } - p.configLock.Lock() } stop := make(chan struct{}) subscribeID = uuid.New().String() From 3408067248a546ae104047a0e70a8c36697e86d3 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Tue, 20 Sep 2022 23:11:20 +0530 Subject: [PATCH 27/39] fixed assertion in postgres_test.go Signed-off-by: akhilac1 --- configuration/postgres/postgres_test.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/configuration/postgres/postgres_test.go b/configuration/postgres/postgres_test.go index 6db16ec8f..ea0f74947 100644 --- a/configuration/postgres/postgres_test.go +++ b/configuration/postgres/postgres_test.go @@ -61,9 +61,6 @@ func TestPostgresbuildQuery(t *testing.T) { } expected := "SELECT * FROM cfgtbl WHERE KEY IN ($1) AND $2 = $3" assert.Equal(t, expected, query, "did not get expected result. Got: '%v' , Expected: '%v'", query, expected) - // if query != expected { - // t.Errorf("did not get expected result. Got: '%v' , Expected: '%v'", query, expected) - // } i := 0 for _, v := range params { got := v.(string) @@ -89,9 +86,7 @@ func TestConnectAndQuery(t *testing.T) { } mock, err := pgxmock.NewPool() - if err != nil { - t.Fatalf("an error '%s' was not expected when opening a stub database connection", err) - } + assert.Nil(t, err) defer mock.Close() query := "SELECT EXISTS (SELECT FROM pg_tables where tablename = '" + m.configTable + "'" @@ -106,7 +101,6 @@ func TestConnectAndQuery(t *testing.T) { if err != nil { t.Error(err) } - if err := mock.ExpectationsWereMet(); err != nil { - t.Errorf("there were unfulfilled expectations: %s", err) - } + err = mock.ExpectationsWereMet() + assert.Nil(t, err) } From 90ba8a441d6ccc8987acf115ca4adf1f49fa9fba Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Wed, 21 Sep 2022 09:48:41 +0530 Subject: [PATCH 28/39] fix modtidy Signed-off-by: akhilac1 --- tests/certification/bindings/alicloud/dubbo/go.mod | 2 +- tests/certification/bindings/alicloud/dubbo/go.sum | 4 ++-- tests/certification/bindings/azure/blobstorage/go.mod | 2 +- tests/certification/bindings/azure/blobstorage/go.sum | 4 ++-- tests/certification/bindings/azure/cosmosdb/go.mod | 2 +- tests/certification/bindings/azure/cosmosdb/go.sum | 4 ++-- tests/certification/bindings/azure/eventhubs/go.mod | 2 +- tests/certification/bindings/azure/eventhubs/go.sum | 4 ++-- tests/certification/bindings/azure/servicebusqueues/go.mod | 2 +- tests/certification/bindings/azure/servicebusqueues/go.sum | 4 ++-- tests/certification/bindings/azure/storagequeues/go.mod | 2 +- tests/certification/bindings/azure/storagequeues/go.sum | 4 ++-- tests/certification/bindings/kafka/go.mod | 2 +- tests/certification/bindings/kafka/go.sum | 4 ++-- tests/certification/bindings/postgres/go.mod | 2 +- tests/certification/bindings/postgres/go.sum | 3 ++- tests/certification/pubsub/azure/eventhubs/go.mod | 2 +- tests/certification/pubsub/azure/eventhubs/go.sum | 4 ++-- tests/certification/pubsub/azure/servicebus/go.mod | 2 +- tests/certification/pubsub/azure/servicebus/go.sum | 4 ++-- tests/certification/pubsub/kafka/go.mod | 2 +- tests/certification/pubsub/kafka/go.sum | 4 ++-- tests/certification/secretstores/azure/keyvault/go.mod | 2 +- tests/certification/secretstores/azure/keyvault/go.sum | 4 ++-- tests/certification/state/azure/blobstorage/go.mod | 2 +- tests/certification/state/azure/blobstorage/go.sum | 4 ++-- tests/certification/state/azure/cosmosdb/go.mod | 2 +- tests/certification/state/azure/cosmosdb/go.sum | 4 ++-- tests/certification/state/azure/tablestorage/go.mod | 2 +- tests/certification/state/azure/tablestorage/go.sum | 4 ++-- tests/certification/state/mongodb/go.mod | 2 +- tests/certification/state/mongodb/go.sum | 4 ++-- tests/certification/state/postgresql/go.mod | 2 +- tests/certification/state/postgresql/go.sum | 3 ++- tests/certification/state/sqlserver/go.mod | 2 +- tests/certification/state/sqlserver/go.sum | 4 ++-- tests/e2e/pubsub/jetstream/go.mod | 2 +- tests/e2e/pubsub/jetstream/go.sum | 4 ++-- 38 files changed, 57 insertions(+), 55 deletions(-) diff --git a/tests/certification/bindings/alicloud/dubbo/go.mod b/tests/certification/bindings/alicloud/dubbo/go.mod index a2983855d..fa81bfa65 100644 --- a/tests/certification/bindings/alicloud/dubbo/go.mod +++ b/tests/certification/bindings/alicloud/dubbo/go.mod @@ -129,7 +129,7 @@ require ( go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect go.uber.org/zap v1.21.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/bindings/alicloud/dubbo/go.sum b/tests/certification/bindings/alicloud/dubbo/go.sum index 01d793f8c..815d1fea4 100644 --- a/tests/certification/bindings/alicloud/dubbo/go.sum +++ b/tests/certification/bindings/alicloud/dubbo/go.sum @@ -1062,8 +1062,8 @@ golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= diff --git a/tests/certification/bindings/azure/blobstorage/go.mod b/tests/certification/bindings/azure/blobstorage/go.mod index 3caa1150d..6ac07fe79 100644 --- a/tests/certification/bindings/azure/blobstorage/go.mod +++ b/tests/certification/bindings/azure/blobstorage/go.mod @@ -116,7 +116,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/bindings/azure/blobstorage/go.sum b/tests/certification/bindings/azure/blobstorage/go.sum index f11c3ec28..24ae198e7 100644 --- a/tests/certification/bindings/azure/blobstorage/go.sum +++ b/tests/certification/bindings/azure/blobstorage/go.sum @@ -779,8 +779,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/bindings/azure/cosmosdb/go.mod b/tests/certification/bindings/azure/cosmosdb/go.mod index 174215d86..e66dc3bf6 100644 --- a/tests/certification/bindings/azure/cosmosdb/go.mod +++ b/tests/certification/bindings/azure/cosmosdb/go.mod @@ -118,7 +118,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/bindings/azure/cosmosdb/go.sum b/tests/certification/bindings/azure/cosmosdb/go.sum index 2ad3dc042..1db160840 100644 --- a/tests/certification/bindings/azure/cosmosdb/go.sum +++ b/tests/certification/bindings/azure/cosmosdb/go.sum @@ -784,8 +784,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/bindings/azure/eventhubs/go.mod b/tests/certification/bindings/azure/eventhubs/go.mod index c0dbbd955..886041634 100644 --- a/tests/certification/bindings/azure/eventhubs/go.mod +++ b/tests/certification/bindings/azure/eventhubs/go.mod @@ -125,7 +125,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/bindings/azure/eventhubs/go.sum b/tests/certification/bindings/azure/eventhubs/go.sum index 77a35c980..bb720df16 100644 --- a/tests/certification/bindings/azure/eventhubs/go.sum +++ b/tests/certification/bindings/azure/eventhubs/go.sum @@ -806,8 +806,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/bindings/azure/servicebusqueues/go.mod b/tests/certification/bindings/azure/servicebusqueues/go.mod index a7b7eed5e..816241361 100644 --- a/tests/certification/bindings/azure/servicebusqueues/go.mod +++ b/tests/certification/bindings/azure/servicebusqueues/go.mod @@ -122,7 +122,7 @@ require ( go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/ratelimit v0.2.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/bindings/azure/servicebusqueues/go.sum b/tests/certification/bindings/azure/servicebusqueues/go.sum index 039e97182..3435b1e6f 100644 --- a/tests/certification/bindings/azure/servicebusqueues/go.sum +++ b/tests/certification/bindings/azure/servicebusqueues/go.sum @@ -794,8 +794,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/bindings/azure/storagequeues/go.mod b/tests/certification/bindings/azure/storagequeues/go.mod index b380d82d9..89917acde 100644 --- a/tests/certification/bindings/azure/storagequeues/go.mod +++ b/tests/certification/bindings/azure/storagequeues/go.mod @@ -118,7 +118,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/bindings/azure/storagequeues/go.sum b/tests/certification/bindings/azure/storagequeues/go.sum index f15cc176f..12a079ffe 100644 --- a/tests/certification/bindings/azure/storagequeues/go.sum +++ b/tests/certification/bindings/azure/storagequeues/go.sum @@ -781,8 +781,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/bindings/kafka/go.mod b/tests/certification/bindings/kafka/go.mod index 04479000d..a9844173b 100644 --- a/tests/certification/bindings/kafka/go.mod +++ b/tests/certification/bindings/kafka/go.mod @@ -113,7 +113,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/bindings/kafka/go.sum b/tests/certification/bindings/kafka/go.sum index 0ab1ae14a..6d18f3d8f 100644 --- a/tests/certification/bindings/kafka/go.sum +++ b/tests/certification/bindings/kafka/go.sum @@ -737,8 +737,8 @@ golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/bindings/postgres/go.mod b/tests/certification/bindings/postgres/go.mod index 23640b2c9..c9223c732 100644 --- a/tests/certification/bindings/postgres/go.mod +++ b/tests/certification/bindings/postgres/go.mod @@ -104,7 +104,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/bindings/postgres/go.sum b/tests/certification/bindings/postgres/go.sum index 008c85284..5f4d7173d 100644 --- a/tests/certification/bindings/postgres/go.sum +++ b/tests/certification/bindings/postgres/go.sum @@ -800,8 +800,9 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/pubsub/azure/eventhubs/go.mod b/tests/certification/pubsub/azure/eventhubs/go.mod index fa2f68b3b..a3f6f0281 100644 --- a/tests/certification/pubsub/azure/eventhubs/go.mod +++ b/tests/certification/pubsub/azure/eventhubs/go.mod @@ -124,7 +124,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/pubsub/azure/eventhubs/go.sum b/tests/certification/pubsub/azure/eventhubs/go.sum index 4d2ed46d9..df1c8302a 100644 --- a/tests/certification/pubsub/azure/eventhubs/go.sum +++ b/tests/certification/pubsub/azure/eventhubs/go.sum @@ -804,8 +804,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/pubsub/azure/servicebus/go.mod b/tests/certification/pubsub/azure/servicebus/go.mod index c61a8b8c2..9df284f39 100644 --- a/tests/certification/pubsub/azure/servicebus/go.mod +++ b/tests/certification/pubsub/azure/servicebus/go.mod @@ -122,7 +122,7 @@ require ( go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/ratelimit v0.2.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/pubsub/azure/servicebus/go.sum b/tests/certification/pubsub/azure/servicebus/go.sum index b6f5b6f45..ed0b1433e 100644 --- a/tests/certification/pubsub/azure/servicebus/go.sum +++ b/tests/certification/pubsub/azure/servicebus/go.sum @@ -791,8 +791,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/pubsub/kafka/go.mod b/tests/certification/pubsub/kafka/go.mod index 88e49ad36..86d464162 100644 --- a/tests/certification/pubsub/kafka/go.mod +++ b/tests/certification/pubsub/kafka/go.mod @@ -113,7 +113,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/pubsub/kafka/go.sum b/tests/certification/pubsub/kafka/go.sum index 0ab1ae14a..6d18f3d8f 100644 --- a/tests/certification/pubsub/kafka/go.sum +++ b/tests/certification/pubsub/kafka/go.sum @@ -737,8 +737,8 @@ golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/secretstores/azure/keyvault/go.mod b/tests/certification/secretstores/azure/keyvault/go.mod index a0a02ad05..b33b47ca0 100644 --- a/tests/certification/secretstores/azure/keyvault/go.mod +++ b/tests/certification/secretstores/azure/keyvault/go.mod @@ -117,7 +117,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/secretstores/azure/keyvault/go.sum b/tests/certification/secretstores/azure/keyvault/go.sum index b609348c9..7e4488031 100644 --- a/tests/certification/secretstores/azure/keyvault/go.sum +++ b/tests/certification/secretstores/azure/keyvault/go.sum @@ -781,8 +781,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/state/azure/blobstorage/go.mod b/tests/certification/state/azure/blobstorage/go.mod index a9edc6096..4f583e1ee 100644 --- a/tests/certification/state/azure/blobstorage/go.mod +++ b/tests/certification/state/azure/blobstorage/go.mod @@ -116,7 +116,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/state/azure/blobstorage/go.sum b/tests/certification/state/azure/blobstorage/go.sum index 630ed1066..a155170e7 100644 --- a/tests/certification/state/azure/blobstorage/go.sum +++ b/tests/certification/state/azure/blobstorage/go.sum @@ -778,8 +778,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/state/azure/cosmosdb/go.mod b/tests/certification/state/azure/cosmosdb/go.mod index a0572de68..dc57ee7ae 100644 --- a/tests/certification/state/azure/cosmosdb/go.mod +++ b/tests/certification/state/azure/cosmosdb/go.mod @@ -117,7 +117,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/state/azure/cosmosdb/go.sum b/tests/certification/state/azure/cosmosdb/go.sum index 0d904060b..113510661 100644 --- a/tests/certification/state/azure/cosmosdb/go.sum +++ b/tests/certification/state/azure/cosmosdb/go.sum @@ -782,8 +782,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/state/azure/tablestorage/go.mod b/tests/certification/state/azure/tablestorage/go.mod index 32ccc8c3b..08b4abf73 100644 --- a/tests/certification/state/azure/tablestorage/go.mod +++ b/tests/certification/state/azure/tablestorage/go.mod @@ -116,7 +116,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/state/azure/tablestorage/go.sum b/tests/certification/state/azure/tablestorage/go.sum index 3bf5f03a3..7be61a88f 100644 --- a/tests/certification/state/azure/tablestorage/go.sum +++ b/tests/certification/state/azure/tablestorage/go.sum @@ -779,8 +779,8 @@ golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/state/mongodb/go.mod b/tests/certification/state/mongodb/go.mod index cdf5233ae..663962b3d 100644 --- a/tests/certification/state/mongodb/go.mod +++ b/tests/certification/state/mongodb/go.mod @@ -104,7 +104,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/state/mongodb/go.sum b/tests/certification/state/mongodb/go.sum index 8c91939e4..0a4b45ae1 100644 --- a/tests/certification/state/mongodb/go.sum +++ b/tests/certification/state/mongodb/go.sum @@ -774,8 +774,8 @@ golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/state/postgresql/go.mod b/tests/certification/state/postgresql/go.mod index 082a92f92..181d4b413 100644 --- a/tests/certification/state/postgresql/go.mod +++ b/tests/certification/state/postgresql/go.mod @@ -102,7 +102,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/state/postgresql/go.sum b/tests/certification/state/postgresql/go.sum index cbc2e9508..d69e86c1c 100644 --- a/tests/certification/state/postgresql/go.sum +++ b/tests/certification/state/postgresql/go.sum @@ -800,8 +800,9 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/certification/state/sqlserver/go.mod b/tests/certification/state/sqlserver/go.mod index 1328cd587..dbc5ca0c5 100644 --- a/tests/certification/state/sqlserver/go.mod +++ b/tests/certification/state/sqlserver/go.mod @@ -97,7 +97,7 @@ require ( go.opentelemetry.io/otel/trace v1.7.0 // indirect go.opentelemetry.io/proto/otlp v0.16.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220630215102-69896b714898 // indirect golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect diff --git a/tests/certification/state/sqlserver/go.sum b/tests/certification/state/sqlserver/go.sum index d4f7c2205..7bea6d1dc 100644 --- a/tests/certification/state/sqlserver/go.sum +++ b/tests/certification/state/sqlserver/go.sum @@ -719,8 +719,8 @@ golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= diff --git a/tests/e2e/pubsub/jetstream/go.mod b/tests/e2e/pubsub/jetstream/go.mod index 5498f24fe..d41c6d77f 100644 --- a/tests/e2e/pubsub/jetstream/go.mod +++ b/tests/e2e/pubsub/jetstream/go.mod @@ -16,7 +16,7 @@ require ( github.com/nats-io/nuid v1.0.1 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/sirupsen/logrus v1.9.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect ) diff --git a/tests/e2e/pubsub/jetstream/go.sum b/tests/e2e/pubsub/jetstream/go.sum index 7e63e0a29..8460fa91e 100644 --- a/tests/e2e/pubsub/jetstream/go.sum +++ b/tests/e2e/pubsub/jetstream/go.sum @@ -30,8 +30,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= +golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ= From b03c77f2d66eebe404b31e148e656e73b7e28e6b Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Wed, 21 Sep 2022 14:10:04 +0530 Subject: [PATCH 29/39] check for maxTimeout to be positive Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 6 +++--- configuration/postgres/postgres_test.go | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index 1d3e74b6b..d2d8bdf6e 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -58,7 +58,7 @@ const ( unlistenTemplate = "unlisten %s" payloadDataKey = "data" ErrorMissingTableName = "missing postgreSQL configuration table name" - ErrorMissingTable = "postgreSQL configuration table - '%v' does not exist" + ErrorMissingTable = "postgreSQL configuration table - '%s' does not exist" InfoStartInit = "initializing postgreSQL configuration store" ErrorMissingConnectionString = "missing postgreSQL connection string" ErrorAlreadyInitialized = "postgreSQL configuration store already initialized" @@ -203,9 +203,9 @@ func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration return fmt.Errorf("error listening to channel: %s", err) } delete(p.ActiveSubscriptions, k) + return nil } } - return nil } return fmt.Errorf("unable to find subscription with ID : %v", req.ID) } @@ -310,7 +310,7 @@ func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { } // configure maxTimeout if provided if mxTimeout, ok := cmetadata.Properties[connMaxIdleTimeKey]; ok && mxTimeout != "" { - if t, err := time.ParseDuration(mxTimeout); err == nil { + if t, err := time.ParseDuration(mxTimeout); err == nil && t > 0 { m.maxIdleTimeout = t } } diff --git a/configuration/postgres/postgres_test.go b/configuration/postgres/postgres_test.go index ea0f74947..8a5a18a17 100644 --- a/configuration/postgres/postgres_test.go +++ b/configuration/postgres/postgres_test.go @@ -98,9 +98,7 @@ func TestConnectAndQuery(t *testing.T) { rows := mock.QueryRow(context.Background(), query) var id string err = rows.Scan(&id) - if err != nil { - t.Error(err) - } + assert.Nil(t, err) err = mock.ExpectationsWereMet() assert.Nil(t, err) } From fff6c5c061e7170baaf4592a9a49af5a8882072c Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Wed, 21 Sep 2022 21:16:56 +0530 Subject: [PATCH 30/39] closing review comments on error message text and loop optimization in unsubscribe method Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 20 +++++++------------- configuration/postgres/postgres_test.go | 4 ++-- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index d2d8bdf6e..16cfbf29c 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -170,7 +170,7 @@ func (p *ConfigurationStore) Subscribe(ctx context.Context, req *configuration.S } } if len(pgNotifyChannels) == 0 { - return "", fmt.Errorf("cannot subscribe to empty channel") + return "", fmt.Errorf("unable to subscribe to '%s'.pgNotifyChannel attribute cannot be empty", p.metadata.configTable) } return p.subscribeToChannel(ctx, pgNotifyChannels, req, handler) } @@ -178,18 +178,11 @@ func (p *ConfigurationStore) Subscribe(ctx context.Context, req *configuration.S func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration.UnsubscribeRequest) error { p.configLock.Lock() defer p.configLock.Unlock() - for _, v := range p.ActiveSubscriptions { + for k, v := range p.ActiveSubscriptions { if v.uuid == req.ID { - break - } else { - return fmt.Errorf("unable to find subscription with ID : %v", req.ID) - } - } - if oldStopChan, ok := p.subscribeStopChanMap[req.ID]; ok { - delete(p.subscribeStopChanMap, req.ID) - close(oldStopChan.(chan struct{})) - for k, v := range p.ActiveSubscriptions { - if v.uuid == req.ID { + if oldStopChan, ok := p.subscribeStopChanMap[req.ID]; ok { + delete(p.subscribeStopChanMap, req.ID) + close(oldStopChan.(chan struct{})) pgChannel := fmt.Sprintf(unlistenTemplate, k) conn, err := p.client.Acquire(ctx) if err != nil { @@ -207,6 +200,7 @@ func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration } } } + return fmt.Errorf("unable to find subscription with ID : %v", req.ID) } @@ -408,6 +402,7 @@ func validateInput(keys []string) error { func (p *ConfigurationStore) subscribeToChannel(ctx context.Context, pgNotifyChanList []string, req *configuration.SubscribeRequest, handler configuration.UpdateHandler) (string, error) { p.configLock.Lock() + defer p.configLock.Unlock() var subscribeID string // TO_DO - duplicate trigger for _, channel := range pgNotifyChanList { pgNotifyCmd := fmt.Sprintf(listenTemplate, channel) @@ -427,6 +422,5 @@ func (p *ConfigurationStore) subscribeToChannel(ctx context.Context, pgNotifyCha } go p.doSubscribe(ctx, req, handler, pgNotifyCmd, channel, subscribeID, stop) } - p.configLock.Unlock() return subscribeID, nil } diff --git a/configuration/postgres/postgres_test.go b/configuration/postgres/postgres_test.go index 8a5a18a17..22150a1a1 100644 --- a/configuration/postgres/postgres_test.go +++ b/configuration/postgres/postgres_test.go @@ -98,7 +98,7 @@ func TestConnectAndQuery(t *testing.T) { rows := mock.QueryRow(context.Background(), query) var id string err = rows.Scan(&id) - assert.Nil(t, err) + assert.Nil(t, err, "error in scan") err = mock.ExpectationsWereMet() - assert.Nil(t, err) + assert.Nil(t, err, "pgxmock error in expectations were met") } From 1243970b63d03c78c58f3543b7b7b5ba0f5f1d19 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Wed, 21 Sep 2022 21:26:40 +0530 Subject: [PATCH 31/39] fixed init comment Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index 16cfbf29c..775d92cb1 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -79,11 +79,6 @@ func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store { logger: logger, subscribeStopChanMap: make(map[string]interface{}), configLock: sync.Mutex{}, - metadata: metadata{ - maxIdleTimeout: 0, - connectionString: "", - configTable: "", - }, } } From 5a06d2d980a533f499d8aed893254e3fc3229c29 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Thu, 22 Sep 2022 15:04:50 +0530 Subject: [PATCH 32/39] fixed review comments Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 13 ++++--------- configuration/postgres/postgres_test.go | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index 775d92cb1..410f8a153 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -303,7 +303,7 @@ func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { m.maxIdleTimeout = t } } - if m.maxIdleTimeout == 0 { + if m.maxIdleTimeout <= 0 { m.maxIdleTimeout = defaultMaxConnIdleTime } return m, nil @@ -375,18 +375,13 @@ func (p *ConfigurationStore) isSubscriptionActive(req *configuration.SubscribeRe } func (p *ConfigurationStore) isSubscribed(subscriptionID string, channel string, key string) bool { - if val, yes := p.ActiveSubscriptions[channel]; yes { - if val.uuid == subscriptionID && slices.Contains(val.keys, key) { - return true - } + if val, yes := p.ActiveSubscriptions[channel]; yes && val.uuid == subscriptionID && slices.Contains(val.keys, key) { + return true } return false } func validateInput(keys []string) error { - if len(keys) == 0 { - return nil - } for _, key := range keys { if !allowedChars.MatchString(key) { return fmt.Errorf("invalid key : '%v'", key) @@ -398,7 +393,7 @@ func validateInput(keys []string) error { func (p *ConfigurationStore) subscribeToChannel(ctx context.Context, pgNotifyChanList []string, req *configuration.SubscribeRequest, handler configuration.UpdateHandler) (string, error) { p.configLock.Lock() defer p.configLock.Unlock() - var subscribeID string // TO_DO - duplicate trigger + var subscribeID string for _, channel := range pgNotifyChanList { pgNotifyCmd := fmt.Sprintf(listenTemplate, channel) if sub, isActive := p.isSubscriptionActive(req); isActive { diff --git a/configuration/postgres/postgres_test.go b/configuration/postgres/postgres_test.go index 22150a1a1..e6f9e4f33 100644 --- a/configuration/postgres/postgres_test.go +++ b/configuration/postgres/postgres_test.go @@ -43,6 +43,7 @@ func TestSelectAllQuery(t *testing.T) { if err != nil { t.Errorf("Error building query: %v ", err) } + assert.Nil(t, err, "Error building query: %v ", err) assert.Equal(t, expected, query, "did not get expected result. Got: '%v' , Expected: '%v'", query, expected) } @@ -56,9 +57,7 @@ func TestPostgresbuildQuery(t *testing.T) { query, params, err := buildQuery(g, "cfgtbl") _ = params - if err != nil { - t.Errorf("Error building query: %v ", err) - } + assert.Nil(t, err, "Error building query: %v ", err) expected := "SELECT * FROM cfgtbl WHERE KEY IN ($1) AND $2 = $3" assert.Equal(t, expected, query, "did not get expected result. Got: '%v' , Expected: '%v'", query, expected) i := 0 @@ -102,3 +101,14 @@ func TestConnectAndQuery(t *testing.T) { err = mock.ExpectationsWereMet() assert.Nil(t, err, "pgxmock error in expectations were met") } + +func TestValidateInput(t *testing.T) { + keys := []string{"testKey1", "testKey2"} + assert.Nil(t, validateInput(keys), "incorrect input provided: %v", keys) + + var keys2 []string + assert.Nil(t, validateInput(keys), "incorrect input provided: %v", keys2) + + keys3 := []string{"Name 1=1"} + assert.Error(t, validateInput(keys3), "invalid key : 'Name 1=1'") +} From 925e8f32a0e0acb7e50f114d9b67e0a417e058ad Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Thu, 22 Sep 2022 20:17:41 +0530 Subject: [PATCH 33/39] updated timeout Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index 410f8a153..bb0f795b8 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -94,9 +94,10 @@ func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { p.metadata = m } p.ActiveSubscriptions = make(map[string]*subscription) - ctx, cancel := context.WithTimeout(context.Background(), p.metadata.maxIdleTimeout) + ctx, cancel := context.WithTimeout(context.Background(), defaultMaxConnIdleTime) defer cancel() - client, err := Connect(ctx, p.metadata.connectionString, p.metadata.maxIdleTimeout) + // ctx := context.Background() + client, err := Connect(ctx, p.metadata.connectionString) if err != nil { return fmt.Errorf("error connecting to configuration store: '%s'", err) } @@ -309,7 +310,7 @@ func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { return m, nil } -func Connect(ctx context.Context, conn string, maxTimeout time.Duration) (*pgxpool.Pool, error) { +func Connect(ctx context.Context, conn string) (*pgxpool.Pool, error) { config, err := pgxpool.ParseConfig(conn) if err != nil { return nil, fmt.Errorf("postgres configuration store connection error : %s", err) From d569c1776da7b57252fcb1ca550c2d4029d16904 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Fri, 23 Sep 2022 14:16:46 +0530 Subject: [PATCH 34/39] fixed wrapping error from %s to %w Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 36 ++++++++++++++---------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index bb0f795b8..bb6f3e5b0 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -70,7 +70,7 @@ const ( var ( allowedChars = regexp.MustCompile(`^[a-zA-Z0-9./_]*$`) - defaultMaxConnIdleTime = time.Minute * 30 + defaultMaxConnIdleTime = time.Second * 30 ) func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store { @@ -78,7 +78,6 @@ func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store { return &ConfigurationStore{ logger: logger, subscribeStopChanMap: make(map[string]interface{}), - configLock: sync.Mutex{}, } } @@ -94,17 +93,16 @@ func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { p.metadata = m } p.ActiveSubscriptions = make(map[string]*subscription) - ctx, cancel := context.WithTimeout(context.Background(), defaultMaxConnIdleTime) + ctx, cancel := context.WithTimeout(context.Background(), p.metadata.maxIdleTimeout) defer cancel() - // ctx := context.Background() - client, err := Connect(ctx, p.metadata.connectionString) + client, err := Connect(ctx, p.metadata.connectionString, p.metadata.maxIdleTimeout) if err != nil { - return fmt.Errorf("error connecting to configuration store: '%s'", err) + return fmt.Errorf("error connecting to configuration store: '%w'", err) } p.client = client pingErr := p.client.Ping(ctx) if pingErr != nil { - return fmt.Errorf("unable to connect to configuration store: '%s'", pingErr) + return fmt.Errorf("unable to connect to configuration store: '%w'", pingErr) } // check if table exists exists := false @@ -126,7 +124,7 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ query, params, err := buildQuery(req, p.metadata.configTable) if err != nil { p.logger.Error(err) - return nil, fmt.Errorf("error in configuration store query: '%s' ", err) + return nil, fmt.Errorf("error in configuration store query: '%w' ", err) } rows, err := p.client.Query(ctx, query, params...) if err != nil { @@ -134,7 +132,7 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ if err == sql.ErrNoRows { return &configuration.GetResponse{}, nil } - return nil, fmt.Errorf("error in querying configuration store: '%s'", err) + return nil, fmt.Errorf("error in querying configuration store: '%w'", err) } items := make(map[string]*configuration.Item) for i := 0; rows.Next(); i++ { @@ -143,10 +141,10 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ var metadata []byte v := make(map[string]string) if err := rows.Scan(&key, &item.Value, &item.Version, &metadata); err != nil { - return nil, fmt.Errorf("error in reading data from configuration store: '%s'", err) + return nil, fmt.Errorf("error in reading data from configuration store: '%w'", err) } if err := json.Unmarshal(metadata, &v); err != nil { - return nil, fmt.Errorf("error in unmarshalling response from configuration store: '%s'", err) + return nil, fmt.Errorf("error in unmarshalling response from configuration store: '%w'", err) } item.Metadata = v if item.Value != "" { @@ -183,13 +181,13 @@ func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration conn, err := p.client.Acquire(ctx) if err != nil { p.logger.Errorf("error acquiring connection:", err) - return fmt.Errorf("error acquiring connection: %s ", err) + return fmt.Errorf("error acquiring connection: %w ", err) } defer conn.Release() _, err = conn.Exec(ctx, pgChannel) if err != nil { p.logger.Errorf("error listening to channel:", err) - return fmt.Errorf("error listening to channel: %s", err) + return fmt.Errorf("error listening to channel: %w", err) } delete(p.ActiveSubscriptions, k) return nil @@ -226,7 +224,7 @@ func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler configuration.UpdateHandler, msg *pgconn.Notification, channel string, subscriptionID string) { defer func() { if err := recover(); err != nil { - p.logger.Errorf("panic in handlesubscribedchange method and recovered: %s", err) + p.logger.Errorf("panic in handlesubscribedchange method and recovered: %w", err) } }() payload := make(map[string]interface{}) @@ -273,7 +271,7 @@ func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler } err = handler(ctx, e) if err != nil { - p.logger.Errorf("fail to call handler to notify event for configuration update subscribe: %s", err) + p.logger.Errorf("fail to call handler to notify event for configuration update subscribe: %w", err) } } else { p.logger.Info("unknown format of data received in notify event - '%s'", msg.Payload) @@ -310,18 +308,18 @@ func parseMetadata(cmetadata configuration.Metadata) (metadata, error) { return m, nil } -func Connect(ctx context.Context, conn string) (*pgxpool.Pool, error) { +func Connect(ctx context.Context, conn string, maxTimeout time.Duration) (*pgxpool.Pool, error) { config, err := pgxpool.ParseConfig(conn) if err != nil { - return nil, fmt.Errorf("postgres configuration store connection error : %s", err) + return nil, fmt.Errorf("postgres configuration store connection error : %w", err) } pool, err := pgxpool.NewWithConfig(ctx, config) if err != nil { - return nil, fmt.Errorf("postgres configuration store connection error : %s", err) + return nil, fmt.Errorf("postgres configuration store connection error : %w", err) } pingErr := pool.Ping(ctx) if pingErr != nil { - return nil, fmt.Errorf("postgres configuration store ping error : %s", pingErr) + return nil, fmt.Errorf("postgres configuration store ping error : %w", pingErr) } return pool, nil } From d013c7505ef1bcf79fe4e387fa3133a599c60a94 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Fri, 23 Sep 2022 17:30:09 +0530 Subject: [PATCH 35/39] changed row iteration to use generic method from pgxv5 Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 61 ++++++++++++++++-------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index bb6f3e5b0..363f0446e 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -27,6 +27,7 @@ import ( "time" "github.com/google/uuid" + "github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5/pgconn" "github.com/jackc/pgx/v5/pgxpool" "k8s.io/utils/strings/slices" @@ -40,7 +41,7 @@ type ConfigurationStore struct { client *pgxpool.Pool logger logger.Logger configLock sync.Mutex - subscribeStopChanMap map[string]interface{} + subscribeStopChanMap map[string]chan struct{} ActiveSubscriptions map[string]*subscription } @@ -49,6 +50,11 @@ type subscription struct { keys []string } +type pgResponse struct { + key string + item *configuration.Item +} + const ( configtablekey = "table" connMaxIdleTimeKey = "connMaxIdleTime" @@ -77,7 +83,7 @@ func NewPostgresConfigurationStore(logger logger.Logger) configuration.Store { logger.Debug("Instantiating PostgreSQL configuration store") return &ConfigurationStore{ logger: logger, - subscribeStopChanMap: make(map[string]interface{}), + subscribeStopChanMap: make(map[string]chan struct{}), } } @@ -100,9 +106,9 @@ func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { return fmt.Errorf("error connecting to configuration store: '%w'", err) } p.client = client - pingErr := p.client.Ping(ctx) - if pingErr != nil { - return fmt.Errorf("unable to connect to configuration store: '%w'", pingErr) + err = p.client.Ping(ctx) + if err != nil { + return fmt.Errorf("unable to connect to configuration store: '%w'", err) } // check if table exists exists := false @@ -111,7 +117,7 @@ func (p *ConfigurationStore) Init(metadata configuration.Metadata) error { if err == sql.ErrNoRows { return fmt.Errorf(ErrorMissingTable, p.metadata.configTable) } - return fmt.Errorf("error in checking if configtable exists - '%v'", p.metadata.configTable) + return fmt.Errorf("error in checking if configtable '%s' exists - '%w'", p.metadata.configTable, err) } return nil } @@ -134,25 +140,24 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ } return nil, fmt.Errorf("error in querying configuration store: '%w'", err) } - items := make(map[string]*configuration.Item) - for i := 0; rows.Next(); i++ { - var item configuration.Item - var key string - var metadata []byte - v := make(map[string]string) - if err := rows.Scan(&key, &item.Value, &item.Version, &metadata); err != nil { - return nil, fmt.Errorf("error in reading data from configuration store: '%w'", err) + items, err := pgx.CollectRows(rows, func(row pgx.CollectableRow) (pgResponse, error) { + a := pgResponse{ + item: new(configuration.Item), } - if err := json.Unmarshal(metadata, &v); err != nil { - return nil, fmt.Errorf("error in unmarshalling response from configuration store: '%w'", err) - } - item.Metadata = v - if item.Value != "" { - items[key] = &item + if err := row.Scan(&a.key, &a.item.Value, &a.item.Version, &a.item.Metadata); err != nil { + return pgResponse{}, fmt.Errorf("error in reading data from configuration store: '%w'", err) } + return a, nil + }) + if err != nil { + return nil, fmt.Errorf("unable to parse response from configuration store - %w", err) + } + result := make(map[string]*configuration.Item) + for _, v := range items { + result[v.key] = v.item } return &configuration.GetResponse{ - Items: items, + Items: result, }, nil } @@ -176,7 +181,7 @@ func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration if v.uuid == req.ID { if oldStopChan, ok := p.subscribeStopChanMap[req.ID]; ok { delete(p.subscribeStopChanMap, req.ID) - close(oldStopChan.(chan struct{})) + close(oldStopChan) pgChannel := fmt.Sprintf(unlistenTemplate, k) conn, err := p.client.Acquire(ctx) if err != nil { @@ -186,7 +191,7 @@ func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration defer conn.Release() _, err = conn.Exec(ctx, pgChannel) if err != nil { - p.logger.Errorf("error listening to channel:", err) + p.logger.Errorf("error un-listening to channel:", err) return fmt.Errorf("error listening to channel: %w", err) } delete(p.ActiveSubscriptions, k) @@ -212,7 +217,7 @@ func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration for { notification, err := conn.Conn().WaitForNotification(ctx) if err != nil { - if !pgconn.Timeout(err) && !errors.Is(ctx.Err(), context.Canceled) { + if !pgconn.Timeout(err) && !errors.Is(err, context.Canceled) { p.logger.Errorf("error waiting for notification:", err) } return @@ -317,9 +322,9 @@ func Connect(ctx context.Context, conn string, maxTimeout time.Duration) (*pgxpo if err != nil { return nil, fmt.Errorf("postgres configuration store connection error : %w", err) } - pingErr := pool.Ping(ctx) - if pingErr != nil { - return nil, fmt.Errorf("postgres configuration store ping error : %w", pingErr) + err = pool.Ping(ctx) + if err != nil { + return nil, fmt.Errorf("postgres configuration store ping error : %w", err) } return pool, nil } @@ -397,7 +402,7 @@ func (p *ConfigurationStore) subscribeToChannel(ctx context.Context, pgNotifyCha pgNotifyCmd := fmt.Sprintf(listenTemplate, channel) if sub, isActive := p.isSubscriptionActive(req); isActive { if oldStopChan, ok := p.subscribeStopChanMap[sub]; ok { - close(oldStopChan.(chan struct{})) + close(oldStopChan) delete(p.subscribeStopChanMap, sub) delete(p.ActiveSubscriptions, channel) } From fd0d789fe72c6b0aca632926ae3cd0bd61bc471e Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Fri, 23 Sep 2022 23:00:27 +0530 Subject: [PATCH 36/39] Review comments Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index 363f0446e..93a0f9162 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -192,7 +192,7 @@ func (p *ConfigurationStore) Unsubscribe(ctx context.Context, req *configuration _, err = conn.Exec(ctx, pgChannel) if err != nil { p.logger.Errorf("error un-listening to channel:", err) - return fmt.Errorf("error listening to channel: %w", err) + return fmt.Errorf("error un-listening to channel: %w", err) } delete(p.ActiveSubscriptions, k) return nil @@ -227,11 +227,6 @@ func (p *ConfigurationStore) doSubscribe(ctx context.Context, req *configuration } func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler configuration.UpdateHandler, msg *pgconn.Notification, channel string, subscriptionID string) { - defer func() { - if err := recover(); err != nil { - p.logger.Errorf("panic in handlesubscribedchange method and recovered: %w", err) - } - }() payload := make(map[string]interface{}) err := json.Unmarshal([]byte(msg.Payload), &payload) if err != nil { @@ -276,7 +271,7 @@ func (p *ConfigurationStore) handleSubscribedChange(ctx context.Context, handler } err = handler(ctx, e) if err != nil { - p.logger.Errorf("fail to call handler to notify event for configuration update subscribe: %w", err) + p.logger.Errorf("failed to call notify event handler : %w", err) } } else { p.logger.Info("unknown format of data received in notify event - '%s'", msg.Payload) From 5e58fa4efec0c652e39af63d33d70035e8075827 Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Fri, 23 Sep 2022 23:20:11 +0530 Subject: [PATCH 37/39] change to uuid.NewRandom to avoid panic Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index 93a0f9162..66d010616 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -403,7 +403,11 @@ func (p *ConfigurationStore) subscribeToChannel(ctx context.Context, pgNotifyCha } } stop := make(chan struct{}) - subscribeID = uuid.New().String() + subscribeUID, err := uuid.NewRandom() + if err != nil { + return "", fmt.Errorf("unable to generate subscription id - %w", err) + } + subscribeID = subscribeUID.String() p.subscribeStopChanMap[subscribeID] = stop p.ActiveSubscriptions[channel] = &subscription{ uuid: subscribeID, From 65e2dbc363f30b402bfa72d84bcf08325c118493 Mon Sep 17 00:00:00 2001 From: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> Date: Fri, 23 Sep 2022 18:28:38 +0000 Subject: [PATCH 38/39] =?UTF-8?q?=F0=9F=92=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> --- configuration/postgres/postgres.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index 66d010616..4fc410a62 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -141,13 +141,13 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ return nil, fmt.Errorf("error in querying configuration store: '%w'", err) } items, err := pgx.CollectRows(rows, func(row pgx.CollectableRow) (pgResponse, error) { - a := pgResponse{ + res := pgResponse{ item: new(configuration.Item), } - if err := row.Scan(&a.key, &a.item.Value, &a.item.Version, &a.item.Metadata); err != nil { - return pgResponse{}, fmt.Errorf("error in reading data from configuration store: '%w'", err) + if innerErr := row.Scan(&res.key, &res.item.Value, &res.item.Version, &res.item.Metadata); innerErr != nil { + return pgResponse{}, fmt.Errorf("error in reading data from configuration store: '%w'", innerErr) } - return a, nil + return res, nil }) if err != nil { return nil, fmt.Errorf("unable to parse response from configuration store - %w", err) From 43f3465f9b8ba48c3f07719afc8d238a6d26489a Mon Sep 17 00:00:00 2001 From: akhilac1 Date: Sat, 24 Sep 2022 00:06:59 +0530 Subject: [PATCH 39/39] fixed linter error Signed-off-by: akhilac1 --- configuration/postgres/postgres.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration/postgres/postgres.go b/configuration/postgres/postgres.go index 66d010616..dabd2aba5 100644 --- a/configuration/postgres/postgres.go +++ b/configuration/postgres/postgres.go @@ -144,7 +144,7 @@ func (p *ConfigurationStore) Get(ctx context.Context, req *configuration.GetRequ a := pgResponse{ item: new(configuration.Item), } - if err := row.Scan(&a.key, &a.item.Value, &a.item.Version, &a.item.Metadata); err != nil { + if err = row.Scan(&a.key, &a.item.Value, &a.item.Version, &a.item.Metadata); err != nil { return pgResponse{}, fmt.Errorf("error in reading data from configuration store: '%w'", err) } return a, nil