Repository: google/exposure-notifications-server
Pull request #626 (2020-06-14 15:18:16)

Handle null output region
Fixes GH-623

google-oss-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/google/exposure-notifications-server/pull/626#" title="Author self-approved">sethvargo</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=google%2Fexposure-notifications-server).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/google/exposure-notifications-server/blob/master/OWNERS)~~ [sethvargo]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
google-oss-robot: @sethvargo: The following test **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
pull-en-server-release-unit | cf6f6d393fd823cfce0e425c0ba8fd7f41bee068 | [link](https://oss-prow.knative.dev/view/gcs/oss-prow/pr-logs/pull/google_exposure-notifications-server/626/pull-en-server-release-unit/1272186729121452032) | `/test pull-en-server-release-unit`

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
mikehelmick: /retest
google-oss-robot: @sethvargo: The following test **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
pull-en-server-release-unit | cf6f6d393fd823cfce0e425c0ba8fd7f41bee068 | [link](https://oss-prow.knative.dev/view/gcs/oss-prow/pr-logs/pull/google_exposure-notifications-server/626/pull-en-server-release-unit/1272188994016251905) | `/test pull-en-server-release-unit`

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
google-oss-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/google/exposure-notifications-server/pull/626#pullrequestreview-430796494" title="Approved">gurayAlsac</a>*, *<a href="https://github.com/google/exposure-notifications-server/pull/626#" title="Author self-approved">sethvargo</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=google%2Fexposure-notifications-server).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/google/exposure-notifications-server/blob/master/OWNERS)~~ [sethvargo]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
google-oss-robot: New changes are detected. LGTM label has been removed.
google-oss-robot: @sethvargo: The following test **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
pull-en-server-release-unit | 1754fa4193143d6f775b891b45649ea5edbc68bc | [link](https://oss-prow.knative.dev/view/gcs/oss-prow/pr-logs/pull/google_exposure-notifications-server/626/pull-en-server-release-unit/1272565978068160512) | `/test pull-en-server-release-unit`

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->

Patch:
diff --git a/docker/urlencode b/docker/urlencode
index 3468a4d..534b81a 100755
--- a/docker/urlencode
+++ b/docker/urlencode
@@ -16,7 +16,7 @@
 
 set -eEuo pipefail
 
-read IN
+IN="$(cat /dev/stdin)"
 LENGTH="${#IN}"
 for (( i = 0; i < $LENGTH; i++ )); do
   c="${IN:i:1}"
diff --git a/internal/authorizedapp/database_provider.go b/internal/authorizedapp/database_provider.go
index 752905d..35e36ea 100644
--- a/internal/authorizedapp/database_provider.go
+++ b/internal/authorizedapp/database_provider.go
@@ -23,8 +23,8 @@ import (
 
 	authorizedappdb "github.com/google/exposure-notifications-server/internal/authorizedapp/database"
 	"github.com/google/exposure-notifications-server/internal/authorizedapp/model"
-	"github.com/google/exposure-notifications-server/internal/cache"
 	"github.com/google/exposure-notifications-server/internal/database"
+	"github.com/google/exposure-notifications-server/pkg/cache"
 
 	"github.com/google/exposure-notifications-server/internal/logging"
 	"github.com/google/exposure-notifications-server/internal/secrets"
diff --git a/internal/database/database_util.go b/internal/database/database_util.go
index 5e9488f..64597a4 100644
--- a/internal/database/database_util.go
+++ b/internal/database/database_util.go
@@ -116,7 +116,6 @@ func NewTestDatabaseWithConfig(tb testing.TB) (*DB, *Config) {
 		var err error
 		dbpool, err = pgxpool.Connect(ctx, connURL.String())
 		if err != nil {
-			tb.Logf("retrying error: %v", err)
 			return retry.RetryableError(err)
 		}
 		return nil
diff --git a/internal/export/database/export.go b/internal/export/database/export.go
index e57a73f..07a30b0 100644
--- a/internal/export/database/export.go
+++ b/internal/export/database/export.go
@@ -17,6 +17,7 @@ package database
 
 import (
 	"context"
+	"database/sql"
 	"fmt"
 	"math/rand"
 	"time"
@@ -183,16 +184,23 @@ func (db *ExportDB) IterateExportConfigs(ctx context.Context, t time.Time, f fun
 func scanOneExportConfig(row pgx.Row) (*model.ExportConfig, error) {
 	var (
 		m             model.ExportConfig
+		outputRegion  sql.NullString
 		periodSeconds int
 		thru          *time.Time
 	)
-	if err := row.Scan(&m.ConfigID, &m.BucketName, &m.FilenameRoot, &periodSeconds, &m.OutputRegion, &m.From, &thru, &m.SignatureInfoIDs, &m.InputRegions); err != nil {
+	if err := row.Scan(&m.ConfigID, &m.BucketName, &m.FilenameRoot, &periodSeconds, &outputRegion, &m.From, &thru, &m.SignatureInfoIDs, &m.InputRegions); err != nil {
 		return nil, err
 	}
+
 	m.Period = time.Duration(periodSeconds) * time.Second
 	if thru != nil {
 		m.Thru = *thru
 	}
+
+	if outputRegion.Valid {
+		m.OutputRegion = outputRegion.String
+	}
+
 	return &m, nil
 }
 
diff --git a/internal/publish/database/exposure.go b/internal/publish/database/exposure.go
index 9fb48f7..f3a54b4 100644
--- a/internal/publish/database/exposure.go
+++ b/internal/publish/database/exposure.go
@@ -23,10 +23,10 @@ import (
 	"strings"
 	"time"
 
-	"github.com/google/exposure-notifications-server/internal/base64util"
 	"github.com/google/exposure-notifications-server/internal/database"
 	"github.com/google/exposure-notifications-server/internal/logging"
 	"github.com/google/exposure-notifications-server/internal/publish/model"
+	"github.com/google/exposure-notifications-server/pkg/base64util"
 
 	pgx "github.com/jackc/pgx/v4"
 )
diff --git a/internal/publish/model/exposure_model.go b/internal/publish/model/exposure_model.go
index 735462b..06240b4 100644
--- a/internal/publish/model/exposure_model.go
+++ b/internal/publish/model/exposure_model.go
@@ -22,8 +22,8 @@ import (
 	"strings"
 	"time"
 
-	"github.com/google/exposure-notifications-server/internal/base64util"
 	"github.com/google/exposure-notifications-server/internal/logging"
+	"github.com/google/exposure-notifications-server/pkg/base64util"
 
 	verifyapi "github.com/google/exposure-notifications-server/pkg/api/v1alpha1"
 )
diff --git a/internal/secrets/cacher.go b/internal/secrets/cacher.go
index 1c08ed9..f42a37c 100644
--- a/internal/secrets/cacher.go
+++ b/internal/secrets/cacher.go
@@ -19,7 +19,7 @@ import (
 	"fmt"
 	"time"
 
-	"github.com/google/exposure-notifications-server/internal/cache"
+	"github.com/google/exposure-notifications-server/pkg/cache"
 )
 
 // Compile-time check to verify implements interface.
diff --git a/internal/signing/azure_keyvault.go b/internal/signing/azure_keyvault.go
index 14b94b1..244cbfb 100644
--- a/internal/signing/azure_keyvault.go
+++ b/internal/signing/azure_keyvault.go
@@ -26,9 +26,10 @@ import (
 	"math/big"
 	"strings"
 
-	"github.com/Azure/azure-sdk-for-go/services/keyvault/v7.0/keyvault"
 	"github.com/google/exposure-notifications-server/internal/azurekeyvault"
-	"github.com/google/exposure-notifications-server/internal/base64util"
+	"github.com/google/exposure-notifications-server/pkg/base64util"
+
+	"github.com/Azure/azure-sdk-for-go/services/keyvault/v7.0/keyvault"
 )
 
 // Compile-time check to verify implements interface.
diff --git a/internal/signing/hashicorp_vault.go b/internal/signing/hashicorp_vault.go
index 0871031..33bcd65 100644
--- a/internal/signing/hashicorp_vault.go
+++ b/internal/signing/hashicorp_vault.go
@@ -25,7 +25,8 @@ import (
 	"io"
 	"strings"
 
-	"github.com/google/exposure-notifications-server/internal/base64util"
+	"github.com/google/exposure-notifications-server/pkg/base64util"
+
 	vaultapi "github.com/hashicorp/vault/api"
 )
 
diff --git a/internal/util/generate.go b/internal/util/generate.go
index 2571c81..f876a63 100644
--- a/internal/util/generate.go
+++ b/internal/util/generate.go
@@ -22,8 +22,8 @@ import (
 	"math/big"
 	"time"
 
-	"github.com/google/exposure-notifications-server/internal/base64util"
 	"github.com/google/exposure-notifications-server/pkg/api/v1alpha1"
+	"github.com/google/exposure-notifications-server/pkg/base64util"
 	"github.com/google/exposure-notifications-server/testing/enclient"
 )
 
diff --git a/internal/verification/phaverify.go b/internal/verification/phaverify.go
index 7a52db5..43843ba 100644
--- a/internal/verification/phaverify.go
+++ b/internal/verification/phaverify.go
@@ -23,12 +23,11 @@ import (
 	"fmt"
 
 	aamodel "github.com/google/exposure-notifications-server/internal/authorizedapp/model"
-	"github.com/google/exposure-notifications-server/internal/base64util"
-	"github.com/google/exposure-notifications-server/internal/cache"
 	"github.com/google/exposure-notifications-server/internal/verification/database"
 	"github.com/google/exposure-notifications-server/internal/verification/model"
-
 	verifyapi "github.com/google/exposure-notifications-server/pkg/api/v1alpha1"
+	"github.com/google/exposure-notifications-server/pkg/base64util"
+	"github.com/google/exposure-notifications-server/pkg/cache"
 	utils "github.com/google/exposure-notifications-server/pkg/verification"
 
 	"github.com/dgrijalva/jwt-go"
diff --git a/internal/base64util/decode.go b/pkg/base64util/decode.go
similarity index 84%
rename from internal/base64util/decode.go
rename to pkg/base64util/decode.go
index 6401e2a..85fcb5f 100644
--- a/internal/base64util/decode.go
+++ b/pkg/base64util/decode.go
@@ -14,6 +14,10 @@
 
 // Package base64util extracts base64 encoding/decoding logic into a single API
 // that is tolerant of various paddings.
+//
+// Although exported, this package is non intended for general consumption.
+// It is a shared dependency between multiple exposure notifications projects.
+// We cannot guarantee that there won't be breaking changes in the future.
 package base64util
 
 import (
diff --git a/internal/base64util/decode_test.go b/pkg/base64util/decode_test.go
similarity index 100%
rename from internal/base64util/decode_test.go
rename to pkg/base64util/decode_test.go
diff --git a/internal/cache/cache.go b/pkg/cache/cache.go
similarity index 94%
rename from internal/cache/cache.go
rename to pkg/cache/cache.go
index d18a0ab..39a091b 100644
--- a/internal/cache/cache.go
+++ b/pkg/cache/cache.go
@@ -13,6 +13,10 @@
 // limitations under the License.
 
 // Package cache implements an inmemory cache for any interface{} object.
+//
+// Although exported, this package is non intended for general consumption.
+// It is a shared dependency between multiple exposure notifications projects.
+// We cannot guarantee that there won't be breaking changes in the future.
 package cache
 
 import (
diff --git a/internal/cache/cache_test.go b/pkg/cache/cache_test.go
similarity index 100%
rename from internal/cache/cache_test.go
rename to pkg/cache/cache_test.go
diff --git a/pkg/verification/utils.go b/pkg/verification/utils.go
index 87602e7..413bda4 100644
--- a/pkg/verification/utils.go
+++ b/pkg/verification/utils.go
@@ -13,6 +13,16 @@
 // limitations under the License.
 
 // Package verification provides verification utilities.
+//
+// This is provided as reference to application authors wishing to calculate
+// the exposure key HMAC as part of their exposure notifications mobile app.
+//
+// This protocol is detailed at
+// https://developers.google.com/android/exposure-notifications/verification-system
+//
+// Although exported, this package is non intended for general consumption.
+// It is a shared dependency between multiple exposure notifications projects.
+// We cannot guarantee that there won't be breaking changes in the future.
 package verification
 
 import (


Test patch:
diff --git a/internal/publish/model/exposure_model_test.go b/internal/publish/model/exposure_model_test.go
index dc44c71..e128e6e 100644
--- a/internal/publish/model/exposure_model_test.go
+++ b/internal/publish/model/exposure_model_test.go
@@ -24,8 +24,8 @@ import (
 	"testing"
 	"time"
 
-	"github.com/google/exposure-notifications-server/internal/base64util"
 	verifyapi "github.com/google/exposure-notifications-server/pkg/api/v1alpha1"
+	"github.com/google/exposure-notifications-server/pkg/base64util"
 	"github.com/google/go-cmp/cmp"
 )
 
diff --git a/internal/publish/publish_test.go b/internal/publish/publish_test.go
index c6554d5..0253998 100644
--- a/internal/publish/publish_test.go
+++ b/internal/publish/publish_test.go
@@ -35,7 +35,6 @@ import (
 	"github.com/google/exposure-notifications-server/internal/authorizedapp"
 	aadb "github.com/google/exposure-notifications-server/internal/authorizedapp/database"
 	aamodel "github.com/google/exposure-notifications-server/internal/authorizedapp/model"
-	"github.com/google/exposure-notifications-server/internal/base64util"
 	coredb "github.com/google/exposure-notifications-server/internal/database"
 	pubdb "github.com/google/exposure-notifications-server/internal/publish/database"
 	"github.com/google/exposure-notifications-server/internal/publish/model"
@@ -43,6 +42,7 @@ import (
 	"github.com/google/exposure-notifications-server/internal/util"
 	verdb "github.com/google/exposure-notifications-server/internal/verification/database"
 	vermodel "github.com/google/exposure-notifications-server/internal/verification/model"
+	"github.com/google/exposure-notifications-server/pkg/base64util"
 
 	verifyapi "github.com/google/exposure-notifications-server/pkg/api/v1alpha1"
 	utils "github.com/google/exposure-notifications-server/pkg/verification"