From 7ccab48a3ca9b0d8212321deb60e6876ed30642c Mon Sep 17 00:00:00 2001 From: Michael Gaffney Date: Mon, 11 Oct 2021 16:00:32 -0400 Subject: [PATCH 1/5] style: Run `make fmt` --- internal/auth/password/repository_password.go | 1 - internal/db/db.go | 4 +++- internal/db/schema/edition.go | 2 +- internal/db/schema/internal/provider/provider_test.go | 1 - internal/oplog/oplog_test.go | 3 ++- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/auth/password/repository_password.go b/internal/auth/password/repository_password.go index 1ebbc18a4..f335afec6 100644 --- a/internal/auth/password/repository_password.go +++ b/internal/auth/password/repository_password.go @@ -215,7 +215,6 @@ func (r *Repository) authenticate(ctx context.Context, scopeId, authMethodId, lo var accts []authAccount rows, err := r.reader.Query(ctx, authenticateQuery, []interface{}{sql.Named("auth_method_id", authMethodId), sql.Named("login_name", loginName)}) - if err != nil { return nil, errors.Wrap(ctx, err, op) } diff --git a/internal/db/db.go b/internal/db/db.go index 2f5ff3d6d..e9aeaeba1 100644 --- a/internal/db/db.go +++ b/internal/db/db.go @@ -29,6 +29,7 @@ func (db DbType) String() string { "postgres", }[db] } + func StringToDbType(dialect string) (DbType, error) { switch dialect { case "postgres": @@ -80,7 +81,8 @@ func Open(dbType DbType, connectionUrl string, opt ...Option) (*DB, error) { switch dbType { case Postgres: dialect = postgres.New(postgres.Config{ - DSN: connectionUrl}, + DSN: connectionUrl, + }, ) default: return nil, fmt.Errorf("unable to open %s database type", dbType) diff --git a/internal/db/schema/edition.go b/internal/db/schema/edition.go index 1aa0899ef..9b17ad722 100644 --- a/internal/db/schema/edition.go +++ b/internal/db/schema/edition.go @@ -17,7 +17,7 @@ const ( ) var supportedDialects = map[Dialect]struct{}{ - Postgres: struct{}{}, + Postgres: {}, } // type dialects map[Dialect]edition.Editions diff --git a/internal/db/schema/internal/provider/provider_test.go b/internal/db/schema/internal/provider/provider_test.go index a55b02a67..cd4ad1c52 100644 --- a/internal/db/schema/internal/provider/provider_test.go +++ b/internal/db/schema/internal/provider/provider_test.go @@ -155,5 +155,4 @@ func TestProvider(t *testing.T) { assert.Nil(t, p.Statements(), tt.name) }) } - } diff --git a/internal/oplog/oplog_test.go b/internal/oplog/oplog_test.go index c7fc4c8a1..8a87d5eee 100644 --- a/internal/oplog/oplog_test.go +++ b/internal/oplog/oplog_test.go @@ -41,7 +41,8 @@ func testOpen(dbType string, connectionUrl string) (*gorm.DB, error) { switch dbType { case "postgres": dialect = postgres.New(postgres.Config{ - DSN: connectionUrl}, + DSN: connectionUrl, + }, ) default: return nil, fmt.Errorf("unable to open %s database type", dbType) From 3b99ded7ad3b849059b7daad6dd3f5d51d9f9792 Mon Sep 17 00:00:00 2001 From: Jim Date: Wed, 13 Oct 2021 11:10:11 -0400 Subject: [PATCH 2/5] refactor: Update gorm deps (#1591) Our recent upstream PR was merged into gorm. We needed to change just a few bits to migrate our gorm dep back to the upstream source. --- go.mod | 6 +----- go.sum | 5 +++-- internal/db/README.md | 4 +--- internal/db/db.go | 4 +--- internal/oplog/oplog_test.go | 4 +--- 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index b3aa79c1b..72fe9c2ed 100644 --- a/go.mod +++ b/go.mod @@ -6,10 +6,6 @@ replace github.com/hashicorp/boundary/api => ./api replace github.com/hashicorp/boundary/sdk => ./sdk -// tmp use of local clone as we understand any required upstream PRs to -// compatibility. -replace gorm.io/gorm => github.com/hashicorp/gorm v0.0.2 - require ( github.com/armon/go-metrics v0.3.9 github.com/bufbuild/buf v0.37.0 @@ -83,7 +79,7 @@ require ( google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 google.golang.org/protobuf v1.27.1 gorm.io/driver/postgres v1.1.0 - gorm.io/gorm v1.21.14 + gorm.io/gorm v1.21.17-0.20211013130203-9a5ba3760424 mvdan.cc/gofumpt v0.1.1 nhooyr.io/websocket v1.8.7 ) diff --git a/go.sum b/go.sum index f6431760e..632cd926c 100644 --- a/go.sum +++ b/go.sum @@ -538,8 +538,6 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.3 h1:YPkqC67at8FYaadspW/6uE0COsBxS2656RLEr8Bppgk= github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/hashicorp/gorm v0.0.2 h1:yxEp0og8mswtQVSEnxEsU+d3QIvYDqU+P5ABAm0B9n4= -github.com/hashicorp/gorm v0.0.2/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= @@ -1518,6 +1516,9 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gorm.io/driver/postgres v1.1.0 h1:afBljg7PtJ5lA6YUWluV2+xovIPhS+YiInuL3kUjrbk= gorm.io/driver/postgres v1.1.0/go.mod h1:hXQIwafeRjJvUm+OMxcFWyswJ/vevcpPLlGocwAwuqw= +gorm.io/gorm v1.21.9/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0= +gorm.io/gorm v1.21.17-0.20211013130203-9a5ba3760424 h1:BIsspdRVnFmC32WxhF+4rvNu/mU/rbX9yK9a8vtJSqs= +gorm.io/gorm v1.21.17-0.20211013130203-9a5ba3760424/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= gotest.tools/v3 v3.0.2 h1:kG1BFyqVHuQoVQiR1bWGnfz/fmHvvuiSPIV7rvl360E= diff --git a/internal/db/README.md b/internal/db/README.md index 120bcc162..115a72324 100644 --- a/internal/db/README.md +++ b/internal/db/README.md @@ -7,9 +7,7 @@ Just some high-level usage highlights to get you started. Read the godocs for a dialect = postgres.New(postgres.Config{ DSN: connectionUrl}, ) - conn, _ := gorm.Open(dialect, &gorm.Config{ - ConvertNullToZeroValues: true, - }) + conn, _ := gorm.Open(dialect, &gorm.Config{}) // Db implements both the Reader and Writer interfaces rw := Db{Tx: conn} diff --git a/internal/db/db.go b/internal/db/db.go index e9aeaeba1..9586cd566 100644 --- a/internal/db/db.go +++ b/internal/db/db.go @@ -87,9 +87,7 @@ func Open(dbType DbType, connectionUrl string, opt ...Option) (*DB, error) { default: return nil, fmt.Errorf("unable to open %s database type", dbType) } - db, err := gorm.Open(dialect, &gorm.Config{ - ConvertNullToZeroValues: true, - }) + db, err := gorm.Open(dialect, &gorm.Config{}) if err != nil { return nil, fmt.Errorf("unable to open database: %w", err) } diff --git a/internal/oplog/oplog_test.go b/internal/oplog/oplog_test.go index 8a87d5eee..a022ccbf7 100644 --- a/internal/oplog/oplog_test.go +++ b/internal/oplog/oplog_test.go @@ -47,9 +47,7 @@ func testOpen(dbType string, connectionUrl string) (*gorm.DB, error) { default: return nil, fmt.Errorf("unable to open %s database type", dbType) } - db, err := gorm.Open(dialect, &gorm.Config{ - ConvertNullToZeroValues: true, - }) + db, err := gorm.Open(dialect, &gorm.Config{}) if err != nil { return nil, fmt.Errorf("unable to open database: %w", err) } From 204ff254ca94044a026801fe95006447355a1cb9 Mon Sep 17 00:00:00 2001 From: Robin Beck Date: Wed, 13 Oct 2021 13:57:31 -0600 Subject: [PATCH 3/5] fixed hcl config examples for sink (#1590) * fixed hcl config examples for sink * fixed observations_enabled parameter typo --- .../docs/configuration/events/file.mdx | 3 +-- .../docs/configuration/events/overview.mdx | 20 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/website/content/docs/configuration/events/file.mdx b/website/content/docs/configuration/events/file.mdx index cc36edada..bc98443a4 100644 --- a/website/content/docs/configuration/events/file.mdx +++ b/website/content/docs/configuration/events/file.mdx @@ -10,7 +10,7 @@ description: |- The file sink configures Boundary to send events to a file. ```hcl -sink = { +sink { name = "obs-sink" description = "Observations sent to a file" event_types = ["observation"] @@ -25,7 +25,6 @@ The `sink` stanza may be specified more than once to make Boundary send events to multiple sinks; however, each file sink must have a unique `path` + `file_name`. - ## common parameters These parameters are shared across all sink types: [common sink parameters](/docs/configuration/events/common) diff --git a/website/content/docs/configuration/events/overview.mdx b/website/content/docs/configuration/events/overview.mdx index be5cb173b..750cb44cb 100644 --- a/website/content/docs/configuration/events/overview.mdx +++ b/website/content/docs/configuration/events/overview.mdx @@ -7,7 +7,7 @@ description: |- # `events` Stanza -The `events` stanza configures Boundary events-specific parameters. +The `events` stanza configures Boundary events-specific parameters. Example: @@ -15,13 +15,13 @@ Example: events { observations_enabled = true sysevents_enabled = true - sink "stderr" = { + sink "stderr" { name = "all-events" description = "All events sent to stderr" event_types = ["*"] format = "hclog-text" } - sink = { + sink { name = "obs-sink" description = "Observations sent to a file" event_types = ["observation"] @@ -34,25 +34,27 @@ events { ``` - `audit_enabled` - Specifies if audit events should be emitted. -Note: audit events are a WIP and will only be emitted if they are both enabled and the env var `BOUNDARY_DEVELOPER_ENABLE_EVENTS` equals true. We anticipate many changes for audit events before they are generally available including what data is included and different options for redacting/encrypting that data. + Note: audit events are a WIP and will only be emitted if they are both enabled and the env var `BOUNDARY_DEVELOPER_ENABLE_EVENTS` equals true. We anticipate many changes for audit events before they are generally available including what data is included and different options for redacting/encrypting that data. -- `observation_enabled` - Specifies if observation events should be emitted. +- `observations_enabled` - Specifies if observation events should be emitted. -- `sysevents_enabled` - Specifies if system events should be emitted. +- `sysevents_enabled` - Specifies if system events should be emitted. - `sink` - Specifies the configuration of an event sink. Currently, two types of sink are supported: [file](/docs/configuration/events/file) and [stderr](/docs/configuration/events/stderr). If no sinks are configured then all events will be sent to a default [stderr](/docs/configuration/events/stderr) sink. Events may be sent to multiple - sinks. + sinks. + +## Default Events Stanza -## Default Events Stanza If no event stanza is specified then the following default is used: + ```hcl events { audit_enabled = false observations_enabled = true sysevents_enabled = true - sink "stderr" = { + sink "stderr" { name = "default" event_types = ["*"] format = "cloudevents-json" From 3af3ceec3a6e1024c18ae976973d13ae298aa87c Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Wed, 13 Oct 2021 17:46:02 -0400 Subject: [PATCH 4/5] Bump Go to 1.17.2 (#1596) --- ci/goinstall.sh | 2 +- packages-oss.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/goinstall.sh b/ci/goinstall.sh index 41fe00c30..eae37af09 100755 --- a/ci/goinstall.sh +++ b/ci/goinstall.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -VERSION="1.17.1" +VERSION="1.17.2" [ -z "$GOROOT" ] && GOROOT="$HOME/.go" [ -z "$GOPATH" ] && GOPATH="$HOME/go" diff --git a/packages-oss.yml b/packages-oss.yml index 2d30eb6e0..eafa65656 100644 --- a/packages-oss.yml +++ b/packages-oss.yml @@ -50,8 +50,8 @@ package-aliases: template: >- boundary/{{.BUNDLE_NAME}}/{{.BUNDLE_NAME}}_{{.GOOS}}_{{.GOARCH}}.zip -# golang:1.17.1-buster -base-image: "docker.mirror.hashicorp.services/golang@sha256:2a0bd53951c1b1746c5adab10e1db1495cc6f2da0a3d21818466265e34a78597" +# golang:1.17.2-buster +base-image: "docker.mirror.hashicorp.services/golang@sha256:c301ce41458847a02caea52b5c2fd2a18b34f33785ddd676d38defe286bb946b" layers: - name: base From 08a0f32a6e20b94bae4ccfaafa52d38a5ba364a9 Mon Sep 17 00:00:00 2001 From: Noel Quiles <3746694+EnMod@users.noreply.github.com> Date: Wed, 13 Oct 2021 18:03:23 -0400 Subject: [PATCH 5/5] website: Add Fathom analytics (#1579) * Impl Fathom analytics * Use analytics package instead of direct impl --- website/package-lock.json | 57 +++++++++++++++++++++++++++++++-------- website/package.json | 2 ++ website/pages/_app.js | 3 +++ 3 files changed, 51 insertions(+), 11 deletions(-) diff --git a/website/package-lock.json b/website/package-lock.json index aa8d23459..a085e664e 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -1614,6 +1614,14 @@ "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz", "integrity": "sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA==" }, + "@hashicorp/platform-analytics": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@hashicorp/platform-analytics/-/platform-analytics-0.1.0.tgz", + "integrity": "sha512-kR/E0KWemjazSrSFN9l22v8JqlQvkgjgkZHPJEhGiBt05LMtt2ugxIakv+gnzW5lU9434nnr7oDooUyj4eufPA==", + "requires": { + "fathom-client": "^3.2.0" + } + }, "node_modules/@hashicorp/react-text-input/node_modules/uuid": { "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", @@ -2295,9 +2303,13 @@ "version": "11.1.2", "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-11.1.2.tgz", "integrity": "sha512-hZuwOlGOwBZADA8EyDYyjx3+4JGIGjSHDHWrmpI7g5rFmQNltjlbaefAbiU5Kk7j3BUSDwt30quJRFv3nyJQ0w==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "optional": true, - "os": ["darwin"], + "os": [ + "darwin" + ], "engines": { "node": ">= 10" } @@ -2306,9 +2318,13 @@ "version": "11.1.2", "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-11.1.2.tgz", "integrity": "sha512-PGOp0E1GisU+EJJlsmJVGE+aPYD0Uh7zqgsrpD3F/Y3766Ptfbe1lEPPWnRDl+OzSSrSrX1lkyM/Jlmh5OwNvA==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "optional": true, - "os": ["darwin"], + "os": [ + "darwin" + ], "engines": { "node": ">= 10" } @@ -2317,9 +2333,13 @@ "version": "11.1.2", "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-11.1.2.tgz", "integrity": "sha512-YcDHTJjn/8RqvyJVB6pvEKXihDcdrOwga3GfMv/QtVeLphTouY4BIcEUfrG5+26Nf37MP1ywN3RRl1TxpurAsQ==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">= 10" } @@ -2328,9 +2348,13 @@ "version": "11.1.2", "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-11.1.2.tgz", "integrity": "sha512-e/pIKVdB+tGQYa1cW3sAeHm8gzEri/HYLZHT4WZojrUxgWXqx8pk7S7Xs47uBcFTqBDRvK3EcQpPLf3XdVsDdg==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "optional": true, - "os": ["win32"], + "os": [ + "win32" + ], "engines": { "node": ">= 10" } @@ -5640,7 +5664,9 @@ "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", "devOptional": true, - "engines": ["node >= 0.8"], + "engines": [ + "node >= 0.8" + ], "peer": true, "dependencies": { "buffer-from": "^1.0.0", @@ -7546,6 +7572,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "fathom-client": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fathom-client/-/fathom-client-3.2.0.tgz", + "integrity": "sha512-WF/qA5wXYSuA5K8uiIhGNbErOcTAmfLEWrBxWP2px2dEc9waH9zxjdh9k0F907VCBhdJrv+f7V3HT/Pmro40zA==" + }, "node_modules/eslint/node_modules/ignore": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", @@ -8740,7 +8771,9 @@ "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", "hasInstallScript": true, "optional": true, - "os": ["darwin"], + "os": [ + "darwin" + ], "engines": { "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } @@ -19443,7 +19476,9 @@ "dev": true, "hasInstallScript": true, "optional": true, - "os": ["darwin"], + "os": [ + "darwin" + ], "peer": true, "dependencies": { "bindings": "^1.5.0", diff --git a/website/package.json b/website/package.json index fe0a93357..58a842a6e 100644 --- a/website/package.json +++ b/website/package.json @@ -7,6 +7,7 @@ "@apidevtools/json-schema-ref-parser": "9.0.9", "@hashicorp/mktg-global-styles": "^4.0.0", "@hashicorp/mktg-logos": "^1.2.0", + "@hashicorp/platform-analytics": "^0.1.0", "@hashicorp/platform-code-highlighting": "^0.1.2", "@hashicorp/platform-runtime-error-monitoring": "^0.1.0", "@hashicorp/platform-util": "^0.1.0", @@ -32,6 +33,7 @@ "classnames": "2.2.6", "next": "^11.1.2", "next-mdx-remote": "^3.0.4", + "fathom-client": "^3.2.0", "next-remote-watch": "1.0.0", "react": "^17.0.2", "react-dom": "^17.0.2", diff --git a/website/pages/_app.js b/website/pages/_app.js index 7a3080ad8..a5ba752b7 100644 --- a/website/pages/_app.js +++ b/website/pages/_app.js @@ -1,5 +1,7 @@ import './style.css' import '@hashicorp/platform-util/nprogress/style.css' + +import useFathomAnalytics from '@hashicorp/platform-analytics' import NProgress from '@hashicorp/platform-util/nprogress' import createConsentManager from '@hashicorp/react-consent-manager/loader' import useAnchorLinkAnalytics from '@hashicorp/platform-util/anchor-link-analytics' @@ -23,6 +25,7 @@ const description = 'Boundary is an open source solution that automates a secure identity-based user access to hosts and services across environments.' export default function App({ Component, pageProps }) { + useFathomAnalytics() useAnchorLinkAnalytics() return (