Skip to content

Commit

Permalink
Fix merge Redact entity configuration metadata
Browse files Browse the repository at this point in the history
Original work (#4862) adapted for 7.x track

Signed-off-by: Christian Kruse <[email protected]>

go mod tidy

Signed-off-by: Christian Kruse <[email protected]>
  • Loading branch information
c-kruse committed Oct 5, 2022
1 parent 41f3e41 commit 04283ff
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 46 deletions.
4 changes: 4 additions & 0 deletions api/core/v3/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ require (
github.com/golang/protobuf v1.5.2
github.com/sensu/sensu-go/api/core/v2 v2.15.0
github.com/sensu/sensu-go/types v0.11.0
github.com/stretchr/testify v1.6.0
)

require (
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/echlebek/timeproxy v1.0.0 // indirect
github.com/golang-jwt/jwt/v4 v4.0.0 // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/robertkrimen/otto v0.0.0-20191219234010-c382bd3c16ff // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/sirupsen/logrus v1.6.0 // indirect
Expand All @@ -27,4 +30,5 @@ require (
google.golang.org/grpc v1.38.0 // indirect
google.golang.org/protobuf v1.26.0 // indirect
gopkg.in/sourcemap.v1 v1.0.5 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
1 change: 1 addition & 0 deletions api/core/v3/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/sourcemap.v1 v1.0.5 h1:inv58fC9f9J3TK2Y2R1NPntXEn3/wjWHkonhIUODNTI=
gopkg.in/sourcemap.v1 v1.0.5/go.mod h1:2RlvNNSMglmRrcvhfuzp4hQHwOtjxlbjX7UPY/GXb78=
Expand Down
10 changes: 6 additions & 4 deletions backend/api/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (g *GenericClient) getResource(ctx context.Context, name string, value core
return err
}
if redacter, ok := value.(corev3.Redacter); ok {
value = redacter.ProduceRedacted()
redacter.ProduceRedacted()
}
return err
}
Expand Down Expand Up @@ -194,9 +194,11 @@ func (g *GenericClient) list(ctx context.Context, resources interface{}, pred *s
if err := list.UnwrapInto(resources); err != nil {
return err
}
if redacters, ok := resources.([]corev3.Redacter); ok {
for i, redacter := range redacters {
redacters[i] = redacter.ProduceRedacted()
if v3Resources, ok := resources.(*[]corev3.Resource); ok {
for i, resource := range *v3Resources {
if redacter, ok := resource.(corev3.Redacter); ok {
(*v3Resources)[i] = redacter.ProduceRedacted()
}
}
}
return nil
Expand Down
26 changes: 13 additions & 13 deletions backend/api/generic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,8 @@ func TestGenericClientStoreV2_sensu_enterprise_go_GH2484(t *testing.T) {
if err != nil {
panic(err)
}
store.On("Get", mock.Anything).Return(wrappedResource, nil)
store.On("List", mock.Anything, mock.Anything).Return(wrap.List{wrappedResource.(*wrap.Wrapper)}, nil)
store.On("Get", mock.Anything, mock.Anything).Return(wrappedResource, nil)
store.On("List", mock.Anything, mock.Anything, mock.Anything).Return(wrap.List{wrappedResource.(*wrap.Wrapper)}, nil)
return store
}
v3AllAccess := func() authorization.Authorizer {
Expand Down Expand Up @@ -633,27 +633,27 @@ func TestGenericClientStoreV2_sensu_enterprise_go_GH2484(t *testing.T) {

ctx := contextWithUser(defaultContext(), "tom", nil)
client := defaultV2TestClient(makeStore(nil), v3AllAccess())
listVal := []corev2.Resource{}
listVal := []corev3.Resource{}
if err := client.List(ctx, &listVal, &store.SelectionPredicate{}); err != nil {
t.Fatal(err)
}
if listVal[0].GetObjectMeta().Labels["password"] != corev2.Redacted {
t.Errorf("Labels['password'] = %s, got: %s", corev2.Redacted, listVal[0].GetObjectMeta().Labels["password"])
if listVal[0].GetMetadata().Labels["password"] != corev2.Redacted {
t.Errorf("Labels['password'] = %s, got: %s", corev2.Redacted, listVal[0].GetMetadata().Labels["password"])
}
if listVal[0].GetObjectMeta().Labels["my_label"] != "test" {
t.Errorf("Labels['my_label'] = %s, got: %s", "test", listVal[0].GetObjectMeta().Labels["my_label"])
if listVal[0].GetMetadata().Labels["my_label"] != "test" {
t.Errorf("Labels['my_label'] = %s, got: %s", "test", listVal[0].GetMetadata().Labels["my_label"])
}

client = defaultV2TestClient(makeStore(nil), v3AllAccess())
getVal := corev3.V2ResourceProxy{Resource: &corev3.EntityConfig{}}
if err := client.Get(ctx, "default", &getVal); err != nil {
getVal := &corev3.EntityConfig{}
if err := client.Get(ctx, "default", getVal); err != nil {
t.Fatal(err)
}
if getVal.GetObjectMeta().Labels["password"] != corev2.Redacted {
t.Errorf("Labels['password'] = %s, got: %s", corev2.Redacted, getVal.GetObjectMeta().Labels["password"])
if getVal.GetMetadata().Labels["password"] != corev2.Redacted {
t.Errorf("Labels['password'] = %s, got: %s", corev2.Redacted, getVal.GetMetadata().Labels["password"])
}
if getVal.GetObjectMeta().Labels["my_label"] != "test" {
t.Errorf("Labels['my_label'] = %s, got: %s", "test", getVal.GetObjectMeta().Labels["my_label"])
if getVal.GetMetadata().Labels["my_label"] != "test" {
t.Errorf("Labels['my_label'] = %s, got: %s", "test", getVal.GetMetadata().Labels["my_label"])
}
}

Expand Down
32 changes: 15 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ require (
github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097
github.com/jackc/pgconn v1.12.1
github.com/jackc/pgx/v4 v4.16.1
github.com/json-iterator/go v1.1.12
github.com/lib/pq v1.10.5
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b
github.com/mholt/archiver/v3 v3.3.1-0.20191129193105-44285f7ed244
Expand All @@ -47,8 +46,8 @@ require (
github.com/robertkrimen/otto v0.0.0-20191219234010-c382bd3c16ff
github.com/robfig/cron/v3 v3.0.1
github.com/sensu/lasr v1.2.1
github.com/sensu/sensu-go/api/core/v2 v2.15.0
github.com/sensu/sensu-go/api/core/v3 v3.7.0
github.com/sensu/sensu-go/api/core/v2 v2.15.1-alpha2
github.com/sensu/sensu-go/api/core/v3 v3.7.1-alpha1
github.com/sensu/sensu-go/types v0.11.0
github.com/shirou/gopsutil/v3 v3.21.12
github.com/sirupsen/logrus v1.7.0
Expand Down Expand Up @@ -78,6 +77,7 @@ require (
github.com/andybalholm/brotli v1.0.0 // indirect
github.com/ash2k/stager v0.0.0-20170622123058-6e9c7b0eacd4 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.1.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
Expand Down Expand Up @@ -107,6 +107,7 @@ require (
github.com/jackc/puddle v1.2.1 // indirect
github.com/jbenet/go-reuseport v0.0.0-20180416043609-15a1cd37f050 // indirect
github.com/jonboulle/clockwork v0.2.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/compress v1.9.2 // indirect
github.com/klauspost/pgzip v1.2.1 // indirect
Expand Down Expand Up @@ -141,24 +142,21 @@ require (
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.etcd.io/etcd/client/v2 v2.305.4 // indirect
go.etcd.io/etcd/pkg/v3 v3.5.4 // indirect
go.etcd.io/etcd/raft/v3 v3.5.4 // indirect
go.opentelemetry.io/contrib v0.20.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.20.0 // indirect
go.opentelemetry.io/otel v0.20.0 // indirect
go.opentelemetry.io/otel/exporters/otlp v0.20.0 // indirect
go.opentelemetry.io/otel/metric v0.20.0 // indirect
go.opentelemetry.io/otel/sdk v0.20.0 // indirect
go.opentelemetry.io/otel/sdk/export/metric v0.20.0 // indirect
go.opentelemetry.io/otel/sdk/metric v0.20.0 // indirect
go.opentelemetry.io/otel/trace v0.20.0 // indirect
go.opentelemetry.io/proto/otlp v0.7.0 // indirect
go.etcd.io/etcd/client/v2 v2.305.5 // indirect
go.etcd.io/etcd/pkg/v3 v3.5.5 // indirect
go.etcd.io/etcd/raft/v3 v3.5.5 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.25.0 // indirect
go.opentelemetry.io/otel v1.0.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.1 // indirect
go.opentelemetry.io/otel/sdk v1.0.1 // indirect
go.opentelemetry.io/otel/trace v1.0.1 // indirect
go.opentelemetry.io/proto/otlp v0.9.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect
google.golang.org/protobuf v1.26.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/ini.v1 v1.51.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/sourcemap.v1 v1.0.5 // indirect
Expand Down
19 changes: 7 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5 h1:xD/lrqdvwsc+O2bjSSi3YqY73Ke3LAiSCx49aCesA0E=
github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo=
github.com/cockroachdb/errors v1.2.4 h1:Lap807SXTH5tri2TivECb/4abUkMZC9zRoLarvcKDqs=
Expand Down Expand Up @@ -487,15 +487,12 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg
github.com/sensu/lasr v1.2.1 h1:4H1QfOrPkwYHMFE5qAI6GwKEFkcI1YRyjjWidz1MihQ=
github.com/sensu/lasr v1.2.1/go.mod h1:VIMtIK67Bcef6dTfctRCBg8EY9M9TtCY9NEFT6Zw5xQ=
github.com/sensu/sensu-go/api/core/v2 v2.14.0/go.mod h1:XCgUjY78ApTahizBz/pkc5KU17L/E5BexeZHkGDdTls=
github.com/sensu/sensu-go/api/core/v2 v2.15.0 h1:TdH4Iq2OfpVqoY3yVXpUVe2lMmC0Ksp9Dq3wpIELXRM=
github.com/sensu/sensu-go/api/core/v2 v2.15.0/go.mod h1:QxGKxqQv4rpweFrR4Jkp1tas3amGzAy0wO0fUwq0suU=
github.com/sensu/sensu-go/api/core/v2 v2.15.1-alpha2 h1:6hUVaCWZkzUPevOXjrSJoGdW4iF3CxdCrahv4m7bPB0=
github.com/sensu/sensu-go/api/core/v2 v2.15.1-alpha2/go.mod h1:MjM7+MCGEyTAgaZ589SiGHwYiaYF7N/58dU0J070u/0=
github.com/sensu/sensu-go/api/core/v3 v3.6.1/go.mod h1:aqNOkJxkrwRq+rPW47XtVWeb5Rk1K5adlCZGBW9nsvM=
github.com/sensu/sensu-go/api/core/v3 v3.6.2/go.mod h1:aqNOkJxkrwRq+rPW47XtVWeb5Rk1K5adlCZGBW9nsvM=
github.com/sensu/sensu-go/api/core/v3 v3.7.0 h1:SgLar+4h3e7B8FveOHGshosmDxJhrP1ovh/1eNS11eM=
github.com/sensu/sensu-go/api/core/v3 v3.7.0/go.mod h1:X0mcDXOt2LCjuu0sCzXNdeeYbLq9QLtxKSpnsDybclg=
github.com/sensu/sensu-go/api/core/v3 v3.6.3-0.20220913191107-10ae2ae7d8cf h1:K1VrKHGwQ4UpOQmy2J6IFyv0u17OKTwWrfAGILClpbw=
github.com/sensu/sensu-go/api/core/v3 v3.6.3-0.20220913191107-10ae2ae7d8cf/go.mod h1:n2dhnBTovMrzmE1P0D7gvEbUG7TPH6hdtr7qvoPf/sY=
github.com/sensu/sensu-go/types v0.10.0 h1:sm+dLuqEEECVxjW5EfXkU5weGPwrg/Jymbm28HdQpl8=
github.com/sensu/sensu-go/api/core/v3 v3.7.1-alpha1 h1:nd6ib+RMRI/e7q++kmtcFt5HrJCBtmz6UGUMH132XhY=
github.com/sensu/sensu-go/api/core/v3 v3.7.1-alpha1/go.mod h1:8io5TBGBcuR9B5MiWUi3bqr2+sGe+qcH5p6NjhAlzy4=
github.com/sensu/sensu-go/types v0.10.0/go.mod h1:vFZJ9TYBAjSPYtYt+82PpS9P6m73Vzr4O23lmJonzrA=
github.com/sensu/sensu-go/types v0.11.0 h1:jsVa/apRaJJEdk0Jl7ZUksiBkuEAjCZd/gSBWlrptJA=
github.com/sensu/sensu-go/types v0.11.0/go.mod h1:fhgW3xlvkPFMZiT0IppHySeyN61ZTIKevgSPFSoaQEk=
Expand Down Expand Up @@ -605,9 +602,9 @@ go.opentelemetry.io/otel/sdk v1.0.1/go.mod h1:HrdXne+BiwsOHYYkBE5ysIcv2bvdZstxzm
go.opentelemetry.io/otel/trace v1.0.1 h1:StTeIH6Q3G4r0Fiw34LTokUFESZgIDUr0qIJ7mKmAfw=
go.opentelemetry.io/otel/trace v1.0.1/go.mod h1:5g4i4fKLaX2BQpSBsxw8YYcgKpMMSW3x7ZTuYBr3sUk=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.opentelemetry.io/proto/otlp v0.9.0 h1:C0g6TWmQYvjKRnljRULLWUVJGy8Uvu0NEL/5frY2/t4=
go.opentelemetry.io/proto/otlp v0.9.0/go.mod h1:1vKfU9rv61e9EVGthD1zNvUbiwPcimSsOPU9brfSHJg=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
Expand Down Expand Up @@ -641,8 +638,6 @@ golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWP
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838 h1:71vQrMauZZhcTVK6KdYM+rklehEEwb3E+ZhaE5jrPrE=
golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA=
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand Down

0 comments on commit 04283ff

Please sign in to comment.