From 098c3e1f22ca59bb903a9cb78f80d279d5179835 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Tue, 5 Oct 2021 16:28:39 -0400 Subject: [PATCH] Update sdk dep from proper branch and fix building --- go.mod | 3 +-- .../migrations/postgres/17/preferred_endpoints_test.go | 2 +- internal/host/plugin/host_catalog_secret.go | 9 +++++---- internal/host/plugin/query.go | 4 ++-- internal/host/plugin/testing.go | 5 ++--- internal/plugin/host/testing.go | 3 +-- internal/plugin/testing.go | 3 +-- 7 files changed, 13 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index 86e8fc1dd..5334d8889 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/hashicorp/boundary-plugin-host-aws v0.0.0-20210928175609-6345faccf578 github.com/hashicorp/boundary-plugin-host-azure v0.0.0-20210930043837-3542fae64d2e github.com/hashicorp/boundary/api v0.0.19 - github.com/hashicorp/boundary/sdk v0.0.11-0.20210928201932-8b1ca4b0b8b9 + github.com/hashicorp/boundary/sdk v0.0.12-0.20211005202728-158ab09952ba github.com/hashicorp/cap v0.1.1 github.com/hashicorp/dawdle v0.4.0 github.com/hashicorp/dbassert v0.0.0-20210708202608-ecf920cf1ed8 @@ -56,7 +56,6 @@ require ( github.com/jackc/pgconn v1.10.0 github.com/jackc/pgx/v4 v4.11.0 github.com/jefferai/keyring v1.1.7-0.20210105022822-8749b3d9ce79 - github.com/jinzhu/gorm v1.9.12 github.com/kr/pretty v0.3.0 github.com/kr/text v0.2.0 github.com/mattn/go-colorable v0.1.8 diff --git a/internal/db/schema/migrations/postgres/17/preferred_endpoints_test.go b/internal/db/schema/migrations/postgres/17/preferred_endpoints_test.go index fed33e577..dc143fc92 100644 --- a/internal/db/schema/migrations/postgres/17/preferred_endpoints_test.go +++ b/internal/db/schema/migrations/postgres/17/preferred_endpoints_test.go @@ -77,7 +77,7 @@ func Test_PreferredEndpointTable(t *testing.T) { condition: "dns:abcd", }, }, - wantErrContains: "priority must not be empty", + wantErrContains: "priority_must_be_greater_than_zero", }, { testName: "duplicate priority", diff --git a/internal/host/plugin/host_catalog_secret.go b/internal/host/plugin/host_catalog_secret.go index 83916ec02..7daf0abf3 100644 --- a/internal/host/plugin/host_catalog_secret.go +++ b/internal/host/plugin/host_catalog_secret.go @@ -2,6 +2,7 @@ package plugin import ( "context" + "database/sql" "github.com/hashicorp/boundary/internal/db" "github.com/hashicorp/boundary/internal/errors" @@ -92,9 +93,9 @@ func (c *HostCatalogSecret) decrypt(ctx context.Context, cipher wrapping.Wrapper func (c *HostCatalogSecret) insertQuery() (query string, queryValues []interface{}) { query = upsertHostCatalogSecretQuery queryValues = []interface{}{ - c.CatalogId, - c.CtSecret, - c.KeyId, + sql.Named("catalog_id", c.CatalogId), + sql.Named("secret", c.CtSecret), + sql.Named("key_id", c.KeyId), } return } @@ -102,7 +103,7 @@ func (c *HostCatalogSecret) insertQuery() (query string, queryValues []interface func (c *HostCatalogSecret) deleteQuery() (query string, queryValues []interface{}) { query = deleteHostCatalogSecretQuery queryValues = []interface{}{ - c.CatalogId, + sql.Named("catalog_id", c.CatalogId), } return } diff --git a/internal/host/plugin/query.go b/internal/host/plugin/query.go index bf3db9dfe..4ad81ad1a 100644 --- a/internal/host/plugin/query.go +++ b/internal/host/plugin/query.go @@ -5,7 +5,7 @@ const ( insert into host_plugin_catalog_secret (catalog_id, secret, key_id) values - ($1, $2, $3) + (@catalog_id, @secret, @key_id) on conflict (catalog_id) do update set secret = excluded.secret, key_id = excluded.key_id @@ -14,6 +14,6 @@ returning *; deleteHostCatalogSecretQuery = ` delete from host_plugin_catalog_secret - where catalog_id = $1; + where catalog_id = @catalog_id; ` ) diff --git a/internal/host/plugin/testing.go b/internal/host/plugin/testing.go index a52814fd1..b7f9a50ec 100644 --- a/internal/host/plugin/testing.go +++ b/internal/host/plugin/testing.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/boundary/internal/kms" "github.com/hashicorp/boundary/internal/plugin/host" plgpb "github.com/hashicorp/boundary/sdk/pbs/plugin" - "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -16,7 +15,7 @@ import ( // TestCatalog creates count number of plugin host catalogs to the provided DB // with the provided scope id. If any errors are encountered during the creation of // the host catalog, the test will fail. -func TestCatalog(t *testing.T, conn *gorm.DB, scopeId, pluginId string, opt ...Option) *HostCatalog { +func TestCatalog(t *testing.T, conn *db.DB, scopeId, pluginId string, opt ...Option) *HostCatalog { t.Helper() ctx := context.Background() w := db.New(conn) @@ -41,7 +40,7 @@ func TestCatalog(t *testing.T, conn *gorm.DB, scopeId, pluginId string, opt ...O // TestSet creates a plugin host sets in the provided DB // with the provided catalog id. The catalog must have been created // previously. The test will fail if any errors are encountered. -func TestSet(t *testing.T, conn *gorm.DB, kmsCache *kms.Kms, hc *HostCatalog, plgm map[string]plgpb.HostPluginServiceServer, opt ...Option) *HostSet { +func TestSet(t *testing.T, conn *db.DB, kmsCache *kms.Kms, hc *HostCatalog, plgm map[string]plgpb.HostPluginServiceServer, opt ...Option) *HostSet { t.Helper() require := require.New(t) ctx := context.Background() diff --git a/internal/plugin/host/testing.go b/internal/plugin/host/testing.go index 2bc6fa35d..e9a0e2b9e 100644 --- a/internal/plugin/host/testing.go +++ b/internal/plugin/host/testing.go @@ -5,11 +5,10 @@ import ( "testing" "github.com/hashicorp/boundary/internal/db" - "github.com/jinzhu/gorm" "github.com/stretchr/testify/require" ) -func TestPlugin(t *testing.T, conn *gorm.DB, name string) *Plugin { +func TestPlugin(t *testing.T, conn *db.DB, name string) *Plugin { t.Helper() p := NewPlugin(WithName(name)) id, err := newPluginId() diff --git a/internal/plugin/testing.go b/internal/plugin/testing.go index 01d5a3929..01b6efca5 100644 --- a/internal/plugin/testing.go +++ b/internal/plugin/testing.go @@ -7,7 +7,6 @@ import ( "github.com/hashicorp/boundary/internal/db" "github.com/hashicorp/boundary/internal/plugin/store" "github.com/hashicorp/boundary/internal/types/scope" - "github.com/jinzhu/gorm" "github.com/stretchr/testify/require" ) @@ -42,7 +41,7 @@ func (c *plugin) SetTableName(n string) { c.tableName = n } -func testPlugin(t *testing.T, conn *gorm.DB, name string) *plugin { +func testPlugin(t *testing.T, conn *db.DB, name string) *plugin { t.Helper() p := newPlugin(name) id, err := db.NewPublicId("plg")