| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,6 +16,7 @@ import ( | |||
| 16 | 16 | "github.com/stackrox/rox/pkg/grpc/requestinfo" | |
| 17 | 17 | "github.com/stackrox/rox/pkg/httputil" | |
| 18 | 18 | "github.com/stackrox/rox/pkg/notifier" | |
| 19 | + "github.com/stackrox/rox/pkg/protocompat" | ||
| 19 | 20 | "github.com/stackrox/rox/pkg/protoutils" | |
| 20 | 21 | "github.com/stackrox/rox/pkg/sac" | |
| 21 | 22 | "github.com/stackrox/rox/pkg/secrets" | |
@@ -62,7 +63,7 @@ func requestToAny(req interface{}) *types.Any { | |||
| 62 | 63 | if req == nil { | |
| 63 | 64 | return nil | |
| 64 | 65 | } | |
| 65 | - msg, ok := req.(proto.Message) | ||
| 66 | + msg, ok := req.(protocompat.Message) | ||
| 66 | 67 | if !ok { | |
| 67 | 68 | return nil | |
| 68 | 69 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,14 +5,14 @@ import ( | |||
| 5 | 5 | "testing" | |
| 6 | 6 | ||
| 7 | 7 | "github.com/golang/protobuf/jsonpb" | |
| 8 | - "github.com/golang/protobuf/proto" | ||
| 8 | + "github.com/stackrox/rox/pkg/protocompat" | ||
| 9 | 9 | "github.com/stretchr/testify/assert" | |
| 10 | 10 | "github.com/stretchr/testify/require" | |
| 11 | 11 | ) | |
| 12 | 12 | ||
| 13 | - // AssertProtoMessageEqual asserts the equality of two proto.Messages by marshalling them to JSON | ||
| 13 | + // AssertProtoMessageEqual asserts the equality of two protocompat.Messages by marshalling them to JSON | ||
| 14 | 14 | // and comparing the JSON output. | |
| 15 | - func AssertProtoMessageEqual(t *testing.T, a, b proto.Message) { | ||
| 15 | + func AssertProtoMessageEqual(t *testing.T, a, b protocompat.Message) { | ||
| 16 | 16 | m := jsonpb.Marshaler{} | |
| 17 | 17 | ||
| 18 | 18 | jsonA := &bytes.Buffer{} | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,6 @@ import ( | |||
| 9 | 9 | "sync/atomic" | |
| 10 | 10 | "time" | |
| 11 | 11 | ||
| 12 | - "github.com/gogo/protobuf/proto" | ||
| 13 | 12 | "github.com/hashicorp/go-multierror" | |
| 14 | 13 | "github.com/mitchellh/hashstructure/v2" | |
| 15 | 14 | "github.com/pkg/errors" | |
@@ -24,6 +23,7 @@ import ( | |||
| 24 | 23 | "github.com/stackrox/rox/pkg/errox" | |
| 25 | 24 | "github.com/stackrox/rox/pkg/k8scfgwatch" | |
| 26 | 25 | "github.com/stackrox/rox/pkg/maputil" | |
| 26 | + "github.com/stackrox/rox/pkg/protocompat" | ||
| 27 | 27 | "github.com/stackrox/rox/pkg/sac" | |
| 28 | 28 | "github.com/stackrox/rox/pkg/sac/resources" | |
| 29 | 29 | "github.com/stackrox/rox/pkg/set" | |
@@ -40,7 +40,7 @@ const ( | |||
| 40 | 40 | consecutiveReconciliationErrorThreshold = 3 | |
| 41 | 41 | ) | |
| 42 | 42 | ||
| 43 | - type protoMessagesByType = map[reflect.Type][]proto.Message | ||
| 43 | + type protoMessagesByType = map[reflect.Type][]protocompat.Message | ||
| 44 | 44 | ||
| 45 | 45 | type managerImpl struct { | |
| 46 | 46 | once sync.Once | |
@@ -182,7 +182,7 @@ func (m *managerImpl) UpdateDeclarativeConfigContents(handlerID string, contents | |||
| 182 | 182 | return | |
| 183 | 183 | } | |
| 184 | 184 | ||
| 185 | - transformedConfigurations := make(map[reflect.Type][]proto.Message, len(configurations)) | ||
| 185 | + transformedConfigurations := make(map[reflect.Type][]protocompat.Message, len(configurations)) | ||
| 186 | 186 | var transformationErrors *multierror.Error | |
| 187 | 187 | for _, configuration := range configurations { | |
| 188 | 188 | transformedConfig, err := m.universalTransformer.Transform(configuration) | |
@@ -327,7 +327,7 @@ func (m *managerImpl) doDeletion(transformedMessagesByHandler map[string]protoMe | |||
| 327 | 327 | // In case err == nil, the health status will be set to healthy. | |
| 328 | 328 | // In case err != nil _and_ the number of errors for this message is >= the given threshold, the health | |
| 329 | 329 | // status will be set to unhealthy. | |
| 330 | - func (m *managerImpl) updateHealthForMessage(handler string, message proto.Message, err error, threshold int32) { | ||
| 330 | + func (m *managerImpl) updateHealthForMessage(handler string, message protocompat.Message, err error, threshold int32) { | ||
| 331 | 331 | messageID := m.idExtractor(message) | |
| 332 | 332 | healthStatus := declarativeConfigUtils.HealthStatusForProtoMessage(message, handler, err, m.idExtractor, m.nameExtractor) | |
| 333 | 333 | ||
@@ -344,7 +344,7 @@ func (m *managerImpl) updateHealthForMessage(handler string, message proto.Messa | |||
| 344 | 344 | } | |
| 345 | 345 | } | |
| 346 | 346 | ||
| 347 | - func (m *managerImpl) registerHealthForMessages(handler string, messages ...proto.Message) { | ||
| 347 | + func (m *managerImpl) registerHealthForMessages(handler string, messages ...protocompat.Message) { | ||
| 348 | 348 | for _, message := range messages { | |
| 349 | 349 | health := declarativeConfigUtils.HealthStatusForProtoMessage(message, handler, nil, m.idExtractor, m.nameExtractor) | |
| 350 | 350 | m.registerDeclarativeConfigHealth(health) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,6 @@ import ( | |||
| 6 | 6 | "testing" | |
| 7 | 7 | "time" | |
| 8 | 8 | ||
| 9 | - "github.com/gogo/protobuf/proto" | ||
| 10 | 9 | "github.com/pkg/errors" | |
| 11 | 10 | declarativeConfigHealthMock "github.com/stackrox/rox/central/declarativeconfig/health/datastore/mocks" | |
| 12 | 11 | "github.com/stackrox/rox/central/declarativeconfig/types" | |
@@ -16,6 +15,7 @@ import ( | |||
| 16 | 15 | "github.com/stackrox/rox/pkg/declarativeconfig" | |
| 17 | 16 | transformMocks "github.com/stackrox/rox/pkg/declarativeconfig/transform/mocks" | |
| 18 | 17 | "github.com/stackrox/rox/pkg/errox" | |
| 18 | + "github.com/stackrox/rox/pkg/protocompat" | ||
| 19 | 19 | "github.com/stretchr/testify/assert" | |
| 20 | 20 | "github.com/stretchr/testify/require" | |
| 21 | 21 | "go.uber.org/mock/gomock" | |
@@ -241,25 +241,25 @@ func TestReconcileTransformedMessages_Success(t *testing.T) { | |||
| 241 | 241 | ||
| 242 | 242 | m.reconcileTransformedMessages(map[string]protoMessagesByType{ | |
| 243 | 243 | "test-handler-1": { | |
| 244 | - types.PermissionSetType: []proto.Message{ | ||
| 244 | + types.PermissionSetType: []protocompat.Message{ | ||
| 245 | 245 | permissionSet1, | |
| 246 | 246 | permissionSet2, | |
| 247 | 247 | }, | |
| 248 | - types.AccessScopeType: []proto.Message{ | ||
| 248 | + types.AccessScopeType: []protocompat.Message{ | ||
| 249 | 249 | accessScope, | |
| 250 | 250 | }, | |
| 251 | 251 | }, | |
| 252 | 252 | "test-handler-2": { | |
| 253 | - types.RoleType: []proto.Message{ | ||
| 253 | + types.RoleType: []protocompat.Message{ | ||
| 254 | 254 | role, | |
| 255 | 255 | }, | |
| 256 | - types.AuthProviderType: []proto.Message{ | ||
| 256 | + types.AuthProviderType: []protocompat.Message{ | ||
| 257 | 257 | authProvider, | |
| 258 | 258 | }, | |
| 259 | - types.GroupType: []proto.Message{ | ||
| 259 | + types.GroupType: []protocompat.Message{ | ||
| 260 | 260 | group, | |
| 261 | 261 | }, | |
| 262 | - types.NotifierType: []proto.Message{ | ||
| 262 | + types.NotifierType: []protocompat.Message{ | ||
| 263 | 263 | notifier, | |
| 264 | 264 | }, | |
| 265 | 265 | }, | |
@@ -308,7 +308,7 @@ func TestReconcileTransformedMessages_ErrorPropagatedToReporter(t *testing.T) { | |||
| 308 | 308 | for i := 0; i < consecutiveReconciliationErrorThreshold; i++ { | |
| 309 | 309 | m.reconcileTransformedMessages(map[string]protoMessagesByType{ | |
| 310 | 310 | "test-handler-1": { | |
| 311 | - types.PermissionSetType: []proto.Message{ | ||
| 311 | + types.PermissionSetType: []protocompat.Message{ | ||
| 312 | 312 | permissionSet1, | |
| 313 | 313 | }, | |
| 314 | 314 | }, | |
@@ -349,7 +349,7 @@ func TestReconcileTransformedMessages_SkipReconciliationWithNoChanges(t *testing | |||
| 349 | 349 | ||
| 350 | 350 | messages := map[string]protoMessagesByType{ | |
| 351 | 351 | "test-handler-1": { | |
| 352 | - types.PermissionSetType: []proto.Message{ | ||
| 352 | + types.PermissionSetType: []protocompat.Message{ | ||
| 353 | 353 | permissionSet1, | |
| 354 | 354 | }, | |
| 355 | 355 | }, | |
@@ -398,7 +398,7 @@ func TestReconcileTransformedMessages_SkipDeletion(t *testing.T) { | |||
| 398 | 398 | ||
| 399 | 399 | messages := map[string]protoMessagesByType{ | |
| 400 | 400 | "test-handler-1": { | |
| 401 | - types.PermissionSetType: []proto.Message{ | ||
| 401 | + types.PermissionSetType: []protocompat.Message{ | ||
| 402 | 402 | permissionSet1, | |
| 403 | 403 | }, | |
| 404 | 404 | }, | |
@@ -463,7 +463,7 @@ func TestReconcileTransformedMessages_SkipUpsert(t *testing.T) { | |||
| 463 | 463 | ||
| 464 | 464 | messages := map[string]protoMessagesByType{ | |
| 465 | 465 | "test-handler-1": { | |
| 466 | - types.PermissionSetType: []proto.Message{ | ||
| 466 | + types.PermissionSetType: []protocompat.Message{ | ||
| 467 | 467 | permissionSet1, | |
| 468 | 468 | }, | |
| 469 | 469 | }, | |
@@ -512,7 +512,7 @@ func TestUpdateDeclarativeConfigContents_RegisterHealthStatus(t *testing.T) { | |||
| 512 | 512 | Description: "test-description", | |
| 513 | 513 | AccessScope: "access-scope", | |
| 514 | 514 | PermissionSet: "permission-set", | |
| 515 | - }).Return(map[reflect.Type][]proto.Message{ | ||
| 515 | + }).Return(map[reflect.Type][]protocompat.Message{ | ||
| 516 | 516 | types.RoleType: { | |
| 517 | 517 | &storage.Role{ | |
| 518 | 518 | Name: "test-name", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,17 +3,17 @@ package types | |||
| 3 | 3 | import ( | |
| 4 | 4 | "fmt" | |
| 5 | 5 | ||
| 6 | - "github.com/gogo/protobuf/proto" | ||
| 7 | 6 | "github.com/stackrox/rox/generated/storage" | |
| 8 | 7 | "github.com/stackrox/rox/pkg/errox" | |
| 8 | + "github.com/stackrox/rox/pkg/protocompat" | ||
| 9 | 9 | "github.com/stackrox/rox/pkg/utils" | |
| 10 | 10 | ) | |
| 11 | 11 | ||
| 12 | 12 | // IDExtractor extracts the ID from proto messages. | |
| 13 | - type IDExtractor func(m proto.Message) string | ||
| 13 | + type IDExtractor func(m protocompat.Message) string | ||
| 14 | 14 | ||
| 15 | 15 | // NameExtractor extracts the name from proto messages. | |
| 16 | - type NameExtractor func(m proto.Message) string | ||
| 16 | + type NameExtractor func(m protocompat.Message) string | ||
| 17 | 17 | ||
| 18 | 18 | // UniversalIDExtractor provides a way to extract the ID from proto messages. | |
| 19 | 19 | func UniversalIDExtractor() IDExtractor { | |
@@ -25,7 +25,7 @@ func UniversalNameExtractor() NameExtractor { | |||
| 25 | 25 | return extractNameFromProtoMessage | |
| 26 | 26 | } | |
| 27 | 27 | ||
| 28 | - func extractIDFromProtoMessage(message proto.Message) string { | ||
| 28 | + func extractIDFromProtoMessage(message protocompat.Message) string { | ||
| 29 | 29 | // Special case, as the group specifies the ID nested within the groups properties. | |
| 30 | 30 | if group, ok := message.(*storage.Group); ok { | |
| 31 | 31 | return group.GetProps().GetId() | |
@@ -48,7 +48,7 @@ func extractIDFromProtoMessage(message proto.Message) string { | |||
| 48 | 48 | return messageWithID.GetId() | |
| 49 | 49 | } | |
| 50 | 50 | ||
| 51 | - func extractNameFromProtoMessage(message proto.Message) string { | ||
| 51 | + func extractNameFromProtoMessage(message protocompat.Message) string { | ||
| 52 | 52 | // Special case, as the group specifies no name we will use a combination of multiple values to identify it. | |
| 53 | 53 | if group, ok := message.(*storage.Group); ok { | |
| 54 | 54 | return fmt.Sprintf("group %s:%s:%s for auth provider ID %s", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,6 @@ package updater | |||
| 3 | 3 | import ( | |
| 4 | 4 | "context" | |
| 5 | 5 | ||
| 6 | - "github.com/gogo/protobuf/proto" | ||
| 7 | 6 | "github.com/hashicorp/go-multierror" | |
| 8 | 7 | "github.com/pkg/errors" | |
| 9 | 8 | declarativeConfigHealth "github.com/stackrox/rox/central/declarativeconfig/health/datastore" | |
@@ -12,6 +11,7 @@ import ( | |||
| 12 | 11 | "github.com/stackrox/rox/generated/storage" | |
| 13 | 12 | "github.com/stackrox/rox/pkg/declarativeconfig" | |
| 14 | 13 | "github.com/stackrox/rox/pkg/errox" | |
| 14 | + "github.com/stackrox/rox/pkg/protocompat" | ||
| 15 | 15 | "github.com/stackrox/rox/pkg/set" | |
| 16 | 16 | ) | |
| 17 | 17 | ||
@@ -33,7 +33,7 @@ func newAccessScopeUpdater(datastore roleDataStore.DataStore, healthDS declarati | |||
| 33 | 33 | } | |
| 34 | 34 | } | |
| 35 | 35 | ||
| 36 | - func (u *accessScopeUpdater) Upsert(ctx context.Context, m proto.Message) error { | ||
| 36 | + func (u *accessScopeUpdater) Upsert(ctx context.Context, m protocompat.Message) error { | ||
| 37 | 37 | accessScope, ok := m.(*storage.SimpleAccessScope) | |
| 38 | 38 | if !ok { | |
| 39 | 39 | return errox.InvariantViolation.Newf("wrong type passed to access scope updater: %T", accessScope) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,6 @@ package updater | |||
| 3 | 3 | import ( | |
| 4 | 4 | "context" | |
| 5 | 5 | ||
| 6 | - "github.com/gogo/protobuf/proto" | ||
| 7 | 6 | "github.com/hashicorp/go-multierror" | |
| 8 | 7 | "github.com/pkg/errors" | |
| 9 | 8 | authProviderDatastore "github.com/stackrox/rox/central/authprovider/datastore" | |
@@ -15,6 +14,7 @@ import ( | |||
| 15 | 14 | "github.com/stackrox/rox/pkg/declarativeconfig" | |
| 16 | 15 | "github.com/stackrox/rox/pkg/errox" | |
| 17 | 16 | "github.com/stackrox/rox/pkg/logging" | |
| 17 | + "github.com/stackrox/rox/pkg/protocompat" | ||
| 18 | 18 | "github.com/stackrox/rox/pkg/sac" | |
| 19 | 19 | "github.com/stackrox/rox/pkg/sac/resources" | |
| 20 | 20 | "github.com/stackrox/rox/pkg/set" | |
@@ -52,7 +52,7 @@ func newAuthProviderUpdater(authProvidersDS authproviders.Store, registry authpr | |||
| 52 | 52 | } | |
| 53 | 53 | } | |
| 54 | 54 | ||
| 55 | - func (u *authProviderUpdater) Upsert(ctx context.Context, m proto.Message) error { | ||
| 55 | + func (u *authProviderUpdater) Upsert(ctx context.Context, m protocompat.Message) error { | ||
| 56 | 56 | authProvider, ok := m.(*storage.AuthProvider) | |
| 57 | 57 | if !ok { | |
| 58 | 58 | return errox.InvariantViolation.Newf("wrong type passed to auth provider updater: %T", authProvider) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,6 @@ package updater | |||
| 3 | 3 | import ( | |
| 4 | 4 | "context" | |
| 5 | 5 | ||
| 6 | - "github.com/gogo/protobuf/proto" | ||
| 7 | 6 | "github.com/hashicorp/go-multierror" | |
| 8 | 7 | "github.com/pkg/errors" | |
| 9 | 8 | declarativeConfigHealth "github.com/stackrox/rox/central/declarativeconfig/health/datastore" | |
@@ -12,6 +11,7 @@ import ( | |||
| 12 | 11 | "github.com/stackrox/rox/generated/storage" | |
| 13 | 12 | "github.com/stackrox/rox/pkg/declarativeconfig" | |
| 14 | 13 | "github.com/stackrox/rox/pkg/errox" | |
| 14 | + "github.com/stackrox/rox/pkg/protocompat" | ||
| 15 | 15 | "github.com/stackrox/rox/pkg/set" | |
| 16 | 16 | ) | |
| 17 | 17 | ||
@@ -33,7 +33,7 @@ func newGroupUpdater(datastore groupDataStore.DataStore, healthDS declarativeCon | |||
| 33 | 33 | } | |
| 34 | 34 | } | |
| 35 | 35 | ||
| 36 | - func (u *groupUpdater) Upsert(ctx context.Context, m proto.Message) error { | ||
| 36 | + func (u *groupUpdater) Upsert(ctx context.Context, m protocompat.Message) error { | ||
| 37 | 37 | group, ok := m.(*storage.Group) | |
| 38 | 38 | if !ok { | |
| 39 | 39 | return errox.InvariantViolation.Newf("wrong type passed to group updater: %T", group) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,6 @@ package updater | |||
| 3 | 3 | import ( | |
| 4 | 4 | "context" | |
| 5 | 5 | ||
| 6 | - "github.com/gogo/protobuf/proto" | ||
| 7 | 6 | "github.com/hashicorp/go-multierror" | |
| 8 | 7 | "github.com/pkg/errors" | |
| 9 | 8 | declarativeConfigHealth "github.com/stackrox/rox/central/declarativeconfig/health/datastore" | |
@@ -18,6 +17,7 @@ import ( | |||
| 18 | 17 | "github.com/stackrox/rox/pkg/integrationhealth" | |
| 19 | 18 | "github.com/stackrox/rox/pkg/notifier" | |
| 20 | 19 | "github.com/stackrox/rox/pkg/notifiers" | |
| 20 | + "github.com/stackrox/rox/pkg/protocompat" | ||
| 21 | 21 | "github.com/stackrox/rox/pkg/set" | |
| 22 | 22 | "github.com/stackrox/rox/pkg/utils" | |
| 23 | 23 | ) | |
@@ -58,7 +58,7 @@ func newNotifierUpdater(notifierDS notifierDataStore.DataStore, policyCleaner po | |||
| 58 | 58 | } | |
| 59 | 59 | } | |
| 60 | 60 | ||
| 61 | - func (u *notifierUpdater) Upsert(ctx context.Context, m proto.Message) error { | ||
| 61 | + func (u *notifierUpdater) Upsert(ctx context.Context, m protocompat.Message) error { | ||
| 62 | 62 | notifierProto, ok := m.(*storage.Notifier) | |
| 63 | 63 | if !ok { | |
| 64 | 64 | return errox.InvariantViolation.Newf("wrong type passed to role updater: %T", notifierProto) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments