diff --git a/docs/generated/redact_safe.md b/docs/generated/redact_safe.md index e00dc5f06a53..47af0bfd5e79 100644 --- a/docs/generated/redact_safe.md +++ b/docs/generated/redact_safe.md @@ -48,3 +48,4 @@ pkg/util/log/redact.go | `reflect.TypeOf(complex128(0))` pkg/util/log/redact.go | `reflect.TypeOf(os.Interrupt)` pkg/util/log/redact.go | `reflect.TypeOf(time.Time{})` pkg/util/log/redact.go | `reflect.TypeOf(time.Duration(0))` +pkg/util/log/redact.go | `reflect.TypeOf(encodingtype.T(0))` diff --git a/pkg/util/encoding/BUILD.bazel b/pkg/util/encoding/BUILD.bazel index ad6f60069bc4..9a09edf532fc 100644 --- a/pkg/util/encoding/BUILD.bazel +++ b/pkg/util/encoding/BUILD.bazel @@ -17,6 +17,7 @@ go_library( "//pkg/geo/geopb", "//pkg/util/bitarray", "//pkg/util/duration", + "//pkg/util/encoding/encodingtype", "//pkg/util/ipaddr", "//pkg/util/protoutil", "//pkg/util/timeofday", diff --git a/pkg/util/encoding/encoding.go b/pkg/util/encoding/encoding.go index bb907c91b7a5..a4766b375c12 100644 --- a/pkg/util/encoding/encoding.go +++ b/pkg/util/encoding/encoding.go @@ -29,6 +29,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/geo/geopb" "github.com/cockroachdb/cockroach/pkg/util/bitarray" "github.com/cockroachdb/cockroach/pkg/util/duration" + "github.com/cockroachdb/cockroach/pkg/util/encoding/encodingtype" "github.com/cockroachdb/cockroach/pkg/util/ipaddr" "github.com/cockroachdb/cockroach/pkg/util/protoutil" "github.com/cockroachdb/cockroach/pkg/util/timeofday" @@ -1548,7 +1549,7 @@ func DecodeBitArrayDescending(b []byte) ([]byte, bitarray.BitArray, error) { // Type represents the type of a value encoded by // Encode{Null,NotNull,Varint,Uvarint,Float,Bytes}. //go:generate stringer -type=Type -type Type int +type Type encodingtype.T // Type values. // TODO(dan, arjun): Make this into a proto enum. diff --git a/pkg/util/encoding/encodingtype/BUILD.bazel b/pkg/util/encoding/encodingtype/BUILD.bazel new file mode 100644 index 000000000000..18afcaefb2f2 --- /dev/null +++ b/pkg/util/encoding/encodingtype/BUILD.bazel @@ -0,0 +1,8 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "encodingtype", + srcs = ["encoding_type.go"], + importpath = "github.com/cockroachdb/cockroach/pkg/util/encoding/encodingtype", + visibility = ["//visibility:public"], +) diff --git a/pkg/util/encoding/encodingtype/encoding_type.go b/pkg/util/encoding/encodingtype/encoding_type.go new file mode 100644 index 000000000000..88bb14c9b575 --- /dev/null +++ b/pkg/util/encoding/encodingtype/encoding_type.go @@ -0,0 +1,16 @@ +// Copyright 2020 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package encodingtype + +// T is declared in the encodingtype package so that it can be +// registered as always safe to report, while avoiding an import +// cycle. +type T int diff --git a/pkg/util/log/BUILD.bazel b/pkg/util/log/BUILD.bazel index 1fa06f58c144..39c4b2229663 100644 --- a/pkg/util/log/BUILD.bazel +++ b/pkg/util/log/BUILD.bazel @@ -43,6 +43,7 @@ go_library( "//pkg/settings", "//pkg/util", "//pkg/util/caller", + "//pkg/util/encoding/encodingtype", "//pkg/util/envutil", "//pkg/util/fileutil", "//pkg/util/log/logflags", diff --git a/pkg/util/log/redact.go b/pkg/util/log/redact.go index b6c0b5a3cf9f..ab19d599158e 100644 --- a/pkg/util/log/redact.go +++ b/pkg/util/log/redact.go @@ -17,6 +17,7 @@ import ( "strings" "time" + "github.com/cockroachdb/cockroach/pkg/util/encoding/encodingtype" "github.com/cockroachdb/errors" "github.com/cockroachdb/logtags" "github.com/cockroachdb/redact" @@ -117,6 +118,8 @@ func init() { // Times and durations too. redact.RegisterSafeType(reflect.TypeOf(time.Time{})) redact.RegisterSafeType(reflect.TypeOf(time.Duration(0))) + // Encoded types should always be safe to report. + redact.RegisterSafeType(reflect.TypeOf(encodingtype.T(0))) } type redactablePackage struct {