diff --git a/api/handler/handler.go b/api/handler/handler.go index 3009bde18..da1a92900 100644 --- a/api/handler/handler.go +++ b/api/handler/handler.go @@ -20,6 +20,5 @@ func Register(ctx context.Context, s *server.MuxServer, gw *server.GRPCGateway, // grpc gateway api will have version endpoints s.SetGateway("/", gw) - v1.RegisterV1(ctx, s, gw, deps.V1) } diff --git a/api/handler/v1/action.go b/api/handler/v1/action.go new file mode 100644 index 000000000..c847ed3dd --- /dev/null +++ b/api/handler/v1/action.go @@ -0,0 +1,132 @@ +package v1 + +import ( + "context" + "errors" + + grpczap "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap" + "github.com/odpf/shield/internal/schema" + "github.com/odpf/shield/model" + shieldv1 "github.com/odpf/shield/proto/v1" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/timestamppb" +) + +type ActionService interface { + GetAction(ctx context.Context, id string) (model.Action, error) + ListActions(ctx context.Context) ([]model.Action, error) + CreateAction(ctx context.Context, action model.Action) (model.Action, error) + UpdateAction(ctx context.Context, id string, action model.Action) (model.Action, error) +} + +var grpcActionNotFoundErr = status.Errorf(codes.NotFound, "action doesn't exist") + +func (v Dep) ListActions(ctx context.Context, request *shieldv1.ListActionsRequest) (*shieldv1.ListActionsResponse, error) { + logger := grpczap.Extract(ctx) + var actions []*shieldv1.Action + + actionsList, err := v.ActionService.ListActions(ctx) + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + for _, act := range actionsList { + actPB, err := transformActionToPB(act) + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + actions = append(actions, &actPB) + } + + return &shieldv1.ListActionsResponse{Actions: actions}, nil +} + +func (v Dep) CreateAction(ctx context.Context, request *shieldv1.CreateActionRequest) (*shieldv1.CreateActionResponse, error) { + logger := grpczap.Extract(ctx) + + newAction, err := v.ActionService.CreateAction(ctx, model.Action{ + Id: request.GetBody().Id, + Name: request.GetBody().Name, + NamespaceId: request.GetBody().NamespaceId, + }) + + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + actionPB, err := transformActionToPB(newAction) + + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + return &shieldv1.CreateActionResponse{Action: &actionPB}, nil +} + +func (v Dep) GetAction(ctx context.Context, request *shieldv1.GetActionRequest) (*shieldv1.GetActionResponse, error) { + logger := grpczap.Extract(ctx) + + fetchedAction, err := v.ActionService.GetAction(ctx, request.GetId()) + if err != nil { + logger.Error(err.Error()) + switch { + case errors.Is(err, schema.ActionDoesntExist): + return nil, grpcActionNotFoundErr + case errors.Is(err, schema.InvalidUUID): + return nil, grpcBadBodyError + default: + return nil, grpcInternalServerError + } + } + + actionPB, err := transformActionToPB(fetchedAction) + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + return &shieldv1.GetActionResponse{Action: &actionPB}, nil +} + +func (v Dep) UpdateAction(ctx context.Context, request *shieldv1.UpdateActionRequest) (*shieldv1.UpdateActionResponse, error) { + logger := grpczap.Extract(ctx) + + updatedAction, err := v.ActionService.UpdateAction(ctx, request.GetId(), model.Action{ + Id: request.GetId(), + Name: request.GetBody().Name, + NamespaceId: request.GetBody().NamespaceId, + }) + + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + actionPB, err := transformActionToPB(updatedAction) + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + return &shieldv1.UpdateActionResponse{Action: &actionPB}, nil +} + +func transformActionToPB(act model.Action) (shieldv1.Action, error) { + namespace, err := transformNamespaceToPB(act.Namespace) + if err != nil { + return shieldv1.Action{}, err + } + return shieldv1.Action{ + Id: act.Id, + Name: act.Name, + Namespace: &namespace, + CreatedAt: timestamppb.New(act.CreatedAt), + UpdatedAt: timestamppb.New(act.UpdatedAt), + }, nil +} diff --git a/api/handler/v1/action_test.go b/api/handler/v1/action_test.go new file mode 100644 index 000000000..16b497639 --- /dev/null +++ b/api/handler/v1/action_test.go @@ -0,0 +1,233 @@ +package v1 + +import ( + "context" + "errors" + "sort" + "strings" + "testing" + "time" + + "github.com/odpf/shield/model" + shieldv1 "github.com/odpf/shield/proto/v1" + + "github.com/stretchr/testify/assert" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/timestamppb" +) + +var testActionMap = map[string]model.Action{ + "read": { + Id: "read", + Name: "Read", + Namespace: model.Namespace{ + Id: "resource-1", + Name: "Resource 1", + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, + "write": { + Id: "write", + Name: "Write", + Namespace: model.Namespace{ + Id: "resource-1", + Name: "Resource 1", + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, + "manage": { + Id: "manage", + Name: "Manage", + Namespace: model.Namespace{ + Id: "resource-1", + Name: "Resource 1", + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, +} + +func TestListActions(t *testing.T) { + t.Parallel() + table := []struct { + title string + mockActionSrc mockActionSrv + req *shieldv1.ListActionsRequest + want *shieldv1.ListActionsResponse + err error + }{ + { + title: "error in Action Service", + mockActionSrc: mockActionSrv{ListActionsFunc: func(ctx context.Context) (actions []model.Action, err error) { + return []model.Action{}, errors.New("some error") + }}, + want: nil, + err: status.Errorf(codes.Internal, internalServerError.Error()), + }, + { + title: "success", + mockActionSrc: mockActionSrv{ListActionsFunc: func(ctx context.Context) (actions []model.Action, err error) { + var testActionList []model.Action + for _, act := range testActionMap { + testActionList = append(testActionList, act) + } + + sort.Slice(testActionList[:], func(i, j int) bool { + return strings.Compare(testActionList[i].Id, testActionList[j].Id) < 1 + }) + return testActionList, nil + }}, + want: &shieldv1.ListActionsResponse{Actions: []*shieldv1.Action{ + { + Id: "manage", + Name: "Manage", + Namespace: &shieldv1.Namespace{ + Id: "resource-1", + Name: "Resource 1", + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + { + Id: "read", + Name: "Read", + Namespace: &shieldv1.Namespace{ + Id: "resource-1", + Name: "Resource 1", + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + { + Id: "write", + Name: "Write", + Namespace: &shieldv1.Namespace{ + Id: "resource-1", + Name: "Resource 1", + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + }}, + err: nil, + }, + } + + for _, tt := range table { + t.Run(tt.title, func(t *testing.T) { + t.Parallel() + + mockDep := Dep{ActionService: tt.mockActionSrc} + resp, err := mockDep.ListActions(context.Background(), tt.req) + + assert.EqualValues(t, tt.want, resp) + assert.EqualValues(t, tt.err, err) + }) + } +} + +func TestCreateAction(t *testing.T) { + t.Parallel() + + table := []struct { + title string + mockActionSrv mockActionSrv + req *shieldv1.CreateActionRequest + want *shieldv1.CreateActionResponse + err error + }{ + { + title: "error in creating action", + mockActionSrv: mockActionSrv{CreateActionFunc: func(ctx context.Context, act model.Action) (model.Action, error) { + return model.Action{}, errors.New("some error") + }}, + req: &shieldv1.CreateActionRequest{Body: &shieldv1.ActionRequestBody{ + Id: "read", + Name: "Read", + NamespaceId: "team", + }}, + want: nil, + err: grpcInternalServerError, + }, + { + title: "success", + mockActionSrv: mockActionSrv{CreateActionFunc: func(ctx context.Context, act model.Action) (model.Action, error) { + return model.Action{ + Id: "read", + Name: "Read", + Namespace: model.Namespace{ + Id: "team", + Name: "Team", + }, + }, nil + }}, + req: &shieldv1.CreateActionRequest{Body: &shieldv1.ActionRequestBody{ + Id: "read", + Name: "Read", + NamespaceId: "team", + }}, + want: &shieldv1.CreateActionResponse{Action: &shieldv1.Action{ + Id: "read", + Name: "Read", + Namespace: &shieldv1.Namespace{ + Id: "team", + Name: "Team", + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }}, + err: nil, + }, + } + + for _, tt := range table { + t.Run(tt.title, func(t *testing.T) { + t.Parallel() + + mockDep := Dep{ActionService: tt.mockActionSrv} + resp, err := mockDep.CreateAction(context.Background(), tt.req) + assert.EqualValues(t, tt.want, resp) + assert.EqualValues(t, tt.err, err) + }) + } +} + +type mockActionSrv struct { + GetActionFunc func(ctx context.Context, id string) (model.Action, error) + CreateActionFunc func(ctx context.Context, act model.Action) (model.Action, error) + ListActionsFunc func(ctx context.Context) ([]model.Action, error) + UpdateActionFunc func(ctx context.Context, id string, act model.Action) (model.Action, error) +} + +func (m mockActionSrv) GetAction(ctx context.Context, id string) (model.Action, error) { + return m.GetActionFunc(ctx, id) +} + +func (m mockActionSrv) ListActions(ctx context.Context) ([]model.Action, error) { + return m.ListActionsFunc(ctx) +} + +func (m mockActionSrv) CreateAction(ctx context.Context, act model.Action) (model.Action, error) { + return m.CreateActionFunc(ctx, act) +} + +func (m mockActionSrv) UpdateAction(ctx context.Context, id string, act model.Action) (model.Action, error) { + return m.UpdateActionFunc(ctx, id, act) +} diff --git a/api/handler/v1/namespace.go b/api/handler/v1/namespace.go new file mode 100644 index 000000000..ccda1e35b --- /dev/null +++ b/api/handler/v1/namespace.go @@ -0,0 +1,125 @@ +package v1 + +import ( + "context" + "errors" + + grpczap "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap" + "github.com/odpf/shield/internal/schema" + "github.com/odpf/shield/model" + shieldv1 "github.com/odpf/shield/proto/v1" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/timestamppb" +) + +type NamespaceService interface { + GetNamespace(ctx context.Context, id string) (model.Namespace, error) + ListNamespaces(ctx context.Context) ([]model.Namespace, error) + CreateNamespace(ctx context.Context, ns model.Namespace) (model.Namespace, error) + UpdateNamespace(ctx context.Context, id string, ns model.Namespace) (model.Namespace, error) +} + +var grpcNamespaceNotFoundErr = status.Errorf(codes.NotFound, "namespace doesn't exist") + +func (v Dep) ListNamespaces(ctx context.Context, request *shieldv1.ListNamespacesRequest) (*shieldv1.ListNamespacesResponse, error) { + logger := grpczap.Extract(ctx) + var namespaces []*shieldv1.Namespace + + nsList, err := v.NamespaceService.ListNamespaces(ctx) + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + for _, ns := range nsList { + nsPB, err := transformNamespaceToPB(ns) + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + namespaces = append(namespaces, &nsPB) + } + + return &shieldv1.ListNamespacesResponse{Namespaces: namespaces}, nil +} + +func (v Dep) CreateNamespace(ctx context.Context, request *shieldv1.CreateNamespaceRequest) (*shieldv1.CreateNamespaceResponse, error) { + logger := grpczap.Extract(ctx) + + newNS, err := v.NamespaceService.CreateNamespace(ctx, model.Namespace{ + Id: request.GetBody().Id, + Name: request.GetBody().Name, + }) + + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + nsPB, err := transformNamespaceToPB(newNS) + + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + return &shieldv1.CreateNamespaceResponse{Namespace: &nsPB}, nil +} + +func (v Dep) GetNamespace(ctx context.Context, request *shieldv1.GetNamespaceRequest) (*shieldv1.GetNamespaceResponse, error) { + logger := grpczap.Extract(ctx) + + fetchedNS, err := v.NamespaceService.GetNamespace(ctx, request.GetId()) + if err != nil { + logger.Error(err.Error()) + switch { + case errors.Is(err, schema.NamespaceDoesntExist): + return nil, grpcNamespaceNotFoundErr + case errors.Is(err, schema.InvalidUUID): + return nil, grpcBadBodyError + default: + return nil, grpcInternalServerError + } + } + + nsPB, err := transformNamespaceToPB(fetchedNS) + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + return &shieldv1.GetNamespaceResponse{Namespace: &nsPB}, nil +} + +func (v Dep) UpdateNamespace(ctx context.Context, request *shieldv1.UpdateNamespaceRequest) (*shieldv1.UpdateNamespaceResponse, error) { + logger := grpczap.Extract(ctx) + + updatedNS, err := v.NamespaceService.UpdateNamespace(ctx, request.GetId(), model.Namespace{ + Id: request.GetId(), + Name: request.GetBody().Name, + }) + + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + nsPB, err := transformNamespaceToPB(updatedNS) + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + return &shieldv1.UpdateNamespaceResponse{Namespace: &nsPB}, nil +} + +func transformNamespaceToPB(ns model.Namespace) (shieldv1.Namespace, error) { + return shieldv1.Namespace{ + Id: ns.Id, + Name: ns.Name, + CreatedAt: timestamppb.New(ns.CreatedAt), + UpdatedAt: timestamppb.New(ns.UpdatedAt), + }, nil +} diff --git a/api/handler/v1/namespace_test.go b/api/handler/v1/namespace_test.go new file mode 100644 index 000000000..b71e63b7e --- /dev/null +++ b/api/handler/v1/namespace_test.go @@ -0,0 +1,184 @@ +package v1 + +import ( + "context" + "errors" + "sort" + "strings" + "testing" + "time" + + "github.com/odpf/shield/model" + shieldv1 "github.com/odpf/shield/proto/v1" + + "github.com/stretchr/testify/assert" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/timestamppb" +) + +var testNsMap = map[string]model.Namespace{ + "team": { + Id: "team", + Name: "Team", + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, + "org": { + Id: "org", + Name: "Org", + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, + "project": { + Id: "project", + Name: "Project", + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, +} + +func TestListNamespaces(t *testing.T) { + t.Parallel() + table := []struct { + title string + mockNamespaceSrv mockNamespaceSrv + req *shieldv1.ListNamespacesRequest + want *shieldv1.ListNamespacesResponse + err error + }{ + { + title: "error in Namespace Service", + mockNamespaceSrv: mockNamespaceSrv{ListNamespacesFunc: func(ctx context.Context) (namespaces []model.Namespace, err error) { + return []model.Namespace{}, errors.New("some error") + }}, + want: nil, + err: status.Errorf(codes.Internal, internalServerError.Error()), + }, + { + title: "success", + mockNamespaceSrv: mockNamespaceSrv{ListNamespacesFunc: func(ctx context.Context) ([]model.Namespace, error) { + var testNSList []model.Namespace + for _, ns := range testNsMap { + testNSList = append(testNSList, ns) + } + sort.Slice(testNSList[:], func(i, j int) bool { + return strings.Compare(testNSList[i].Id, testNSList[j].Id) < 1 + }) + return testNSList, nil + }}, + want: &shieldv1.ListNamespacesResponse{Namespaces: []*shieldv1.Namespace{ + { + Id: "org", + Name: "Org", + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + { + Id: "project", + Name: "Project", + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + { + Id: "team", + Name: "Team", + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + }}, + err: nil, + }, + } + + for _, tt := range table { + t.Run(tt.title, func(t *testing.T) { + t.Parallel() + + mockDep := Dep{NamespaceService: tt.mockNamespaceSrv} + resp, err := mockDep.ListNamespaces(context.Background(), tt.req) + + assert.EqualValues(t, tt.want, resp) + assert.EqualValues(t, tt.err, err) + }) + } +} + +func TestCreateNamespace(t *testing.T) { + t.Parallel() + + table := []struct { + title string + mockNamespaceSrv mockNamespaceSrv + req *shieldv1.CreateNamespaceRequest + want *shieldv1.CreateNamespaceResponse + err error + }{ + { + title: "error in creating namespace", + mockNamespaceSrv: mockNamespaceSrv{CreateNamespaceFunc: func(ctx context.Context, ns model.Namespace) (model.Namespace, error) { + return model.Namespace{}, errors.New("some error") + }}, + req: &shieldv1.CreateNamespaceRequest{Body: &shieldv1.NamespaceRequestBody{ + Id: "team", + Name: "Team", + }}, + want: nil, + err: grpcInternalServerError, + }, + { + title: "success", + mockNamespaceSrv: mockNamespaceSrv{CreateNamespaceFunc: func(ctx context.Context, ns model.Namespace) (model.Namespace, error) { + return model.Namespace{ + Id: "team", + Name: "Team", + }, nil + }}, + req: &shieldv1.CreateNamespaceRequest{Body: &shieldv1.NamespaceRequestBody{ + Id: "team", + Name: "Team", + }}, + want: &shieldv1.CreateNamespaceResponse{Namespace: &shieldv1.Namespace{ + Id: "team", + Name: "Team", + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }}, + err: nil, + }, + } + + for _, tt := range table { + t.Run(tt.title, func(t *testing.T) { + t.Parallel() + + mockDep := Dep{NamespaceService: tt.mockNamespaceSrv} + resp, err := mockDep.CreateNamespace(context.Background(), tt.req) + assert.EqualValues(t, tt.want, resp) + assert.EqualValues(t, tt.err, err) + }) + } +} + +type mockNamespaceSrv struct { + GetNamespaceFunc func(ctx context.Context, id string) (model.Namespace, error) + CreateNamespaceFunc func(ctx context.Context, ns model.Namespace) (model.Namespace, error) + ListNamespacesFunc func(ctx context.Context) ([]model.Namespace, error) + UpdateNamespaceFunc func(ctx context.Context, id string, ns model.Namespace) (model.Namespace, error) +} + +func (m mockNamespaceSrv) GetNamespace(ctx context.Context, id string) (model.Namespace, error) { + return m.GetNamespaceFunc(ctx, id) +} + +func (m mockNamespaceSrv) ListNamespaces(ctx context.Context) ([]model.Namespace, error) { + return m.ListNamespacesFunc(ctx) +} + +func (m mockNamespaceSrv) CreateNamespace(ctx context.Context, ns model.Namespace) (model.Namespace, error) { + return m.CreateNamespaceFunc(ctx, ns) +} + +func (m mockNamespaceSrv) UpdateNamespace(ctx context.Context, id string, ns model.Namespace) (model.Namespace, error) { + return m.UpdateNamespaceFunc(ctx, id, ns) +} diff --git a/api/handler/v1/policy.go b/api/handler/v1/policy.go new file mode 100644 index 000000000..c5f0856fe --- /dev/null +++ b/api/handler/v1/policy.go @@ -0,0 +1,165 @@ +package v1 + +import ( + "context" + "errors" + + grpczap "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/timestamppb" + + "github.com/odpf/shield/internal/schema" + "github.com/odpf/shield/model" + shieldv1 "github.com/odpf/shield/proto/v1" +) + +type PolicyService interface { + GetPolicy(ctx context.Context, id string) (model.Policy, error) + ListPolicies(ctx context.Context) ([]model.Policy, error) + CreatePolicy(ctx context.Context, policy model.Policy) ([]model.Policy, error) + UpdatePolicy(ctx context.Context, id string, policy model.Policy) ([]model.Policy, error) +} + +var grpcPolicyNotFoundErr = status.Errorf(codes.NotFound, "policy doesn't exist") + +func (v Dep) ListPolicies(ctx context.Context, request *shieldv1.ListPoliciesRequest) (*shieldv1.ListPoliciesResponse, error) { + logger := grpczap.Extract(ctx) + var policies []*shieldv1.Policy + + policyList, err := v.PolicyService.ListPolicies(ctx) + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + for _, p := range policyList { + policyPB, err := transformPolicyToPB(p) + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + policies = append(policies, &policyPB) + } + + return &shieldv1.ListPoliciesResponse{Policies: policies}, nil +} + +func (v Dep) CreatePolicy(ctx context.Context, request *shieldv1.CreatePolicyRequest) (*shieldv1.CreatePolicyResponse, error) { + logger := grpczap.Extract(ctx) + var policies []*shieldv1.Policy + + newPolicies, err := v.PolicyService.CreatePolicy(ctx, model.Policy{ + RoleId: request.GetBody().RoleId, + NamespaceId: request.GetBody().NamespaceId, + ActionId: request.GetBody().ActionId, + }) + + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + for _, p := range newPolicies { + policyPB, err := transformPolicyToPB(p) + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + policies = append(policies, &policyPB) + } + + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + return &shieldv1.CreatePolicyResponse{Policies: policies}, nil +} + +func (v Dep) GetPolicy(ctx context.Context, request *shieldv1.GetPolicyRequest) (*shieldv1.GetPolicyResponse, error) { + logger := grpczap.Extract(ctx) + + fetchedPolicy, err := v.PolicyService.GetPolicy(ctx, request.GetId()) + if err != nil { + logger.Error(err.Error()) + switch { + case errors.Is(err, schema.PolicyDoesntExist): + return nil, grpcPolicyNotFoundErr + case errors.Is(err, schema.InvalidUUID): + return nil, grpcBadBodyError + default: + return nil, grpcInternalServerError + } + } + + policyPB, err := transformPolicyToPB(fetchedPolicy) + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + return &shieldv1.GetPolicyResponse{Policy: &policyPB}, nil +} + +func (v Dep) UpdatePolicy(ctx context.Context, request *shieldv1.UpdatePolicyRequest) (*shieldv1.UpdatePolicyResponse, error) { + logger := grpczap.Extract(ctx) + var policies []*shieldv1.Policy + + updatedPolices, err := v.PolicyService.UpdatePolicy(ctx, request.GetId(), model.Policy{ + RoleId: request.GetBody().RoleId, + NamespaceId: request.GetBody().NamespaceId, + ActionId: request.GetBody().ActionId, + }) + + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + for _, p := range updatedPolices { + policyPB, err := transformPolicyToPB(p) + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + + policies = append(policies, &policyPB) + } + + if err != nil { + logger.Error(err.Error()) + return nil, grpcInternalServerError + } + return &shieldv1.UpdatePolicyResponse{Policies: policies}, nil +} + +func transformPolicyToPB(policy model.Policy) (shieldv1.Policy, error) { + role, err := transformRoleToPB(policy.Role) + if err != nil { + return shieldv1.Policy{}, err + } + + action, err := transformActionToPB(policy.Action) + + if err != nil { + return shieldv1.Policy{}, err + } + + namespace, err := transformNamespaceToPB(policy.Namespace) + + if err != nil { + return shieldv1.Policy{}, err + } + + return shieldv1.Policy{ + Id: policy.Id, + Role: &role, + Action: &action, + Namespace: &namespace, + CreatedAt: timestamppb.New(policy.CreatedAt), + UpdatedAt: timestamppb.New(policy.UpdatedAt), + }, nil +} diff --git a/api/handler/v1/policy_test.go b/api/handler/v1/policy_test.go new file mode 100644 index 000000000..aae3dbf8f --- /dev/null +++ b/api/handler/v1/policy_test.go @@ -0,0 +1,276 @@ +package v1 + +import ( + "context" + "errors" + "testing" + "time" + + "github.com/odpf/shield/model" + shieldv1 "github.com/odpf/shield/proto/v1" + + "github.com/stretchr/testify/assert" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/structpb" + "google.golang.org/protobuf/types/known/timestamppb" +) + +var testPolicyMap = map[string]model.Policy{ + "test": { + Id: "test", + Action: model.Action{ + Id: "read", + Name: "Read", + Namespace: model.Namespace{ + Id: "resource-1", + Name: "Resource 1", + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, + Namespace: model.Namespace{ + Id: "resource-1", + Name: "Resource 1", + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, + Role: model.Role{ + Id: "reader", + Name: "Reader", + Metadata: map[string]string{}, + Namespace: model.Namespace{ + Id: "resource-1", + Name: "Resource 1", + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, + }, + }, +} + +func TestListPolicies(t *testing.T) { + t.Parallel() + table := []struct { + title string + MockPolicySrv mockPolicySrv + req *shieldv1.ListPoliciesRequest + want *shieldv1.ListPoliciesResponse + err error + }{ + { + title: "error in Policy Service", + MockPolicySrv: mockPolicySrv{ListPoliciesFunc: func(ctx context.Context) (actions []model.Policy, err error) { + return []model.Policy{}, errors.New("some error") + }}, + want: nil, + err: status.Errorf(codes.Internal, internalServerError.Error()), + }, + { + title: "success", + MockPolicySrv: mockPolicySrv{ListPoliciesFunc: func(ctx context.Context) (actions []model.Policy, err error) { + var testPoliciesList []model.Policy + for _, p := range testPolicyMap { + testPoliciesList = append(testPoliciesList, p) + } + return testPoliciesList, nil + }}, + want: &shieldv1.ListPoliciesResponse{Policies: []*shieldv1.Policy{ + { + Id: "test", + Action: &shieldv1.Action{ + Id: "read", + Name: "Read", + Namespace: &shieldv1.Namespace{ + Id: "resource-1", + Name: "Resource 1", + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + Namespace: &shieldv1.Namespace{ + Id: "resource-1", + Name: "Resource 1", + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + Role: &shieldv1.Role{ + Id: "reader", + Name: "Reader", + Metadata: &structpb.Struct{Fields: map[string]*structpb.Value{}}, + Namespace: &shieldv1.Namespace{ + Id: "resource-1", + Name: "Resource 1", + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + }}, + err: nil, + }, + } + + for _, tt := range table { + t.Run(tt.title, func(t *testing.T) { + t.Parallel() + + mockDep := Dep{PolicyService: tt.MockPolicySrv} + resp, err := mockDep.ListPolicies(context.Background(), tt.req) + + assert.EqualValues(t, tt.want, resp) + assert.EqualValues(t, tt.err, err) + }) + } +} + +func TestCreatePolicy(t *testing.T) { + t.Parallel() + + table := []struct { + title string + mockPolicySrv mockPolicySrv + req *shieldv1.CreatePolicyRequest + want *shieldv1.CreatePolicyResponse + err error + }{ + { + title: "error in creating policy", + mockPolicySrv: mockPolicySrv{CreatePolicyFunc: func(ctx context.Context, policy model.Policy) ([]model.Policy, error) { + return []model.Policy{}, errors.New("some error") + }}, + req: &shieldv1.CreatePolicyRequest{Body: &shieldv1.PolicyRequestBody{ + NamespaceId: "team", + RoleId: "Admin", + ActionId: "add-member", + }}, + want: nil, + err: grpcInternalServerError, + }, + { + title: "success", + mockPolicySrv: mockPolicySrv{CreatePolicyFunc: func(ctx context.Context, policy model.Policy) ([]model.Policy, error) { + return []model.Policy{ + { + Id: "test", + Action: model.Action{ + Id: "read", + Name: "Read", + Namespace: model.Namespace{ + Id: "resource-1", + Name: "Resource 1", + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, + Namespace: model.Namespace{ + Id: "resource-1", + Name: "Resource 1", + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, + Role: model.Role{ + Id: "reader", + Name: "Reader", + Metadata: map[string]string{}, + Namespace: model.Namespace{ + Id: "resource-1", + Name: "Resource 1", + CreatedAt: time.Time{}, + UpdatedAt: time.Time{}, + }, + }, + }, + }, nil + }}, + req: &shieldv1.CreatePolicyRequest{Body: &shieldv1.PolicyRequestBody{ + ActionId: "read", + NamespaceId: "resource-1", + RoleId: "reader", + }}, + want: &shieldv1.CreatePolicyResponse{Policies: []*shieldv1.Policy{ + { + Id: "test", + Action: &shieldv1.Action{ + Id: "read", + Name: "Read", + Namespace: &shieldv1.Namespace{ + Id: "resource-1", + Name: "Resource 1", + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + Namespace: &shieldv1.Namespace{ + Id: "resource-1", + Name: "Resource 1", + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + Role: &shieldv1.Role{ + Id: "reader", + Name: "Reader", + Metadata: &structpb.Struct{Fields: map[string]*structpb.Value{}}, + Namespace: &shieldv1.Namespace{ + Id: "resource-1", + Name: "Resource 1", + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + CreatedAt: timestamppb.New(time.Time{}), + UpdatedAt: timestamppb.New(time.Time{}), + }, + }}, + err: nil, + }, + } + + for _, tt := range table { + t.Run(tt.title, func(t *testing.T) { + t.Parallel() + + mockDep := Dep{PolicyService: tt.mockPolicySrv} + resp, err := mockDep.CreatePolicy(context.Background(), tt.req) + assert.EqualValues(t, tt.want, resp) + assert.EqualValues(t, tt.err, err) + }) + } +} + +type mockPolicySrv struct { + GetPolicyFunc func(ctx context.Context, id string) (model.Policy, error) + CreatePolicyFunc func(ctx context.Context, policy model.Policy) ([]model.Policy, error) + ListPoliciesFunc func(ctx context.Context) ([]model.Policy, error) + UpdatePolicyFunc func(ctx context.Context, id string, policy model.Policy) ([]model.Policy, error) +} + +func (m mockPolicySrv) GetPolicy(ctx context.Context, id string) (model.Policy, error) { + return m.GetPolicyFunc(ctx, id) +} + +func (m mockPolicySrv) ListPolicies(ctx context.Context) ([]model.Policy, error) { + return m.ListPoliciesFunc(ctx) +} + +func (m mockPolicySrv) CreatePolicy(ctx context.Context, policy model.Policy) ([]model.Policy, error) { + return m.CreatePolicyFunc(ctx, policy) +} + +func (m mockPolicySrv) UpdatePolicy(ctx context.Context, id string, policy model.Policy) ([]model.Policy, error) { + return m.UpdatePolicyFunc(ctx, id, policy) +} diff --git a/api/handler/v1/role.go b/api/handler/v1/role.go index e45b7ad21..751ed12af 100644 --- a/api/handler/v1/role.go +++ b/api/handler/v1/role.go @@ -5,10 +5,8 @@ import ( "errors" grpczap "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap" - "github.com/odpf/shield/internal/roles" "github.com/odpf/shield/model" - "google.golang.org/protobuf/types/known/structpb" "google.golang.org/protobuf/types/known/timestamppb" @@ -54,11 +52,11 @@ func (v Dep) CreateRole(ctx context.Context, request *shieldv1.CreateRoleRequest } newRole, err := v.RoleService.Create(ctx, model.Role{ - Id: request.GetBody().Id, - Name: request.GetBody().Name, - Types: request.GetBody().Types, - Namespace: request.GetBody().NamespaceId, - Metadata: metaDataMap, + Id: request.GetBody().Id, + Name: request.GetBody().Name, + Types: request.GetBody().Types, + NamespaceId: request.GetBody().NamespaceId, + Metadata: metaDataMap, }) if err != nil { logger.Error(err.Error()) @@ -108,11 +106,11 @@ func (v Dep) UpdateRole(ctx context.Context, request *shieldv1.UpdateRoleRequest } updatedRole, err := v.RoleService.Update(ctx, model.Role{ - Id: request.GetBody().Id, - Name: request.GetBody().Name, - Types: request.GetBody().Types, - Namespace: request.GetBody().NamespaceId, - Metadata: metaDataMap, + Id: request.GetBody().Id, + Name: request.GetBody().Name, + Types: request.GetBody().Types, + NamespaceId: request.GetBody().NamespaceId, + Metadata: metaDataMap, }) if err != nil { logger.Error(err.Error()) @@ -134,9 +132,16 @@ func transformRoleToPB(from model.Role) (shieldv1.Role, error) { return shieldv1.Role{}, err } + namespace, err := transformNamespaceToPB(from.Namespace) + if err != nil { + return shieldv1.Role{}, err + } + return shieldv1.Role{ - Id: from.Id, - Name: from.Name, + Id: from.Id, + Name: from.Name, + Types: from.Types, + Namespace: &namespace, //Tags: nil, //Actions: nil, Metadata: metaData, diff --git a/api/handler/v1/v1.go b/api/handler/v1/v1.go index 4ab153efa..4aef4fc41 100644 --- a/api/handler/v1/v1.go +++ b/api/handler/v1/v1.go @@ -15,7 +15,10 @@ type Dep struct { ProjectService ProjectService GroupService GroupService RoleService RoleService + PolicyService PolicyService UserService UserService + NamespaceService NamespaceService + ActionService ActionService IdentityProxyHeader string } diff --git a/buf.gen.yaml b/buf.gen.yaml index e34173cd9..2984c789f 100755 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -8,7 +8,7 @@ plugins: - remote: "buf.build/library/plugins/go-grpc:v1.1.0-2" out: "proto" opt: "paths=source_relative" - - name: "validate" + - remote: buf.build/odpf/plugins/validate out: "proto" opt: "paths=source_relative,lang=go" - remote: "buf.build/grpc-ecosystem/plugins/grpc-gateway:v2.5.0-1" diff --git a/cmd/serve.go b/cmd/serve.go index 34bafdaeb..ef5d4e00f 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -15,10 +15,12 @@ import ( "github.com/odpf/shield/config" "github.com/odpf/shield/hook" authz_hook "github.com/odpf/shield/hook/authz" + "github.com/odpf/shield/internal/authz" "github.com/odpf/shield/internal/group" "github.com/odpf/shield/internal/org" "github.com/odpf/shield/internal/project" "github.com/odpf/shield/internal/roles" + "github.com/odpf/shield/internal/schema" "github.com/odpf/shield/internal/user" "github.com/odpf/shield/pkg/sql" "github.com/odpf/shield/proxy" @@ -114,7 +116,7 @@ func startServer(logger log.Logger, appConfig *config.Shield, err error, ctx con panic(err) } - handler.Register(ctx, s, gw, apiDependencies(db, appConfig)) + handler.Register(ctx, s, gw, apiDependencies(db, appConfig, logger)) go s.Serve() @@ -196,8 +198,9 @@ func healthCheck() http.HandlerFunc { } } -func apiDependencies(db *sql.SQL, appConfig *config.Shield) handler.Deps { +func apiDependencies(db *sql.SQL, appConfig *config.Shield, logger log.Logger) handler.Deps { serviceStore := postgres.NewStore(db) + authzService := authz.New(appConfig, logger) dependencies := handler.Deps{ V1: v1.Dep{ @@ -216,6 +219,10 @@ func apiDependencies(db *sql.SQL, appConfig *config.Shield) handler.Deps { GroupService: group.Service{ Store: serviceStore, }, + PolicyService: schema.Service{ + Store: serviceStore, + Authz: authzService, + }, IdentityProxyHeader: appConfig.App.IdentityProxyHeader, }, } diff --git a/config/config.go b/config/config.go index e06f18223..efcdbe879 100644 --- a/config/config.go +++ b/config/config.go @@ -12,12 +12,13 @@ import ( type Shield struct { // configuration version - Version int `yaml:"version"` - Proxy ProxyConfig `yaml:"proxy"` - Log LogConfig `yaml:"log"` - NewRelic NewRelic `yaml:"new_relic"` - App Service `yaml:"app"` - DB DBConfig `yaml:"db"` + Version int `yaml:"version"` + Proxy ProxyConfig `yaml:"proxy"` + Log LogConfig `yaml:"log"` + NewRelic NewRelic `yaml:"new_relic"` + App Service `yaml:"app"` + DB DBConfig `yaml:"db"` + SpiceDB SpiceDBConfig `yaml:"spice_db"` } type LogConfig struct { @@ -32,6 +33,12 @@ type ProxyConfig struct { Services []Service `yaml:"services" mapstructure:"services"` } +type SpiceDBConfig struct { + Host string `yaml:"host"` + Port string `yaml:"port" default:"50051"` + PreSharedKey string `yaml:"pre_shared_key"` +} + type Service struct { // port to listen on Port int `yaml:"port" mapstructure:"port" default:"8080"` diff --git a/docker-compose.yml b/docker-compose.yml index 873e76e48..f67fbce9a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,23 @@ services: interval: 30s timeout: 30s retries: 3 + + pg2: + image: "postgres:12" + environment: + POSTGRES_USER: "spicedb" + POSTGRES_DB: "spicedb" + POSTGRES_HOST_AUTH_METHOD: "trust" + volumes: + - ./temp/pgdata2:/var/lib/postgresql/data + ports: + - "5431:5432" + healthcheck: + test: ["CMD-SHELL", "pg_isready -U spicedb"] + interval: 30s + timeout: 30s + retries: 3 + shield-migrate: build: context: . @@ -27,6 +44,9 @@ services: environment: - SHIELD_DB_DRIVER=postgres - SHIELD_DB_URL=postgres://shield:@pg:5432/shield?sslmode=disable + - SHIELD_SPICEDB_HOST=spicedb + - SHIELD_SPICEDB_PRE_SHARED_KEY=shield; + shield: build: context: . @@ -41,4 +61,28 @@ services: condition: service_completed_successfully environment: - SHIELD_DB_DRIVER=postgres - - SHIELD_DB_URL=postgres://shield:@pg:5432/shield?sslmode=disable \ No newline at end of file + - SHIELD_DB_URL=postgres://shield:@pg:5432/shield?sslmode=disable + + spicedb-migration: + image: quay.io/authzed/spicedb:v1.0.0 + command: spicedb migrate head --datastore-engine postgres --datastore-conn-uri postgres://spicedb:@pg2:5432/spicedb?sslmode=disable + restart: on-failure + depends_on: + pg2: + condition: service_healthy + + spicedb: + image: quay.io/authzed/spicedb:v1.0.0 + ports: + - "8080:8080" + - "50051:50051" + - "50053:50053" + command: + spicedb serve --grpc-preshared-key "shield" --grpc-no-tls --datastore-engine postgres + --datastore-conn-uri postgres://spicedb:@pg2:5432/spicedb?sslmode=disable + restart: on-failure + depends_on: + pg2: + condition: service_healthy + spicedb-migration: + condition: service_completed_successfully \ No newline at end of file diff --git a/go.mod b/go.mod index 05e41f2a5..432e44f16 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,8 @@ require ( cloud.google.com/go/storage v1.18.2 // indirect github.com/abbot/go-http-auth v0.4.0 github.com/authzed/authzed-go v0.3.0 + github.com/authzed/grpcutil v0.0.0-20211020204402-aba1876830e6 + github.com/authzed/spicedb v1.1.0 github.com/envoyproxy/protoc-gen-validate v0.6.1 github.com/ghodss/yaml v1.0.0 github.com/golang-migrate/migrate/v4 v4.15.1 @@ -15,6 +17,7 @@ require ( github.com/grpc-ecosystem/grpc-gateway/v2 v2.6.0 github.com/jhump/protoreflect v1.9.0 github.com/jmoiron/sqlx v1.3.4 + github.com/lib/pq v1.10.4 github.com/mitchellh/mapstructure v1.4.2 github.com/newrelic/go-agent v3.15.0+incompatible github.com/odpf/salt v0.0.0-20211209124356-60f6178cfd80 @@ -28,9 +31,9 @@ require ( github.com/tidwall/gjson v1.9.1 go.uber.org/zap v1.19.0 gocloud.dev v0.24.0 - golang.org/x/net v0.0.0-20211013171255-e13a2654a71e + golang.org/x/net v0.0.0-20211020060615-d418f374d309 golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1 - google.golang.org/genproto v0.0.0-20211016002631-37fc39342514 + google.golang.org/genproto v0.0.0-20211020151524-b7c3a969101a google.golang.org/grpc v1.41.0 google.golang.org/protobuf v1.27.1 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b diff --git a/go.sum b/go.sum index c4ec2cbe3..45b28f184 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,6 @@ bazil.org/fuse v0.0.0-20160811212531-371fbbdaa898/go.mod h1:Xbm+BRKSBEpa4q4hTSxohYNQpsxXPbPry4JJWOB3LB8= bazil.org/fuse v0.0.0-20180421153158-65cc252bf669/go.mod h1:Xbm+BRKSBEpa4q4hTSxohYNQpsxXPbPry4JJWOB3LB8= +bazil.org/fuse v0.0.0-20200407214033-5883e5a4b512/go.mod h1:FbcW6z/2VytnFDhZfumh8Ss8zxHE6qpMP5sHTRe0EaM= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= @@ -113,6 +114,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ClickHouse/clickhouse-go v1.4.3/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI= github.com/GoogleCloudPlatform/cloudsql-proxy v1.24.0/go.mod h1:3tx938GhY4FC+E1KT/jNjDw7Z5qxAEtIiERJ2sXjnII= +github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= +github.com/Masterminds/squirrel v1.5.0/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10= github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw= @@ -134,6 +137,7 @@ github.com/Microsoft/hcsshim v0.8.21/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwT github.com/Microsoft/hcsshim/test v0.0.0-20201218223536-d3e5debf77da/go.mod h1:5hlzMzRKMLyo42nCZ9oml8AdTlq/0cvIaBv6tK1RehU= github.com/Microsoft/hcsshim/test v0.0.0-20210227013316-43a75bb4edd3/go.mod h1:mw7qgWloBUl75W/gVH3cQszUg1+gUITj7D6NY7ywVnY= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= +github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= @@ -151,6 +155,7 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/alecthomas/units v0.0.0-20210208195552-ff826a37aa15/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE= github.com/alexflint/go-filemutex v0.0.0-20171022225611-72bdc8eae2ae/go.mod h1:CgnQgUtFrFz9mxFNtED3jI5tLDjKlOM+oUF/sTk6ps0= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/arrow/go/arrow v0.0.0-20210818145353-234c94e4ce64/go.mod h1:2qMFB56yOP3KzkB3PbYZ4AlUFg3a88F67TIx5lB/WwY= @@ -164,12 +169,18 @@ github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:l github.com/authzed/authzed-go v0.3.0 h1:m5eqPX9p1mhdbd8jrFhNORx5PvnHQ2e1bISweEwja+E= github.com/authzed/authzed-go v0.3.0/go.mod h1:bsUniBRroq4l5WZMYLO+T9osQa/P2qMwZ+Af8zoJK8Y= github.com/authzed/grpcutil v0.0.0-20210913124023-cad23ae5a9e8/go.mod h1:HwO/KbRU3fWXEYHE96kvXnwxzi97tkXD1hfi5UaZ71Y= +github.com/authzed/grpcutil v0.0.0-20211020204402-aba1876830e6 h1:izP/rEris51ZmomXb5J0ShyJKqsxTfVKDRnJz0QGbgg= +github.com/authzed/grpcutil v0.0.0-20211020204402-aba1876830e6/go.mod h1:rqjY3zyK/YP7NID9+B2BdIRRkvnK+cdf9/qya/zaFZE= +github.com/authzed/spicedb v1.1.0 h1:zZbW/XJabDD6viJnIgFNQxOm88vRkD5F2vvaKFNuzFI= +github.com/authzed/spicedb v1.1.0/go.mod h1:DcBEu6wVyYNp8CtXH4+5DUo46Y6+IcWNiHZEPnlr7hE= github.com/aws/aws-sdk-go v1.15.11/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= github.com/aws/aws-sdk-go v1.15.27/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= +github.com/aws/aws-sdk-go v1.17.4/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.17.7/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.37.0/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= -github.com/aws/aws-sdk-go v1.40.34 h1:SBYmodndE2d4AYucuuJnOXk4MD1SFbucoIdpwKVKeSA= github.com/aws/aws-sdk-go v1.40.34/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= +github.com/aws/aws-sdk-go v1.40.53 h1:wi4UAslOQ1HfF2NjnIwI6st8n7sQg7shUUNLkaCgIpc= +github.com/aws/aws-sdk-go v1.40.53/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= github.com/aws/aws-sdk-go-v2 v1.8.0/go.mod h1:xEFuWz+3TYdlPRuo+CqATbeDWIWyaT5uAPwPaWtgse0= github.com/aws/aws-sdk-go-v2 v1.9.0/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= github.com/aws/aws-sdk-go-v2 v1.9.2 h1:dUFQcMNZMLON4BOe273pl0filK9RqyQMhCK/6xssL6s= @@ -228,6 +239,7 @@ github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCS github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4= +github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= github.com/blang/semver v3.1.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= @@ -239,8 +251,11 @@ github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8n github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50= github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= github.com/cenkalti/backoff/v4 v4.0.2/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8Bog/87DQnVg= +github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d h1:S2NE3iHSwP0XV47EEXL8mWmRdEfGscSJ+7EgePNgt0s= +github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/charmbracelet/glamour v0.3.0/go.mod h1:TzF0koPZhqq0YVBNL100cPHznAAjVj7fksX2RInwjGw= @@ -300,11 +315,13 @@ github.com/containerd/containerd v1.5.7 h1:rQyoYtj4KddB3bxG6SAqd4+08gePNyJjRqvOI github.com/containerd/containerd v1.5.7/go.mod h1:gyvv6+ugqY25TiXxcZC3L5yOeYgEw0QMhscqVp1AR9c= github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= +github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/containerd/continuity v0.0.0-20191127005431-f65d91d395eb/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/containerd/continuity v0.0.0-20200710164510-efbc4488d8fe/go.mod h1:cECdGN1O8G9bgKTlLhuPJimka6Xb/Gg7vYzCTNVxhvo= github.com/containerd/continuity v0.0.0-20201208142359-180525291bb7/go.mod h1:kR3BEg7bDFaEddKm54WSmrol1fKWDU1nKYkgrcgZT7Y= github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e/go.mod h1:EXlVlkqNba9rJe3j7w3Xa924itAMLgZH4UD/Q4PExuQ= github.com/containerd/continuity v0.1.0/go.mod h1:ICJu0PwR54nI0yPEnJ6jcS+J7CZAUXrLh8lPo2knzsM= +github.com/containerd/continuity v0.2.1/go.mod h1:wCYX+dRqZdImhGucXOqTQn05AhX6EUDaGEMUzTFFpLg= github.com/containerd/fifo v0.0.0-20180307165137-3d5202aec260/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI= github.com/containerd/fifo v0.0.0-20190226154929-a9fb20d87448/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI= github.com/containerd/fifo v0.0.0-20200410184934-f15a3290365b/go.mod h1:jPQ2IAeZRCYxpS/Cm1495vGFww6ecHmMk1YJH2Q5ln0= @@ -349,6 +366,7 @@ github.com/containers/ocicrypt v1.1.0/go.mod h1:b8AOe0YR67uU8OqfVNcznfFpAzu3rdgU github.com/containers/ocicrypt v1.1.1/go.mod h1:Dm55fwWm1YZAjYRaJ94z2mfZikIyIN4B0oB3dj3jFxY= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-iptables v0.4.5/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU= github.com/coreos/go-iptables v0.5.0/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU= github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= @@ -381,8 +399,10 @@ github.com/denisenkom/go-mssqldb v0.9.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27N github.com/denisenkom/go-mssqldb v0.10.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= github.com/devigned/tab v0.1.1/go.mod h1:XG9mPq0dFghrYvoBF3xdRrJzSTX1b7IQrvaL9mzjeJY= +github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug= github.com/dgrijalva/jwt-go v0.0.0-20170104182250-a601269ab70c/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dhui/dktest v0.3.7 h1:jWjWgHAPDAdqgUr7lAsB3bqB2DKWC3OaA+isfekjRew= github.com/dhui/dktest v0.3.7/go.mod h1:nYMOkafiA07WchSwKnKFUSbGMb2hMm5DrCGiXYG6gwM= @@ -390,10 +410,13 @@ github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQ github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/j0mACtrfE= github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= +github.com/docker/cli v20.10.8+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v20.10.9+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v0.0.0-20190905152932-14b96e55d84c/go.mod h1:0+TTO4EOBfRPhZXAeF1Vu+W3hHZ8eLp8PgKVZlcvtFY= github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/docker v20.10.7+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v20.10.9+incompatible h1:JlsVnETOjM2RLQa0Cc1XCIspUdXW3Zenq9P54uXBm6k= github.com/docker/docker v20.10.9+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= @@ -413,6 +436,8 @@ github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= +github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= +github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -427,6 +452,9 @@ github.com/envoyproxy/protoc-gen-validate v0.6.1/go.mod h1:txg5va2Qkip90uYoSKH+n github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/set v0.2.1/go.mod h1:+RKtMCH+favT2+3YecHGxcc0b4KyVWA1QWWJUs4E0CI= +github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= @@ -621,6 +649,7 @@ github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210715191844-86eeefc3e471/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/subcommands v1.0.1/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -636,7 +665,6 @@ github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pf github.com/googleapis/gax-go/v2 v2.1.1 h1:dp3bWCh+PPO1zjRRiCSczJav13sBvG4UhNyVTa1KqdU= github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= github.com/googleapis/gnostic v0.4.1/go.mod h1:LRhVm6pbyptWbWbuZ38d1eyptfvIytN3ir6b65WBswg= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c= @@ -656,6 +684,9 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmg github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= +github.com/grpc-ecosystem/go-grpc-middleware/providers/zerolog/v2 v2.0.0-rc.2/go.mod h1:BL7w7qd2l/j9jgY6WMhYutfOFQc0I8RTVwtjpnAMoTM= +github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0-20200501113911-9a95f0fdbfea/go.mod h1:GugMBs30ZSAkckqXEAIEGyYdDH6EgqowG8ppA3Zt+AY= +github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0-rc.2/go.mod h1:GhphxcdlaRyAuBSvo6rV71BvQcvB/vuX8ugCyybuS2k= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= @@ -674,6 +705,8 @@ github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-immutable-radix v1.3.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-memdb v1.3.2/go.mod h1:Mluclgwib3R93Hk5fxEfiRhB+6Dar64wWh71LpNSe3g= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v0.0.0-20161216184304-ed905158d874/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= @@ -689,6 +722,7 @@ github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09 github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= 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= @@ -709,6 +743,7 @@ github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/influxdata/tdigest v0.0.1/go.mod h1:Z0kXnxzbTC2qrx4NaIzYkE1k66+6oEDQTvL95hQFh5Y= github.com/j-keck/arping v0.0.0-20160618110441-2cf9dc699c56/go.mod h1:ymszkNOg6tORTn+6F6j+Jc8TOr5osrynvN6ivFWZ2GA= github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= @@ -720,9 +755,14 @@ github.com/jackc/pgconn v1.4.0/go.mod h1:Y2O3ZDF0q4mMacyWV3AstPJpeHXWGEetiFttmq5 github.com/jackc/pgconn v1.5.0/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI= github.com/jackc/pgconn v1.5.1-0.20200601181101-fa742c524853/go.mod h1:QeD3lBfpTFe8WUnPZWN5KY/mB8FGMIYRdd8P8Jr0fAI= github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= +github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= +github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= +github.com/jackc/pgconn v1.10.0/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= github.com/jackc/pgerrcode v0.0.0-20201024163028-a0d42d470451/go.mod h1:a/s9Lp5W7n/DD0VrVoyJ00FbP2ytTPDVOivvn2bMlds= github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= +github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c= +github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78= github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA= @@ -732,6 +772,7 @@ github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1: github.com/jackc/pgproto3/v2 v2.0.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgproto3/v2 v2.0.7/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgservicefile v0.0.0-20200307190119-3430c5407db8/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= @@ -741,6 +782,8 @@ github.com/jackc/pgtype v1.2.0/go.mod h1:5m2OfMh1wTK7x+Fk952IDmI4nw3nPrvtQdM0ZT4 github.com/jackc/pgtype v1.3.1-0.20200510190516-8cd94a14c75a/go.mod h1:vaogEUkALtxZMCH411K+tKzNpwzCKU+AnPzBKZ+I+Po= github.com/jackc/pgtype v1.3.1-0.20200606141011-f6355165a91c/go.mod h1:cvk9Bgu/VzJ9/lxTO5R5sf80p0DiucVtN7ZxvaC4GmQ= github.com/jackc/pgtype v1.6.2/go.mod h1:JCULISAZBFGrHaOXIIFiyfzW5VY0GRitRr8NeJsrdig= +github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= +github.com/jackc/pgtype v1.8.1/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= @@ -748,6 +791,8 @@ github.com/jackc/pgx/v4 v4.5.0/go.mod h1:EpAKPLdnTorwmPUUsqrPxy5fphV18j9q3wrfRXg github.com/jackc/pgx/v4 v4.6.1-0.20200510190926-94ba730bb1e9/go.mod h1:t3/cdRQl6fOLDxqtlyhe9UWgfIi9R8+8v8GKV5TRA/o= github.com/jackc/pgx/v4 v4.6.1-0.20200606145419-4e5062306904/go.mod h1:ZDaNWkt9sW1JMiNn0kdYBaLelIhw7Pg4qd+Vk6tw7Hg= github.com/jackc/pgx/v4 v4.10.1/go.mod h1:QlrWebbs3kqEZPHCTGyxecvzG6tvIsYu+A5b1raylkA= +github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= +github.com/jackc/pgx/v4 v4.13.0/go.mod h1:9P4X524sErlaxj0XSGZk7s+LD0eOyu1ZDUrrpznYDF0= github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= @@ -769,6 +814,7 @@ github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhB github.com/jmoiron/sqlx v1.3.1/go.mod h1:2BljVx/86SuTyjE+aPYlHCTNvZrnJXghYGpNiXLBMCQ= github.com/jmoiron/sqlx v1.3.4 h1:wv+0IJZfL5z0uZoUjlpKgHkgaFSYD+r9CfrXjEXsO7w= github.com/jmoiron/sqlx v1.3.4/go.mod h1:2BljVx/86SuTyjE+aPYlHCTNvZrnJXghYGpNiXLBMCQ= +github.com/johannesboyne/gofakes3 v0.0.0-20210608054100-92d5d4af5fde/go.mod h1:LIAXxPvcUXwOcTIj9LSNSUpE9/eMHalTWxsP/kmWxQI= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= @@ -779,13 +825,16 @@ github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/ github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= +github.com/jwangsadinata/go-multimap v0.0.0-20190620162914-c29f3d7f33b6/go.mod h1:CEusGbCRDFcHX9EgEhPsgJX33kpp9CfSFRBAoSGOems= +github.com/jzelinskie/cobrautil v0.0.5/go.mod h1:svcV0pfy8vH8O+IpYaJgWw70PJuAtvoKXsIELG8Krzs= github.com/jzelinskie/stringz v0.0.0-20210414224931-d6a8ce844a70/go.mod h1:hHYbgxJuNLRw91CmpuFsYEOyQqpDVFg8pvEh23vy4P0= +github.com/jzelinskie/stringz v0.0.1 h1:IahR+y8ct2nyj7B6i8UtFsGFj4ex1SX27iKFYsAheLk= +github.com/jzelinskie/stringz v0.0.1/go.mod h1:hHYbgxJuNLRw91CmpuFsYEOyQqpDVFg8pvEh23vy4P0= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= github.com/k0kubun/pp v2.3.0+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg= github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8= @@ -819,18 +868,24 @@ github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/ktrysmt/go-bitbucket v0.6.4/go.mod h1:9u0v3hsd2rqCHRIpbir1oP7F58uo5dq19sBYvuMoyQ4= +github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o= +github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/lib/pq v0.0.0-20180327071824-d34b9ff171c2/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8= github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.3/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk= +github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/lyft/protoc-gen-star v0.5.1/go.mod h1:9toiA3cC7z5uVbODF7kEQ91Xn7XNFkVUl+SrEe+ZORU= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -845,6 +900,7 @@ github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcncea github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-ieproxy v0.0.1 h1:qiyop7gCflfhwCzGyeT0gro3sF9AIg9HU98JORTkqfI= github.com/mattn/go-ieproxy v0.0.1/go.mod h1:pYabZ6IHcRpFh7vIaLfK7rdcWgFEb3SFJ6/gNWuh88E= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= @@ -857,6 +913,7 @@ github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcME github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= @@ -885,7 +942,6 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F github.com/mitchellh/mapstructure v0.0.0-20180220230111-00c29f56e238/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.2 h1:6h7AQ0yhTcIsmFmnAwQls75jp2Gzs4iB8W7pjMO+rqo= github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= @@ -895,6 +951,7 @@ github.com/moby/sys/mountinfo v0.4.0/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2J github.com/moby/sys/mountinfo v0.4.1/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A= github.com/moby/sys/symlink v0.1.0/go.mod h1:GGDODQmbFOjFsXvfLVn3+ZRxkch54RkSiGqsZeMYowQ= github.com/moby/term v0.0.0-20200312100748-672ec06f55cd/go.mod h1:DdlQx2hp0Ss5/fLikoLlEeIYiATotOjgB//nb973jeo= +github.com/moby/term v0.0.0-20201216013528-df9cb8a40635/go.mod h1:FBS0z0QWA44HXygs7VXDUOGoN/1TV3RuWkLO04am3wc= github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 h1:dcztxKSvZ4Id8iPpHERQBbIJfabdt4wUm5qy3wOL2Zc= github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -919,13 +976,10 @@ github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ github.com/neo4j/neo4j-go-driver v1.8.1-0.20200803113522-b626aa943eba/go.mod h1:ncO5VaFWh0Nrt+4KT4mOZboaczBZcLuHrG+/sUeP8gI= github.com/newrelic/go-agent v3.15.0+incompatible h1:BQ5+6vIgNtnv8jFET8CMjY7u7o+pN1wmGKIvN1uDIY4= github.com/newrelic/go-agent v3.15.0+incompatible/go.mod h1:a8Fv1b/fYhFSReoTU6HDkTYIMZeSVNffmoS726Y0LzQ= +github.com/ngrok/sqlmw v0.0.0-20200129213757-d5c93a81bec6/go.mod h1:E26fwEtRNigBfFfHDWsklmo0T7Ixbg0XXgck+Hq4O9k= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3/go.mod h1:nt3d53pc1VYcphSCIaYAJtnPYnr3Zyn8fMq2wvPGPso= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/odpf/salt v0.0.0-20211208090303-1aad792723ce h1:pbiCvSuI2opo6OXTebxH7bSphOrnulvBdiHE0ATNJE0= -github.com/odpf/salt v0.0.0-20211208090303-1aad792723ce/go.mod h1:NVnVQaXur70W/1wo06X6DYu6utZIUI/bMeMGyvFIwyo= -github.com/odpf/salt v0.0.0-20211209110810-233bff2ace28 h1:kjpVEyQ4s9xcTGeMjtksNRhRD5X0ws8Vi4/e+1TPIX8= -github.com/odpf/salt v0.0.0-20211209110810-233bff2ace28/go.mod h1:NVnVQaXur70W/1wo06X6DYu6utZIUI/bMeMGyvFIwyo= github.com/odpf/salt v0.0.0-20211209124356-60f6178cfd80 h1:da6GZ1cswyPZobRO/Q8h9DdcnL2wnTVbFyGPcrti2U0= github.com/odpf/salt v0.0.0-20211209124356-60f6178cfd80/go.mod h1:NVnVQaXur70W/1wo06X6DYu6utZIUI/bMeMGyvFIwyo= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= @@ -971,11 +1025,11 @@ github.com/opencontainers/selinux v1.6.0/go.mod h1:VVGKuOLlE7v4PJyT6h7mNWvq1rzqi github.com/opencontainers/selinux v1.8.0/go.mod h1:RScLhm78qiWa2gbVCcGkC7tCGdgk3ogry1nUQF8Evvo= github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xAPP8dBsCoU0KuF8= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/ory/dockertest/v3 v3.8.0/go.mod h1:9zPATATlWQru+ynXP+DytBQrsXV7Tmlx7K86H6fQaDo= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= -github.com/pelletier/go-toml v1.9.3 h1:zeC5b1GviRUyKYd6OJPvBU/mcVDVoL1OhT17FCt5dSQ= github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM= github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= @@ -1042,17 +1096,24 @@ github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= +github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= +github.com/rs/zerolog v1.19.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJRjo= +github.com/rs/zerolog v1.23.0/go.mod h1:6c7hFfxPOy7TacJc4Fcdi24/J0NKYGzjG8FWRI916Qo= +github.com/rs/zerolog v1.25.0/go.mod h1:7KHcEGe0QZPOm2IE4Kpb5rTh6n1h2hIgS5OOnu1rUaI= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46/go.mod h1:uAQ5PCi+MFsC7HjREoAz1BU+Mq60+05gifQSsHSDG/8= github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4= github.com/sagikazarmark/crypt v0.1.0/go.mod h1:B/mN0msZuINBtQ1zZLEQcegFJJf9vnYIR88KRMEuODE= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/scylladb/go-set v1.0.2/go.mod h1:DkpGd78rljTxKAnTDPFqXSGxvETQnJyuSOQwsHycqfs= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/shabbyrobe/gocovmerge v0.0.0-20180507124511-f6ea450bfb63/go.mod h1:n+VKSARF5y/tS9XFSP7vWDfS+GUC5vs/YT7M5XDTUEM= github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= @@ -1067,10 +1128,8 @@ github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrf github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/snowflakedb/gosnowflake v1.6.3/go.mod h1:6hLajn6yxuJ4xUHZegMekpq9rnQbGJ7TMwXjgTmA6lg= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= @@ -1078,19 +1137,20 @@ github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js= github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/afero v1.2.1/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= github.com/spf13/afero v1.3.4/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.2-0.20171109065643-2da4a54c5cee/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= +github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= github.com/spf13/cobra v1.2.1 h1:+KmjbUw1hriSNMF55oPrkZcb27aECyrj8V2ytv7kWDw= github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= @@ -1103,7 +1163,8 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= -github.com/spf13/viper v1.8.1 h1:Kq1fyeebqsBfbjZj4EL7gj2IO0mMaiyjYUWcUsl2O44= +github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= +github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= github.com/spf13/viper v1.9.0 h1:yR6EXjTp0y0cLN8OZg1CRZmOBdI88UcGkhgyJhu6nZk= github.com/spf13/viper v1.9.0/go.mod h1:+i6ajR7OX2XaiBkrcZJFK21htRk7eDeLg7+O6bhUPP4= @@ -1135,6 +1196,7 @@ github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c/go.mod h1:hzIxponao9Kjc7aWznkXaL4U4TWaDSs8zcsY4Ka08nM= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= @@ -1155,8 +1217,10 @@ github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= @@ -1166,6 +1230,7 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.3/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark-emoji v1.0.1/go.mod h1:2w1E6FEWLcDQkoTE+7HU6QF1F6SLlNGjRIBbIZQFqkQ= github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs= github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA= @@ -1193,16 +1258,33 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.22.6/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.24.0/go.mod h1:O0cG0vP6TP3c323kh70JmeG1jN69Sn9Z5HxgmeASFWY= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.25.0/go.mod h1:NyB05cd+yPX6W5SiRNuJ90w7PV2+g2cgRbsPL7MvpME= +go.opentelemetry.io/otel v1.0.0-RC2/go.mod h1:w1thVQ7qbAy8MHb0IFj8a5Q2QU0l2ksf8u/CN8m3NOM= +go.opentelemetry.io/otel v1.0.0/go.mod h1:AjRVh9A5/5DE7S+mZtTR6t8vpKKryam+0lREnfmS4cg= +go.opentelemetry.io/otel v1.0.1/go.mod h1:OPEOD4jIT2SlZPMmwT6FqZz2C0ZNdQqiWcoK6M0SNFU= +go.opentelemetry.io/otel/exporters/jaeger v1.0.0-RC2/go.mod h1:sZZqN3Vb0iT+NE6mZ1S7sNyH3t4PFk6ElK5TLGFBZ7E= +go.opentelemetry.io/otel/exporters/jaeger v1.0.0/go.mod h1:q10N1AolE1JjqKrFJK2tYw0iZpmX+HBaXBtuCzRnBGQ= +go.opentelemetry.io/otel/internal/metric v0.24.0/go.mod h1:PSkQG+KuApZjBpC6ea6082ZrWUUy/w132tJ/LOU3TXk= +go.opentelemetry.io/otel/metric v0.24.0/go.mod h1:tpMFnCD9t+BEGiWY2bWF5+AwjuAdM0lSowQ4SBA3/K4= +go.opentelemetry.io/otel/sdk v1.0.0-RC2/go.mod h1:fgwHyiDn4e5k40TD9VX243rOxXR+jzsWBZYA2P5jpEw= +go.opentelemetry.io/otel/sdk v1.0.0/go.mod h1:PCrDHlSy5x1kjezSdL37PhbFUMjrsLRshJ2zCzeXwbM= +go.opentelemetry.io/otel/trace v1.0.0-RC2/go.mod h1:JPQ+z6nNw9mqEGT8o3eoPTdnNI+Aj5JcxEsVGREIAy4= +go.opentelemetry.io/otel/trace v1.0.0/go.mod h1:PXTWqayeFUlJV1YDNhsJYB184+IvAH814St6o6ajzIs= +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.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= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= +go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec= @@ -1210,6 +1292,7 @@ go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95a go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= go.uber.org/zap v1.19.0 h1:mZQZefskPPCMIBCSEH0v2/iUqqLrYtaeqwD6FUGUnFE= @@ -1237,8 +1320,11 @@ golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= +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-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= @@ -1276,7 +1362,6 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= @@ -1303,6 +1388,7 @@ golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190225153610-fe579d43d832/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190310074541-c10a0554eabf/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -1349,11 +1435,13 @@ golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210825183410-e898025ed96a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210913180222-943fd674d43e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211013171255-e13a2654a71e h1:Xj+JO91noE97IN6F/7WZxzC5QE6yENAQPrwIYhW3bsA= golang.org/x/net v0.0.0-20211013171255-e13a2654a71e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211020060615-d418f374d309 h1:A0lJIi+hcTR6aajJH4YqKWwohY4aW9RO7oRMcdv+HKI= +golang.org/x/net v0.0.0-20211020060615-d418f374d309/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180227000427-d7d64896b5ff/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1458,6 +1546,7 @@ golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200817155316-9781c653f443/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200828194041-157a740278f4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1482,6 +1571,7 @@ golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210503080704-8803ae5d1324/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1493,14 +1583,17 @@ golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210818153620-00dd8d7831e7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211013075003-97ac67df715c h1:taxlMj0D/1sOAuv/CbSD+MMDof2vbyPTqz5FNYKpXt8= golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211020174200-9d6173849985 h1:LOlKVhfDyahgmqa97awczplwkjzNaELFg3zRIJ13RYo= +golang.org/x/sys v0.0.0-20211020174200-9d6173849985/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1525,6 +1618,7 @@ golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190308174544-00c44ba9c14f/go.mod h1:25r3+/G6/xytQM8iWZKq3Hn0kr0rgFKPUNVEL/dr3z4= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= @@ -1545,6 +1639,7 @@ golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190828213141-aed303cbaa74/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -1560,6 +1655,7 @@ golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= @@ -1594,8 +1690,8 @@ golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.6/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1604,8 +1700,10 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= +gonum.org/v1/gonum v0.0.0-20181121035319-3f7ecaa7e8ca/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= gonum.org/v1/gonum v0.9.3/go.mod h1:TZumC3NeyVQskjXqmyWt4S3bINhy7B4eYwW69EbyX+0= +gonum.org/v1/netlib v0.0.0-20181029234149-ec6d1f5cefe6/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= gonum.org/v1/plot v0.9.0/go.mod h1:3Pcqqmp6RHvJI72kgb8fThyUnav364FOsdDo2aGW5lY= @@ -1728,8 +1826,9 @@ google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEc google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211013025323-ce878158c4d4/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211016002631-37fc39342514 h1:Rp1vYDPD4TdkMH5S/bZbopsGCsWhPcrLBUwOVhAQCxM= google.golang.org/genproto v0.0.0-20211016002631-37fc39342514/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211020151524-b7c3a969101a h1:8maMHMQp9NroHXhc3HelFX9Ay2lWlXLcdH5mw5Biz0s= +google.golang.org/genproto v0.0.0-20211020151524-b7c3a969101a/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -1792,10 +1891,11 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU= +gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.63.2 h1:tGK/CyBg7SMzb60vP1M03vNZ3VDu3wGQJwn7Sxi9r3c= gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= diff --git a/internal/authz/authz.go b/internal/authz/authz.go new file mode 100644 index 000000000..b81132195 --- /dev/null +++ b/internal/authz/authz.go @@ -0,0 +1,28 @@ +package authz + +import ( + "context" + + "github.com/odpf/salt/log" + "github.com/odpf/shield/config" + "github.com/odpf/shield/internal/authz/spicedb" +) + +type Policy interface { + AddPolicy(ctx context.Context, schema string) error +} + +type Authz struct { + Policy +} + +func New(config *config.Shield, logger log.Logger) *Authz { + spice, err := spicedb.New(config.SpiceDB) + + if err != nil { + logger.Fatal(err.Error()) + } + return &Authz{ + spice.Policy, + } +} diff --git a/internal/authz/spicedb/spicedb.go b/internal/authz/spicedb/spicedb.go new file mode 100644 index 000000000..ac5f26349 --- /dev/null +++ b/internal/authz/spicedb/spicedb.go @@ -0,0 +1,48 @@ +package spicedb + +import ( + "context" + "fmt" + + pb "github.com/authzed/authzed-go/proto/authzed/api/v1" + "github.com/authzed/authzed-go/v1" + "github.com/authzed/grpcutil" + "github.com/odpf/shield/config" + "google.golang.org/grpc" +) + +type SpiceDB struct { + Policy *Policy +} + +type Policy struct { + client *authzed.Client +} + +func (s *SpiceDB) Check() bool { + return false +} + +func (p *Policy) AddPolicy(ctx context.Context, schema string) error { + request := &pb.WriteSchemaRequest{Schema: schema} + _, err := p.client.WriteSchema(ctx, request) + if err != nil { + return err + } + return nil +} + +func New(config config.SpiceDBConfig) (*SpiceDB, error) { + endpoint := fmt.Sprintf("%s:%s", config.Host, config.Port) + client, err := authzed.NewClient(endpoint, grpc.WithInsecure(), grpcutil.WithInsecureBearerToken(config.PreSharedKey)) + if err != nil { + return &SpiceDB{}, err + } + + policy := &Policy{ + client, + } + return &SpiceDB{ + policy, + }, nil +} diff --git a/internal/schema/action.go b/internal/schema/action.go new file mode 100644 index 000000000..f81dad5aa --- /dev/null +++ b/internal/schema/action.go @@ -0,0 +1,44 @@ +package schema + +import ( + "context" + "errors" + + "github.com/odpf/shield/model" +) + +var ActionDoesntExist = errors.New("actions doesn't exist") + +func (s Service) GetAction(ctx context.Context, id string) (model.Action, error) { + return s.Store.GetAction(ctx, id) +} + +func (s Service) CreateAction(ctx context.Context, action model.Action) (model.Action, error) { + newAction, err := s.Store.CreateAction(ctx, model.Action{ + Name: action.Name, + Id: action.Id, + }) + + if err != nil { + return model.Action{}, err + } + + return newAction, nil +} + +func (s Service) ListActions(ctx context.Context) ([]model.Action, error) { + return s.Store.ListActions(ctx) +} + +func (s Service) UpdateAction(ctx context.Context, id string, action model.Action) (model.Action, error) { + updatedAction, err := s.Store.UpdateAction(ctx, model.Action{ + Name: action.Name, + Id: id, + }) + + if err != nil { + return model.Action{}, err + } + + return updatedAction, nil +} diff --git a/internal/schema/namespace.go b/internal/schema/namespace.go new file mode 100644 index 000000000..ef6fb9030 --- /dev/null +++ b/internal/schema/namespace.go @@ -0,0 +1,42 @@ +package schema + +import ( + "context" + "errors" + + "github.com/odpf/shield/model" +) + +var NamespaceDoesntExist = errors.New("actions doesn't exist") + +func (s Service) GetNamespace(ctx context.Context, id string) (model.Namespace, error) { + return s.Store.GetNamespace(ctx, id) +} + +func (s Service) CreateNamespace(ctx context.Context, ns model.Namespace) (model.Namespace, error) { + newNamespace, err := s.Store.CreateNamespace(ctx, model.Namespace{ + Name: ns.Name, + Id: ns.Id, + }) + + if err != nil { + return model.Namespace{}, err + } + + return newNamespace, nil +} + +func (s Service) ListNamespaces(ctx context.Context) ([]model.Namespace, error) { + return s.Store.ListNamespaces(ctx) +} + +func (s Service) UpdateNamespace(ctx context.Context, id string, ns model.Namespace) (model.Namespace, error) { + updatedNamespace, err := s.Store.UpdateNamespace(ctx, model.Namespace{ + Name: ns.Name, + Id: id, + }) + if err != nil { + return model.Namespace{}, err + } + return updatedNamespace, nil +} diff --git a/internal/schema/policy.go b/internal/schema/policy.go new file mode 100644 index 000000000..174d86989 --- /dev/null +++ b/internal/schema/policy.go @@ -0,0 +1,70 @@ +package schema + +import ( + "context" + "errors" + + "github.com/odpf/shield/internal/schema_generator" + "github.com/odpf/shield/model" +) + +var PolicyDoesntExist = errors.New("policies doesn't exist") + +func (s Service) GetPolicy(ctx context.Context, id string) (model.Policy, error) { + return s.Store.GetPolicy(ctx, id) +} + +func (s Service) ListPolicies(ctx context.Context) ([]model.Policy, error) { + return s.Store.ListPolicies(ctx) +} + +func (s Service) CreatePolicy(ctx context.Context, policy model.Policy) ([]model.Policy, error) { + policies, err := s.Store.CreatePolicy(ctx, policy) + if err != nil { + return []model.Policy{}, err + } + schemas, err := s.generateSchema(policies) + if err != nil { + return []model.Policy{}, err + } + err = s.pushSchema(ctx, schemas) + if err != nil { + return []model.Policy{}, err + } + return policies, err +} + +func (s Service) UpdatePolicy(ctx context.Context, id string, policy model.Policy) ([]model.Policy, error) { + policies, err := s.Store.UpdatePolicy(ctx, id, policy) + if err != nil { + return []model.Policy{}, err + } + schemas, err := s.generateSchema(policies) + if err != nil { + return []model.Policy{}, err + } + err = s.pushSchema(ctx, schemas) + if err != nil { + return []model.Policy{}, err + } + return policies, err +} + +func (s Service) generateSchema(policies []model.Policy) ([]string, error) { + definitions, err := schema_generator.BuildPolicyDefinitions(policies) + if err != nil { + return []string{}, err + } + schemas := schema_generator.BuildSchema(definitions) + return schemas, nil +} + +func (s Service) pushSchema(ctx context.Context, schemas []string) error { + for _, schema := range schemas { + err := s.Authz.Policy.AddPolicy(ctx, schema) + if err != nil { + return err + } + } + return nil +} diff --git a/internal/schema/schema.go b/internal/schema/schema.go new file mode 100644 index 000000000..a3085f26c --- /dev/null +++ b/internal/schema/schema.go @@ -0,0 +1,35 @@ +package schema + +import ( + "context" + "errors" + + "github.com/odpf/shield/internal/authz" + "github.com/odpf/shield/model" +) + +type PolicyFilters struct { + NamespaceId string +} + +type Service struct { + Store Store + Authz *authz.Authz +} + +var InvalidUUID = errors.New("invalid syntax of uuid") + +type Store interface { + GetAction(ctx context.Context, id string) (model.Action, error) + CreateAction(ctx context.Context, action model.Action) (model.Action, error) + ListActions(ctx context.Context) ([]model.Action, error) + UpdateAction(ctx context.Context, action model.Action) (model.Action, error) + GetNamespace(ctx context.Context, id string) (model.Namespace, error) + CreateNamespace(ctx context.Context, namespace model.Namespace) (model.Namespace, error) + ListNamespaces(ctx context.Context) ([]model.Namespace, error) + UpdateNamespace(ctx context.Context, namespace model.Namespace) (model.Namespace, error) + GetPolicy(ctx context.Context, id string) (model.Policy, error) + ListPolicies(ctx context.Context) ([]model.Policy, error) + CreatePolicy(ctx context.Context, policy model.Policy) ([]model.Policy, error) + UpdatePolicy(ctx context.Context, id string, policy model.Policy) ([]model.Policy, error) +} diff --git a/internal/schema_generator/generator.go b/internal/schema_generator/generator.go new file mode 100644 index 000000000..0ef17942b --- /dev/null +++ b/internal/schema_generator/generator.go @@ -0,0 +1,171 @@ +package schema_generator + +import ( + "errors" + "fmt" + "sort" + "strings" + + v0 "github.com/authzed/authzed-go/proto/authzed/api/v0" + "github.com/authzed/spicedb/pkg/namespace" + "github.com/authzed/spicedb/pkg/schemadsl/generator" + "github.com/odpf/shield/model" +) + +type role struct { + name string + types []string + namespace string + permissions []string +} + +type definition struct { + name string + roles []role +} + +func BuildSchema(def []definition) []string { + var schema []string + for _, d := range def { + schema = append(schema, buildSchema(d)) + } + return schema +} + +func buildSchema(d definition) string { + var relations []*v0.Relation + permissions := make(map[string][]*v0.SetOperation_Child) + + for _, r := range d.roles { + if r.namespace == "" { + relationReference := buildRelationReference(r) + relations = append(relations, namespace.Relation( + r.name, + nil, + relationReference..., + )) + } + + for _, p := range r.permissions { + perm := namespace.ComputedUserset(r.name) + if r.namespace != "" { + perm = namespace.TupleToUserset(r.namespace, r.name) + relations = append(relations, namespace.Relation( + r.namespace, + nil, + &v0.RelationReference{ + Namespace: r.namespace, + Relation: "...", + }, + )) + } + permissions[p] = append(permissions[p], perm) + } + } + + for p, roles := range permissions { + if len(roles) == 0 { + continue + } + relations = append(relations, namespace.Relation( + p, + namespace.Union( + roles[0], + roles[1:]..., + ), + )) + } + + n := namespace.Namespace(d.name, relations...) + + schemaDefinition, _ := generator.GenerateSource(n) + return schemaDefinition +} + +func buildRelationReference(r role) []*v0.RelationReference { + var relationReference []*v0.RelationReference + for _, t := range r.types { + roleType := strings.Split(t, "#") + subType := "..." + if len(roleType) > 1 { + subType = roleType[1] + } + relationReference = append(relationReference, &v0.RelationReference{ + Namespace: roleType[0], + Relation: subType, + }) + } + return relationReference +} + +func BuildPolicyDefinitions(policies []model.Policy) ([]definition, error) { + var definitions []definition + defMap := make(map[string]map[string][]role) + + for _, p := range policies { + namespaceId := p.Namespace.Id + def, ok := defMap[namespaceId] + if !ok { + def = make(map[string][]role) + defMap[namespaceId] = def + } + + keyName := fmt.Sprintf("%s_%s_%s", p.Role.Id, p.Role.NamespaceId, namespaceId) + + r, ok := def[keyName] + if !ok { + r = []role{} + def[keyName] = r + } + + if p.Action.NamespaceId != "" && p.Action.NamespaceId != namespaceId { + return []definition{}, errors.New("actions namespace doesnt match") + } + + def[keyName] = append(r, role{ + name: p.Role.Id, + types: p.Role.Types, + namespace: p.Role.NamespaceId, + permissions: []string{p.Action.Id}, + }) + } + + for ns, def := range defMap { + var roles []role + for _, r := range def { + var permissions []string + for _, p := range r { + permissions = append(permissions, p.permissions...) + } + + roleNamespace := ns + + if r[0].namespace != "" { + roleNamespace = r[0].namespace + } + + roles = append(roles, role{ + name: r[0].name, + types: r[0].types, + namespace: roleNamespace, + permissions: permissions, + }) + } + + definition := definition{ + name: ns, + roles: roles, + } + + sort.Slice(roles[:], func(i, j int) bool { + return strings.Compare(roles[i].name, roles[j].name) < 1 && strings.Compare(roles[i].namespace, roles[j].namespace) < 1 + }) + + definitions = append(definitions, definition) + } + + sort.Slice(definitions[:], func(i, j int) bool { + return strings.Compare(definitions[i].name, definitions[j].name) < 1 + }) + return definitions, nil +} diff --git a/internal/schema_generator/generator_test.go b/internal/schema_generator/generator_test.go new file mode 100644 index 000000000..482998653 --- /dev/null +++ b/internal/schema_generator/generator_test.go @@ -0,0 +1,280 @@ +package schema_generator + +import ( + "testing" + + "github.com/odpf/shield/model" + "github.com/stretchr/testify/assert" +) + +func TestBuildSchema(t *testing.T) { + t.Run("Generate Empty schema with name ", func(t *testing.T) { + d := definition{ + name: "Test", + } + assert.Equal(t, "definition Test {}", buildSchema(d)) + }) + + t.Run("Generate Empty schema with name and role ", func(t *testing.T) { + d := definition{ + name: "Test", + roles: []role{{name: "Admin", types: []string{"User"}}}, + } + assert.Equal(t, `definition Test { + relation Admin: User +}`, buildSchema(d)) + }) + + t.Run("Generate Empty schema with name, role and permission ", func(t *testing.T) { + d := definition{ + name: "Test", + roles: []role{{name: "Admin", types: []string{"User"}, permissions: []string{"read"}}}, + } + assert.Equal(t, `definition Test { + relation Admin: User + permission read = Admin +}`, buildSchema(d)) + }) + + t.Run("Add role name and children", func(t *testing.T) { + d := definition{ + name: "Test", + roles: []role{ + {name: "Admin", types: []string{"User"}, permissions: []string{"read"}, namespace: "Project"}, + {name: "Member", types: []string{"User"}, namespace: "Group", permissions: []string{"read"}}, + }, + } + assert.Equal(t, `definition Test { + relation Project: Project + relation Group: Group + permission read = Project->Admin + Group->Member +}`, buildSchema(d)) + }) + + t.Run("Should add role subtype", func(t *testing.T) { + d := definition{ + name: "Test", + roles: []role{{name: "Admin", types: []string{"User#member"}, permissions: []string{"read"}}}, + } + assert.Equal(t, `definition Test { + relation Admin: User#member + permission read = Admin +}`, buildSchema(d)) + }) + + t.Run("Should add multiple role types", func(t *testing.T) { + d := definition{ + name: "Test", + roles: []role{{name: "Admin", types: []string{"User", "Team#member"}, permissions: []string{"read"}}}, + } + assert.Equal(t, `definition Test { + relation Admin: User | Team#member + permission read = Admin +}`, buildSchema(d)) + }) +} + +func TestBuildPolicyDefinitions(t *testing.T) { + t.Run("return policy definitions", func(t *testing.T) { + policies := []model.Policy{ + { + Namespace: model.Namespace{Name: "Project", Id: "project"}, + Role: model.Role{Name: "Admin", Id: "admin", Types: []string{"User"}}, + Action: model.Action{Name: "Read", Id: "read"}, + }, + } + def, _ := BuildPolicyDefinitions(policies) + expectedDef := []definition{ + { + name: "project", + roles: []role{ + { + name: "admin", + types: []string{"User"}, + namespace: "project", + permissions: []string{"read"}, + }, + }, + }, + } + + assert.EqualValues(t, expectedDef, def) + }) + + t.Run("merge roles in policy definitions", func(t *testing.T) { + policies := []model.Policy{ + { + Namespace: model.Namespace{Name: "Project", Id: "project"}, + Role: model.Role{Name: "Admin", Id: "admin", Types: []string{"User"}}, + Action: model.Action{Name: "Read", Id: "read"}, + }, + { + Namespace: model.Namespace{Name: "Project", Id: "project"}, + Role: model.Role{Name: "Admin", Id: "admin", Types: []string{"User"}}, + Action: model.Action{Name: "Write", Id: "write"}, + }, + { + Namespace: model.Namespace{Name: "Project", Id: "project"}, + Role: model.Role{Name: "Admin", Id: "admin", Types: []string{"User"}}, + Action: model.Action{Name: "Delete", Id: "delete"}, + }, + } + def, _ := BuildPolicyDefinitions(policies) + expectedDef := []definition{ + { + name: "project", + roles: []role{ + { + name: "admin", + types: []string{"User"}, + namespace: "project", + permissions: []string{"read", "write", "delete"}, + }, + }, + }, + } + + assert.EqualValues(t, expectedDef, def) + }) + + t.Run("create multiple roles in policy definitions", func(t *testing.T) { + policies := []model.Policy{ + { + Namespace: model.Namespace{Name: "Project", Id: "project"}, + Role: model.Role{Name: "Admin", Id: "admin", Types: []string{"User"}}, + Action: model.Action{Name: "Read", Id: "read"}, + }, + { + Namespace: model.Namespace{Name: "Project", Id: "project"}, + Role: model.Role{Name: "Admin", Id: "admin", Types: []string{"User"}}, + Action: model.Action{Name: "Write", Id: "write"}, + }, + { + Namespace: model.Namespace{Name: "Project", Id: "project"}, + Role: model.Role{Name: "Admin", Id: "admin", Types: []string{"User"}}, + Action: model.Action{Name: "Delete", Id: "delete"}, + }, + { + Namespace: model.Namespace{Name: "Project", Id: "project"}, + Role: model.Role{Name: "Reader", Id: "reader", Types: []string{"User"}}, + Action: model.Action{Name: "Read", Id: "read"}, + }, + } + def, _ := BuildPolicyDefinitions(policies) + expectedDef := []definition{ + { + name: "project", + roles: []role{ + { + name: "admin", + types: []string{"User"}, + namespace: "project", + permissions: []string{"read", "write", "delete"}, + }, + { + name: "reader", + types: []string{"User"}, + namespace: "project", + permissions: []string{"read"}, + }, + }, + }, + } + + assert.EqualValues(t, expectedDef, def) + }) + + t.Run("should add roles namespace", func(t *testing.T) { + policies := []model.Policy{ + { + Namespace: model.Namespace{Name: "Project", Id: "project"}, + Role: model.Role{Name: "Admin", NamespaceId: "Org", Id: "admin", Types: []string{"User"}}, + Action: model.Action{Name: "Read", Id: "read"}, + }, + { + Namespace: model.Namespace{Name: "Project", Id: "project"}, + Role: model.Role{Name: "Admin", Id: "admin", Types: []string{"User"}}, + Action: model.Action{Name: "Write", Id: "write"}, + }, + { + Namespace: model.Namespace{Name: "Project", Id: "project"}, + Role: model.Role{Name: "Admin", Id: "admin", Types: []string{"User"}}, + Action: model.Action{Name: "Delete", Id: "delete"}, + }, + { + Namespace: model.Namespace{Name: "Project", Id: "project"}, + Role: model.Role{Name: "Reader", Id: "reader", Types: []string{"User"}}, + Action: model.Action{Name: "Read", Id: "read"}, + }, + } + def, _ := BuildPolicyDefinitions(policies) + expectedDef := []definition{ + { + name: "project", + roles: []role{ + { + name: "admin", + types: []string{"User"}, + namespace: "Org", + permissions: []string{"read"}, + }, + { + name: "admin", + types: []string{"User"}, + namespace: "project", + permissions: []string{"write", "delete"}, + }, + { + name: "reader", + types: []string{"User"}, + namespace: "project", + permissions: []string{"read"}, + }, + }, + }, + } + + assert.EqualValues(t, expectedDef, def) + }) + + t.Run("should support multiple role types", func(t *testing.T) { + policies := []model.Policy{ + { + Namespace: model.Namespace{Name: "Project", Id: "project"}, + Role: model.Role{Name: "Admin", Id: "admin", Types: []string{"User", "Team#members"}}, + Action: model.Action{Name: "Read", Id: "read"}, + }, + } + def, _ := BuildPolicyDefinitions(policies) + expectedDef := []definition{ + { + name: "project", + roles: []role{ + { + name: "admin", + types: []string{"User", "Team#members"}, + namespace: "project", + permissions: []string{"read"}, + }, + }, + }, + } + + assert.EqualValues(t, expectedDef, def) + }) + + t.Run("should throw error if action namespace is different", func(t *testing.T) { + policies := []model.Policy{ + { + Namespace: model.Namespace{Name: "Project", Id: "project"}, + Role: model.Role{Name: "Admin", Id: "admin", Types: []string{"User", "Team#members"}}, + Action: model.Action{Name: "Read", Id: "read", NamespaceId: "org"}, + }, + } + def, err := BuildPolicyDefinitions(policies) + expectedDef := []definition{} + + assert.EqualValues(t, expectedDef, def) + assert.Errorf(t, err, "actions namespace doesnt match") + }) +} diff --git a/model/model.go b/model/model.go index 4b0ef5d17..5d1548bac 100644 --- a/model/model.go +++ b/model/model.go @@ -32,15 +32,44 @@ type Group struct { } type Role struct { + Id string + Name string + Types []string + Namespace Namespace + NamespaceId string + Metadata map[string]string + CreatedAt time.Time + UpdatedAt time.Time +} + +type Action struct { + Id string + Name string + NamespaceId string + Namespace Namespace + CreatedAt time.Time + UpdatedAt time.Time +} + +type Namespace struct { Id string Name string - Types []string - Namespace string - Metadata map[string]string CreatedAt time.Time UpdatedAt time.Time } +type Policy struct { + Id string + Role Role + RoleId string `json:"role_id"` + Namespace Namespace + NamespaceId string `json:"namespace_id"` + Action Action + ActionId string `json:"action_id"` + CreatedAt time.Time + UpdatedAt time.Time +} + type User struct { Id string Name string diff --git a/proto/v1/shield.pb.validate.go b/proto/v1/shield.pb.validate.go index 23c2189ee..e9df9e6de 100644 --- a/proto/v1/shield.pb.validate.go +++ b/proto/v1/shield.pb.validate.go @@ -11,11 +11,12 @@ import ( "net/mail" "net/url" "regexp" + "sort" "strings" "time" "unicode/utf8" - "github.com/golang/protobuf/ptypes" + "google.golang.org/protobuf/types/known/anypb" ) // ensure the imports are used @@ -30,36 +31,75 @@ var ( _ = time.Duration(0) _ = (*url.URL)(nil) _ = (*mail.Address)(nil) - _ = ptypes.DynamicAny{} + _ = anypb.Any{} + _ = sort.Sort ) -// define the regex for a UUID once up-front -var _shield_uuidPattern = regexp.MustCompile("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$") - // Validate checks the field values on UserRequestBody with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *UserRequestBody) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UserRequestBody with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UserRequestBodyMultiError, or nil if none found. +func (m *UserRequestBody) ValidateAll() error { + return m.validate(true) +} + +func (m *UserRequestBody) validate(all bool) error { if m == nil { return nil } + var errors []error + if !_UserRequestBody_Name_Pattern.MatchString(m.GetName()) { - return UserRequestBodyValidationError{ + err := UserRequestBodyValidationError{ field: "Name", reason: "value does not match regex pattern \"^[A-Za-z0-9_-]+$\"", } + if !all { + return err + } + errors = append(errors, err) } if err := m._validateEmail(m.GetEmail()); err != nil { - return UserRequestBodyValidationError{ + err = UserRequestBodyValidationError{ field: "Email", reason: "value must be a valid email address", cause: err, } + if !all { + return err + } + errors = append(errors, err) } - if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserRequestBodyValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserRequestBodyValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UserRequestBodyValidationError{ field: "Metadata", @@ -69,6 +109,9 @@ func (m *UserRequestBody) Validate() error { } } + if len(errors) > 0 { + return UserRequestBodyMultiError(errors) + } return nil } @@ -122,6 +165,23 @@ func (m *UserRequestBody) _validateEmail(addr string) error { return m._validateHostname(parts[1]) } +// UserRequestBodyMultiError is an error wrapping multiple validation errors +// returned by UserRequestBody.ValidateAll() if the designated constraints +// aren't met. +type UserRequestBodyMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UserRequestBodyMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UserRequestBodyMultiError) AllErrors() []error { return m } + // UserRequestBodyValidationError is the validation error returned by // UserRequestBody.Validate if the designated constraints aren't met. type UserRequestBodyValidationError struct { @@ -179,14 +239,47 @@ var _ interface { var _UserRequestBody_Name_Pattern = regexp.MustCompile("^[A-Za-z0-9_-]+$") // Validate checks the field values on CreateUserRequest with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *CreateUserRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateUserRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CreateUserRequestMultiError, or nil if none found. +func (m *CreateUserRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateUserRequest) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetBody()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateUserRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateUserRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CreateUserRequestValidationError{ field: "Body", @@ -196,9 +289,29 @@ func (m *CreateUserRequest) Validate() error { } } + if len(errors) > 0 { + return CreateUserRequestMultiError(errors) + } return nil } +// CreateUserRequestMultiError is an error wrapping multiple validation errors +// returned by CreateUserRequest.ValidateAll() if the designated constraints +// aren't met. +type CreateUserRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateUserRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CreateUserRequestMultiError) AllErrors() []error { return m } + // CreateUserRequestValidationError is the validation error returned by // CreateUserRequest.Validate if the designated constraints aren't met. type CreateUserRequestValidationError struct { @@ -256,32 +369,73 @@ var _ interface { } = CreateUserRequestValidationError{} // Validate checks the field values on User with the rules defined in the proto -// definition for this message. If any rules are violated, an error is returned. +// definition for this message. If any rules are violated, the first error +// encountered is returned, or nil if there are no violations. func (m *User) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on User with the rules defined in the +// proto definition for this message. If any rules are violated, the result is +// a list of violation errors wrapped in UserMultiError, or nil if none found. +func (m *User) ValidateAll() error { + return m.validate(true) +} + +func (m *User) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id if !_User_Name_Pattern.MatchString(m.GetName()) { - return UserValidationError{ + err := UserValidationError{ field: "Name", reason: "value does not match regex pattern \"^[A-Za-z0-9_-]+$\"", } + if !all { + return err + } + errors = append(errors, err) } // no validation rules for Slug if err := m._validateEmail(m.GetEmail()); err != nil { - return UserValidationError{ + err = UserValidationError{ field: "Email", reason: "value must be a valid email address", cause: err, } + if !all { + return err + } + errors = append(errors, err) } - if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UserValidationError{ field: "Metadata", @@ -291,7 +445,26 @@ func (m *User) Validate() error { } } - if v, ok := interface{}(m.GetCreatedAt()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetCreatedAt()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserValidationError{ + field: "CreatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserValidationError{ + field: "CreatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreatedAt()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UserValidationError{ field: "CreatedAt", @@ -301,7 +474,26 @@ func (m *User) Validate() error { } } - if v, ok := interface{}(m.GetUpdatedAt()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetUpdatedAt()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserValidationError{ + field: "UpdatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserValidationError{ + field: "UpdatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdatedAt()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UserValidationError{ field: "UpdatedAt", @@ -311,6 +503,9 @@ func (m *User) Validate() error { } } + if len(errors) > 0 { + return UserMultiError(errors) + } return nil } @@ -364,6 +559,22 @@ func (m *User) _validateEmail(addr string) error { return m._validateHostname(parts[1]) } +// UserMultiError is an error wrapping multiple validation errors returned by +// User.ValidateAll() if the designated constraints aren't met. +type UserMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UserMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UserMultiError) AllErrors() []error { return m } + // UserValidationError is the validation error returned by User.Validate if the // designated constraints aren't met. type UserValidationError struct { @@ -422,13 +633,46 @@ var _User_Name_Pattern = regexp.MustCompile("^[A-Za-z0-9_-]+$") // Validate checks the field values on CreateUserResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *CreateUserResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateUserResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CreateUserResponseMultiError, or nil if none found. +func (m *CreateUserResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateUserResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateUserResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateUserResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CreateUserResponseValidationError{ field: "User", @@ -438,9 +682,29 @@ func (m *CreateUserResponse) Validate() error { } } + if len(errors) > 0 { + return CreateUserResponseMultiError(errors) + } return nil } +// CreateUserResponseMultiError is an error wrapping multiple validation errors +// returned by CreateUserResponse.ValidateAll() if the designated constraints +// aren't met. +type CreateUserResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateUserResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CreateUserResponseMultiError) AllErrors() []error { return m } + // CreateUserResponseValidationError is the validation error returned by // CreateUserResponse.Validate if the designated constraints aren't met. type CreateUserResponseValidationError struct { @@ -498,14 +762,47 @@ var _ interface { } = CreateUserResponseValidationError{} // Validate checks the field values on GetUserResponse with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *GetUserResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetUserResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetUserResponseMultiError, or nil if none found. +func (m *GetUserResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetUserResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetUserResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetUserResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GetUserResponseValidationError{ field: "User", @@ -515,9 +812,29 @@ func (m *GetUserResponse) Validate() error { } } + if len(errors) > 0 { + return GetUserResponseMultiError(errors) + } return nil } +// GetUserResponseMultiError is an error wrapping multiple validation errors +// returned by GetUserResponse.ValidateAll() if the designated constraints +// aren't met. +type GetUserResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetUserResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetUserResponseMultiError) AllErrors() []error { return m } + // GetUserResponseValidationError is the validation error returned by // GetUserResponse.Validate if the designated constraints aren't met. type GetUserResponseValidationError struct { @@ -574,13 +891,46 @@ var _ interface { // Validate checks the field values on GetCurrentUserResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *GetCurrentUserResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetCurrentUserResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetCurrentUserResponseMultiError, or nil if none found. +func (m *GetCurrentUserResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetCurrentUserResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetCurrentUserResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetCurrentUserResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GetCurrentUserResponseValidationError{ field: "User", @@ -590,9 +940,29 @@ func (m *GetCurrentUserResponse) Validate() error { } } + if len(errors) > 0 { + return GetCurrentUserResponseMultiError(errors) + } return nil } +// GetCurrentUserResponseMultiError is an error wrapping multiple validation +// errors returned by GetCurrentUserResponse.ValidateAll() if the designated +// constraints aren't met. +type GetCurrentUserResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetCurrentUserResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetCurrentUserResponseMultiError) AllErrors() []error { return m } + // GetCurrentUserResponseValidationError is the validation error returned by // GetCurrentUserResponse.Validate if the designated constraints aren't met. type GetCurrentUserResponseValidationError struct { @@ -651,13 +1021,46 @@ var _ interface { // Validate checks the field values on UpdateUserResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *UpdateUserResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateUserResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdateUserResponseMultiError, or nil if none found. +func (m *UpdateUserResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateUserResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateUserResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateUserResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UpdateUserResponseValidationError{ field: "User", @@ -667,9 +1070,29 @@ func (m *UpdateUserResponse) Validate() error { } } + if len(errors) > 0 { + return UpdateUserResponseMultiError(errors) + } return nil } +// UpdateUserResponseMultiError is an error wrapping multiple validation errors +// returned by UpdateUserResponse.ValidateAll() if the designated constraints +// aren't met. +type UpdateUserResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateUserResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UpdateUserResponseMultiError) AllErrors() []error { return m } + // UpdateUserResponseValidationError is the validation error returned by // UpdateUserResponse.Validate if the designated constraints aren't met. type UpdateUserResponseValidationError struct { @@ -728,13 +1151,46 @@ var _ interface { // Validate checks the field values on UpdateCurrentUserResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *UpdateCurrentUserResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateCurrentUserResponse with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdateCurrentUserResponseMultiError, or nil if none found. +func (m *UpdateCurrentUserResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateCurrentUserResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateCurrentUserResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateCurrentUserResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UpdateCurrentUserResponseValidationError{ field: "User", @@ -744,9 +1200,29 @@ func (m *UpdateCurrentUserResponse) Validate() error { } } + if len(errors) > 0 { + return UpdateCurrentUserResponseMultiError(errors) + } return nil } +// UpdateCurrentUserResponseMultiError is an error wrapping multiple validation +// errors returned by UpdateCurrentUserResponse.ValidateAll() if the +// designated constraints aren't met. +type UpdateCurrentUserResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateCurrentUserResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UpdateCurrentUserResponseMultiError) AllErrors() []error { return m } + // UpdateCurrentUserResponseValidationError is the validation error returned by // UpdateCurrentUserResponse.Validate if the designated constraints aren't met. type UpdateCurrentUserResponseValidationError struct { @@ -804,16 +1280,49 @@ var _ interface { } = UpdateCurrentUserResponseValidationError{} // Validate checks the field values on UpdateUserRequest with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *UpdateUserRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateUserRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdateUserRequestMultiError, or nil if none found. +func (m *UpdateUserRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateUserRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id - if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetBody()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateUserRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateUserRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UpdateUserRequestValidationError{ field: "Body", @@ -823,9 +1332,29 @@ func (m *UpdateUserRequest) Validate() error { } } + if len(errors) > 0 { + return UpdateUserRequestMultiError(errors) + } return nil } +// UpdateUserRequestMultiError is an error wrapping multiple validation errors +// returned by UpdateUserRequest.ValidateAll() if the designated constraints +// aren't met. +type UpdateUserRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateUserRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UpdateUserRequestMultiError) AllErrors() []error { return m } + // UpdateUserRequestValidationError is the validation error returned by // UpdateUserRequest.Validate if the designated constraints aren't met. type UpdateUserRequestValidationError struct { @@ -883,18 +1412,52 @@ var _ interface { } = UpdateUserRequestValidationError{} // Validate checks the field values on GetUserRequest with the rules defined in -// the proto definition for this message. If any rules are violated, an error -// is returned. +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. func (m *GetUserRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetUserRequest with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in GetUserRequestMultiError, +// or nil if none found. +func (m *GetUserRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetUserRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id + if len(errors) > 0 { + return GetUserRequestMultiError(errors) + } return nil } +// GetUserRequestMultiError is an error wrapping multiple validation errors +// returned by GetUserRequest.ValidateAll() if the designated constraints +// aren't met. +type GetUserRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetUserRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetUserRequestMultiError) AllErrors() []error { return m } + // GetUserRequestValidationError is the validation error returned by // GetUserRequest.Validate if the designated constraints aren't met. type GetUserRequestValidationError struct { @@ -951,15 +1514,49 @@ var _ interface { // Validate checks the field values on GetCurrentUserRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *GetCurrentUserRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetCurrentUserRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetCurrentUserRequestMultiError, or nil if none found. +func (m *GetCurrentUserRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetCurrentUserRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + + if len(errors) > 0 { + return GetCurrentUserRequestMultiError(errors) + } return nil } +// GetCurrentUserRequestMultiError is an error wrapping multiple validation +// errors returned by GetCurrentUserRequest.ValidateAll() if the designated +// constraints aren't met. +type GetCurrentUserRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetCurrentUserRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetCurrentUserRequestMultiError) AllErrors() []error { return m } + // GetCurrentUserRequestValidationError is the validation error returned by // GetCurrentUserRequest.Validate if the designated constraints aren't met. type GetCurrentUserRequestValidationError struct { @@ -1017,14 +1614,47 @@ var _ interface { } = GetCurrentUserRequestValidationError{} // Validate checks the field values on ListUsersRequest with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *ListUsersRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListUsersRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListUsersRequestMultiError, or nil if none found. +func (m *ListUsersRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListUsersRequest) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetFields()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetFields()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListUsersRequestValidationError{ + field: "Fields", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListUsersRequestValidationError{ + field: "Fields", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetFields()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListUsersRequestValidationError{ field: "Fields", @@ -1034,9 +1664,29 @@ func (m *ListUsersRequest) Validate() error { } } + if len(errors) > 0 { + return ListUsersRequestMultiError(errors) + } return nil } +// ListUsersRequestMultiError is an error wrapping multiple validation errors +// returned by ListUsersRequest.ValidateAll() if the designated constraints +// aren't met. +type ListUsersRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListUsersRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListUsersRequestMultiError) AllErrors() []error { return m } + // ListUsersRequestValidationError is the validation error returned by // ListUsersRequest.Validate if the designated constraints aren't met. type ListUsersRequestValidationError struct { @@ -1092,17 +1742,50 @@ var _ interface { } = ListUsersRequestValidationError{} // Validate checks the field values on ListUsersResponse with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *ListUsersResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListUsersResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListUsersResponseMultiError, or nil if none found. +func (m *ListUsersResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListUsersResponse) validate(all bool) error { if m == nil { return nil } + var errors []error + for idx, item := range m.GetUsers() { _, _ = idx, item - if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListUsersResponseValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListUsersResponseValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListUsersResponseValidationError{ field: fmt.Sprintf("Users[%v]", idx), @@ -1114,11 +1797,31 @@ func (m *ListUsersResponse) Validate() error { } + if len(errors) > 0 { + return ListUsersResponseMultiError(errors) + } return nil } -// ListUsersResponseValidationError is the validation error returned by -// ListUsersResponse.Validate if the designated constraints aren't met. +// ListUsersResponseMultiError is an error wrapping multiple validation errors +// returned by ListUsersResponse.ValidateAll() if the designated constraints +// aren't met. +type ListUsersResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListUsersResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListUsersResponseMultiError) AllErrors() []error { return m } + +// ListUsersResponseValidationError is the validation error returned by +// ListUsersResponse.Validate if the designated constraints aren't met. type ListUsersResponseValidationError struct { field string reason string @@ -1174,23 +1877,60 @@ var _ interface { } = ListUsersResponseValidationError{} // Validate checks the field values on GroupRequestBody with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *GroupRequestBody) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GroupRequestBody with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GroupRequestBodyMultiError, or nil if none found. +func (m *GroupRequestBody) ValidateAll() error { + return m.validate(true) +} + +func (m *GroupRequestBody) validate(all bool) error { if m == nil { return nil } + var errors []error + if !_GroupRequestBody_Name_Pattern.MatchString(m.GetName()) { - return GroupRequestBodyValidationError{ + err := GroupRequestBodyValidationError{ field: "Name", reason: "value does not match regex pattern \"^[A-Za-z0-9_-]+$\"", } + if !all { + return err + } + errors = append(errors, err) } // no validation rules for Slug - if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GroupRequestBodyValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GroupRequestBodyValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GroupRequestBodyValidationError{ field: "Metadata", @@ -1202,9 +1942,29 @@ func (m *GroupRequestBody) Validate() error { // no validation rules for OrgId + if len(errors) > 0 { + return GroupRequestBodyMultiError(errors) + } return nil } +// GroupRequestBodyMultiError is an error wrapping multiple validation errors +// returned by GroupRequestBody.ValidateAll() if the designated constraints +// aren't met. +type GroupRequestBodyMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GroupRequestBodyMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GroupRequestBodyMultiError) AllErrors() []error { return m } + // GroupRequestBodyValidationError is the validation error returned by // GroupRequestBody.Validate if the designated constraints aren't met. type GroupRequestBodyValidationError struct { @@ -1263,13 +2023,46 @@ var _GroupRequestBody_Name_Pattern = regexp.MustCompile("^[A-Za-z0-9_-]+$") // Validate checks the field values on CreateGroupRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *CreateGroupRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateGroupRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CreateGroupRequestMultiError, or nil if none found. +func (m *CreateGroupRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateGroupRequest) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetBody()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateGroupRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateGroupRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CreateGroupRequestValidationError{ field: "Body", @@ -1279,9 +2072,29 @@ func (m *CreateGroupRequest) Validate() error { } } + if len(errors) > 0 { + return CreateGroupRequestMultiError(errors) + } return nil } +// CreateGroupRequestMultiError is an error wrapping multiple validation errors +// returned by CreateGroupRequest.ValidateAll() if the designated constraints +// aren't met. +type CreateGroupRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateGroupRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CreateGroupRequestMultiError) AllErrors() []error { return m } + // CreateGroupRequestValidationError is the validation error returned by // CreateGroupRequest.Validate if the designated constraints aren't met. type CreateGroupRequestValidationError struct { @@ -1339,26 +2152,63 @@ var _ interface { } = CreateGroupRequestValidationError{} // Validate checks the field values on Group with the rules defined in the -// proto definition for this message. If any rules are violated, an error is returned. +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. func (m *Group) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Group with the rules defined in the +// proto definition for this message. If any rules are violated, the result is +// a list of violation errors wrapped in GroupMultiError, or nil if none found. +func (m *Group) ValidateAll() error { + return m.validate(true) +} + +func (m *Group) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id if !_Group_Name_Pattern.MatchString(m.GetName()) { - return GroupValidationError{ + err := GroupValidationError{ field: "Name", reason: "value does not match regex pattern \"^[A-Za-z0-9_-]+$\"", } + if !all { + return err + } + errors = append(errors, err) } // no validation rules for Slug // no validation rules for OrgId - if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GroupValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GroupValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GroupValidationError{ field: "Metadata", @@ -1368,7 +2218,26 @@ func (m *Group) Validate() error { } } - if v, ok := interface{}(m.GetCreatedAt()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetCreatedAt()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GroupValidationError{ + field: "CreatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GroupValidationError{ + field: "CreatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreatedAt()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GroupValidationError{ field: "CreatedAt", @@ -1378,7 +2247,26 @@ func (m *Group) Validate() error { } } - if v, ok := interface{}(m.GetUpdatedAt()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetUpdatedAt()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GroupValidationError{ + field: "UpdatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GroupValidationError{ + field: "UpdatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdatedAt()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GroupValidationError{ field: "UpdatedAt", @@ -1388,9 +2276,28 @@ func (m *Group) Validate() error { } } + if len(errors) > 0 { + return GroupMultiError(errors) + } return nil } +// GroupMultiError is an error wrapping multiple validation errors returned by +// Group.ValidateAll() if the designated constraints aren't met. +type GroupMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GroupMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GroupMultiError) AllErrors() []error { return m } + // GroupValidationError is the validation error returned by Group.Validate if // the designated constraints aren't met. type GroupValidationError struct { @@ -1449,13 +2356,46 @@ var _Group_Name_Pattern = regexp.MustCompile("^[A-Za-z0-9_-]+$") // Validate checks the field values on CreateGroupResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *CreateGroupResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateGroupResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CreateGroupResponseMultiError, or nil if none found. +func (m *CreateGroupResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateGroupResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetGroup()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetGroup()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateGroupResponseValidationError{ + field: "Group", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateGroupResponseValidationError{ + field: "Group", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetGroup()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CreateGroupResponseValidationError{ field: "Group", @@ -1465,9 +2405,29 @@ func (m *CreateGroupResponse) Validate() error { } } + if len(errors) > 0 { + return CreateGroupResponseMultiError(errors) + } return nil } +// CreateGroupResponseMultiError is an error wrapping multiple validation +// errors returned by CreateGroupResponse.ValidateAll() if the designated +// constraints aren't met. +type CreateGroupResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateGroupResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CreateGroupResponseMultiError) AllErrors() []error { return m } + // CreateGroupResponseValidationError is the validation error returned by // CreateGroupResponse.Validate if the designated constraints aren't met. type CreateGroupResponseValidationError struct { @@ -1525,14 +2485,47 @@ var _ interface { } = CreateGroupResponseValidationError{} // Validate checks the field values on GetGroupResponse with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *GetGroupResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetGroupResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetGroupResponseMultiError, or nil if none found. +func (m *GetGroupResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetGroupResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetGroup()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetGroup()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetGroupResponseValidationError{ + field: "Group", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetGroupResponseValidationError{ + field: "Group", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetGroup()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GetGroupResponseValidationError{ field: "Group", @@ -1542,9 +2535,29 @@ func (m *GetGroupResponse) Validate() error { } } + if len(errors) > 0 { + return GetGroupResponseMultiError(errors) + } return nil } +// GetGroupResponseMultiError is an error wrapping multiple validation errors +// returned by GetGroupResponse.ValidateAll() if the designated constraints +// aren't met. +type GetGroupResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetGroupResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetGroupResponseMultiError) AllErrors() []error { return m } + // GetGroupResponseValidationError is the validation error returned by // GetGroupResponse.Validate if the designated constraints aren't met. type GetGroupResponseValidationError struct { @@ -1601,13 +2614,46 @@ var _ interface { // Validate checks the field values on UpdateGroupResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *UpdateGroupResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateGroupResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdateGroupResponseMultiError, or nil if none found. +func (m *UpdateGroupResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateGroupResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetGroup()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetGroup()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateGroupResponseValidationError{ + field: "Group", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateGroupResponseValidationError{ + field: "Group", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetGroup()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UpdateGroupResponseValidationError{ field: "Group", @@ -1617,9 +2663,29 @@ func (m *UpdateGroupResponse) Validate() error { } } + if len(errors) > 0 { + return UpdateGroupResponseMultiError(errors) + } return nil } +// UpdateGroupResponseMultiError is an error wrapping multiple validation +// errors returned by UpdateGroupResponse.ValidateAll() if the designated +// constraints aren't met. +type UpdateGroupResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateGroupResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UpdateGroupResponseMultiError) AllErrors() []error { return m } + // UpdateGroupResponseValidationError is the validation error returned by // UpdateGroupResponse.Validate if the designated constraints aren't met. type UpdateGroupResponseValidationError struct { @@ -1678,16 +2744,49 @@ var _ interface { // Validate checks the field values on ListGroupUsersResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *ListGroupUsersResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListGroupUsersResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListGroupUsersResponseMultiError, or nil if none found. +func (m *ListGroupUsersResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListGroupUsersResponse) validate(all bool) error { if m == nil { return nil } + var errors []error + for idx, item := range m.GetUsers() { _, _ = idx, item - if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListGroupUsersResponseValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListGroupUsersResponseValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListGroupUsersResponseValidationError{ field: fmt.Sprintf("Users[%v]", idx), @@ -1699,9 +2798,29 @@ func (m *ListGroupUsersResponse) Validate() error { } + if len(errors) > 0 { + return ListGroupUsersResponseMultiError(errors) + } return nil } +// ListGroupUsersResponseMultiError is an error wrapping multiple validation +// errors returned by ListGroupUsersResponse.ValidateAll() if the designated +// constraints aren't met. +type ListGroupUsersResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListGroupUsersResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListGroupUsersResponseMultiError) AllErrors() []error { return m } + // ListGroupUsersResponseValidationError is the validation error returned by // ListGroupUsersResponse.Validate if the designated constraints aren't met. type ListGroupUsersResponseValidationError struct { @@ -1760,15 +2879,48 @@ var _ interface { // Validate checks the field values on UpdateGroupRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *UpdateGroupRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateGroupRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdateGroupRequestMultiError, or nil if none found. +func (m *UpdateGroupRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateGroupRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id - if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetBody()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateGroupRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateGroupRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UpdateGroupRequestValidationError{ field: "Body", @@ -1778,9 +2930,29 @@ func (m *UpdateGroupRequest) Validate() error { } } + if len(errors) > 0 { + return UpdateGroupRequestMultiError(errors) + } return nil } +// UpdateGroupRequestMultiError is an error wrapping multiple validation errors +// returned by UpdateGroupRequest.ValidateAll() if the designated constraints +// aren't met. +type UpdateGroupRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateGroupRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UpdateGroupRequestMultiError) AllErrors() []error { return m } + // UpdateGroupRequestValidationError is the validation error returned by // UpdateGroupRequest.Validate if the designated constraints aren't met. type UpdateGroupRequestValidationError struct { @@ -1839,13 +3011,46 @@ var _ interface { // Validate checks the field values on UpdateCurrentUserRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *UpdateCurrentUserRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateCurrentUserRequest with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdateCurrentUserRequestMultiError, or nil if none found. +func (m *UpdateCurrentUserRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateCurrentUserRequest) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetBody()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateCurrentUserRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateCurrentUserRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UpdateCurrentUserRequestValidationError{ field: "Body", @@ -1855,9 +3060,29 @@ func (m *UpdateCurrentUserRequest) Validate() error { } } + if len(errors) > 0 { + return UpdateCurrentUserRequestMultiError(errors) + } return nil } +// UpdateCurrentUserRequestMultiError is an error wrapping multiple validation +// errors returned by UpdateCurrentUserRequest.ValidateAll() if the designated +// constraints aren't met. +type UpdateCurrentUserRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateCurrentUserRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UpdateCurrentUserRequestMultiError) AllErrors() []error { return m } + // UpdateCurrentUserRequestValidationError is the validation error returned by // UpdateCurrentUserRequest.Validate if the designated constraints aren't met. type UpdateCurrentUserRequestValidationError struct { @@ -1915,18 +3140,52 @@ var _ interface { } = UpdateCurrentUserRequestValidationError{} // Validate checks the field values on GetGroupRequest with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *GetGroupRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetGroupRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetGroupRequestMultiError, or nil if none found. +func (m *GetGroupRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetGroupRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id + if len(errors) > 0 { + return GetGroupRequestMultiError(errors) + } return nil } +// GetGroupRequestMultiError is an error wrapping multiple validation errors +// returned by GetGroupRequest.ValidateAll() if the designated constraints +// aren't met. +type GetGroupRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetGroupRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetGroupRequestMultiError) AllErrors() []error { return m } + // GetGroupRequestValidationError is the validation error returned by // GetGroupRequest.Validate if the designated constraints aren't met. type GetGroupRequestValidationError struct { @@ -1983,17 +3242,51 @@ var _ interface { // Validate checks the field values on ListGroupUsersRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *ListGroupUsersRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListGroupUsersRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListGroupUsersRequestMultiError, or nil if none found. +func (m *ListGroupUsersRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListGroupUsersRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id + if len(errors) > 0 { + return ListGroupUsersRequestMultiError(errors) + } return nil } +// ListGroupUsersRequestMultiError is an error wrapping multiple validation +// errors returned by ListGroupUsersRequest.ValidateAll() if the designated +// constraints aren't met. +type ListGroupUsersRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListGroupUsersRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListGroupUsersRequestMultiError) AllErrors() []error { return m } + // ListGroupUsersRequestValidationError is the validation error returned by // ListGroupUsersRequest.Validate if the designated constraints aren't met. type ListGroupUsersRequestValidationError struct { @@ -2051,18 +3344,52 @@ var _ interface { } = ListGroupUsersRequestValidationError{} // Validate checks the field values on ListGroupsRequest with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *ListGroupsRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListGroupsRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListGroupsRequestMultiError, or nil if none found. +func (m *ListGroupsRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListGroupsRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for UserId + if len(errors) > 0 { + return ListGroupsRequestMultiError(errors) + } return nil } +// ListGroupsRequestMultiError is an error wrapping multiple validation errors +// returned by ListGroupsRequest.ValidateAll() if the designated constraints +// aren't met. +type ListGroupsRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListGroupsRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListGroupsRequestMultiError) AllErrors() []error { return m } + // ListGroupsRequestValidationError is the validation error returned by // ListGroupsRequest.Validate if the designated constraints aren't met. type ListGroupsRequestValidationError struct { @@ -2121,16 +3448,49 @@ var _ interface { // Validate checks the field values on ListGroupsResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *ListGroupsResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListGroupsResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListGroupsResponseMultiError, or nil if none found. +func (m *ListGroupsResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListGroupsResponse) validate(all bool) error { if m == nil { return nil } + var errors []error + for idx, item := range m.GetGroups() { _, _ = idx, item - if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListGroupsResponseValidationError{ + field: fmt.Sprintf("Groups[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListGroupsResponseValidationError{ + field: fmt.Sprintf("Groups[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListGroupsResponseValidationError{ field: fmt.Sprintf("Groups[%v]", idx), @@ -2142,9 +3502,29 @@ func (m *ListGroupsResponse) Validate() error { } + if len(errors) > 0 { + return ListGroupsResponseMultiError(errors) + } return nil } +// ListGroupsResponseMultiError is an error wrapping multiple validation errors +// returned by ListGroupsResponse.ValidateAll() if the designated constraints +// aren't met. +type ListGroupsResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListGroupsResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListGroupsResponseMultiError) AllErrors() []error { return m } + // ListGroupsResponseValidationError is the validation error returned by // ListGroupsResponse.Validate if the designated constraints aren't met. type ListGroupsResponseValidationError struct { @@ -2202,22 +3582,59 @@ var _ interface { } = ListGroupsResponseValidationError{} // Validate checks the field values on Role with the rules defined in the proto -// definition for this message. If any rules are violated, an error is returned. +// definition for this message. If any rules are violated, the first error +// encountered is returned, or nil if there are no violations. func (m *Role) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Role with the rules defined in the +// proto definition for this message. If any rules are violated, the result is +// a list of violation errors wrapped in RoleMultiError, or nil if none found. +func (m *Role) ValidateAll() error { + return m.validate(true) +} + +func (m *Role) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id if !_Role_Name_Pattern.MatchString(m.GetName()) { - return RoleValidationError{ + err := RoleValidationError{ field: "Name", reason: "value does not match regex pattern \"^[A-Za-z0-9_-]+$\"", } + if !all { + return err + } + errors = append(errors, err) } - if v, ok := interface{}(m.GetNamespace()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetNamespace()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleValidationError{ + field: "Namespace", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleValidationError{ + field: "Namespace", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetNamespace()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RoleValidationError{ field: "Namespace", @@ -2227,7 +3644,26 @@ func (m *Role) Validate() error { } } - if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RoleValidationError{ field: "Metadata", @@ -2237,7 +3673,26 @@ func (m *Role) Validate() error { } } - if v, ok := interface{}(m.GetCreatedAt()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetCreatedAt()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleValidationError{ + field: "CreatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleValidationError{ + field: "CreatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreatedAt()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RoleValidationError{ field: "CreatedAt", @@ -2247,7 +3702,26 @@ func (m *Role) Validate() error { } } - if v, ok := interface{}(m.GetUpdatedAt()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetUpdatedAt()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleValidationError{ + field: "UpdatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleValidationError{ + field: "UpdatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdatedAt()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RoleValidationError{ field: "UpdatedAt", @@ -2257,9 +3731,28 @@ func (m *Role) Validate() error { } } + if len(errors) > 0 { + return RoleMultiError(errors) + } return nil } +// RoleMultiError is an error wrapping multiple validation errors returned by +// Role.ValidateAll() if the designated constraints aren't met. +type RoleMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RoleMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m RoleMultiError) AllErrors() []error { return m } + // RoleValidationError is the validation error returned by Role.Validate if the // designated constraints aren't met. type RoleValidationError struct { @@ -2317,25 +3810,62 @@ var _ interface { var _Role_Name_Pattern = regexp.MustCompile("^[A-Za-z0-9_-]+$") // Validate checks the field values on RoleRequestBody with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *RoleRequestBody) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RoleRequestBody with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// RoleRequestBodyMultiError, or nil if none found. +func (m *RoleRequestBody) ValidateAll() error { + return m.validate(true) +} + +func (m *RoleRequestBody) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id if !_RoleRequestBody_Name_Pattern.MatchString(m.GetName()) { - return RoleRequestBodyValidationError{ + err := RoleRequestBodyValidationError{ field: "Name", reason: "value does not match regex pattern \"^[A-Za-z0-9_-]+$\"", } + if !all { + return err + } + errors = append(errors, err) } // no validation rules for NamespaceId - if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleRequestBodyValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleRequestBodyValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RoleRequestBodyValidationError{ field: "Metadata", @@ -2345,9 +3875,29 @@ func (m *RoleRequestBody) Validate() error { } } + if len(errors) > 0 { + return RoleRequestBodyMultiError(errors) + } return nil } +// RoleRequestBodyMultiError is an error wrapping multiple validation errors +// returned by RoleRequestBody.ValidateAll() if the designated constraints +// aren't met. +type RoleRequestBodyMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RoleRequestBodyMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m RoleRequestBodyMultiError) AllErrors() []error { return m } + // RoleRequestBodyValidationError is the validation error returned by // RoleRequestBody.Validate if the designated constraints aren't met. type RoleRequestBodyValidationError struct { @@ -2405,14 +3955,47 @@ var _ interface { var _RoleRequestBody_Name_Pattern = regexp.MustCompile("^[A-Za-z0-9_-]+$") // Validate checks the field values on CreateRoleRequest with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *CreateRoleRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateRoleRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CreateRoleRequestMultiError, or nil if none found. +func (m *CreateRoleRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateRoleRequest) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetBody()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateRoleRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateRoleRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CreateRoleRequestValidationError{ field: "Body", @@ -2422,9 +4005,29 @@ func (m *CreateRoleRequest) Validate() error { } } + if len(errors) > 0 { + return CreateRoleRequestMultiError(errors) + } return nil } +// CreateRoleRequestMultiError is an error wrapping multiple validation errors +// returned by CreateRoleRequest.ValidateAll() if the designated constraints +// aren't met. +type CreateRoleRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateRoleRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CreateRoleRequestMultiError) AllErrors() []error { return m } + // CreateRoleRequestValidationError is the validation error returned by // CreateRoleRequest.Validate if the designated constraints aren't met. type CreateRoleRequestValidationError struct { @@ -2483,13 +4086,46 @@ var _ interface { // Validate checks the field values on CreateRoleResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *CreateRoleResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateRoleResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CreateRoleResponseMultiError, or nil if none found. +func (m *CreateRoleResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateRoleResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateRoleResponseValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateRoleResponseValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CreateRoleResponseValidationError{ field: "Role", @@ -2499,9 +4135,29 @@ func (m *CreateRoleResponse) Validate() error { } } + if len(errors) > 0 { + return CreateRoleResponseMultiError(errors) + } return nil } +// CreateRoleResponseMultiError is an error wrapping multiple validation errors +// returned by CreateRoleResponse.ValidateAll() if the designated constraints +// aren't met. +type CreateRoleResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateRoleResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CreateRoleResponseMultiError) AllErrors() []error { return m } + // CreateRoleResponseValidationError is the validation error returned by // CreateRoleResponse.Validate if the designated constraints aren't met. type CreateRoleResponseValidationError struct { @@ -2559,14 +4215,47 @@ var _ interface { } = CreateRoleResponseValidationError{} // Validate checks the field values on GetRoleResponse with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *GetRoleResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetRoleResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetRoleResponseMultiError, or nil if none found. +func (m *GetRoleResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetRoleResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetRoleResponseValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetRoleResponseValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GetRoleResponseValidationError{ field: "Role", @@ -2576,9 +4265,29 @@ func (m *GetRoleResponse) Validate() error { } } + if len(errors) > 0 { + return GetRoleResponseMultiError(errors) + } return nil } +// GetRoleResponseMultiError is an error wrapping multiple validation errors +// returned by GetRoleResponse.ValidateAll() if the designated constraints +// aren't met. +type GetRoleResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetRoleResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetRoleResponseMultiError) AllErrors() []error { return m } + // GetRoleResponseValidationError is the validation error returned by // GetRoleResponse.Validate if the designated constraints aren't met. type GetRoleResponseValidationError struct { @@ -2635,13 +4344,46 @@ var _ interface { // Validate checks the field values on UpdateRoleResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *UpdateRoleResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateRoleResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdateRoleResponseMultiError, or nil if none found. +func (m *UpdateRoleResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateRoleResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateRoleResponseValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateRoleResponseValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UpdateRoleResponseValidationError{ field: "Role", @@ -2651,9 +4393,29 @@ func (m *UpdateRoleResponse) Validate() error { } } + if len(errors) > 0 { + return UpdateRoleResponseMultiError(errors) + } return nil } +// UpdateRoleResponseMultiError is an error wrapping multiple validation errors +// returned by UpdateRoleResponse.ValidateAll() if the designated constraints +// aren't met. +type UpdateRoleResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateRoleResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UpdateRoleResponseMultiError) AllErrors() []error { return m } + // UpdateRoleResponseValidationError is the validation error returned by // UpdateRoleResponse.Validate if the designated constraints aren't met. type UpdateRoleResponseValidationError struct { @@ -2711,18 +4473,52 @@ var _ interface { } = UpdateRoleResponseValidationError{} // Validate checks the field values on GetRoleRequest with the rules defined in -// the proto definition for this message. If any rules are violated, an error -// is returned. +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. func (m *GetRoleRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetRoleRequest with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in GetRoleRequestMultiError, +// or nil if none found. +func (m *GetRoleRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetRoleRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id + if len(errors) > 0 { + return GetRoleRequestMultiError(errors) + } return nil } +// GetRoleRequestMultiError is an error wrapping multiple validation errors +// returned by GetRoleRequest.ValidateAll() if the designated constraints +// aren't met. +type GetRoleRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetRoleRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetRoleRequestMultiError) AllErrors() []error { return m } + // GetRoleRequestValidationError is the validation error returned by // GetRoleRequest.Validate if the designated constraints aren't met. type GetRoleRequestValidationError struct { @@ -2778,16 +4574,49 @@ var _ interface { } = GetRoleRequestValidationError{} // Validate checks the field values on UpdateRoleRequest with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *UpdateRoleRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateRoleRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdateRoleRequestMultiError, or nil if none found. +func (m *UpdateRoleRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateRoleRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id - if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetBody()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateRoleRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateRoleRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UpdateRoleRequestValidationError{ field: "Body", @@ -2797,9 +4626,29 @@ func (m *UpdateRoleRequest) Validate() error { } } + if len(errors) > 0 { + return UpdateRoleRequestMultiError(errors) + } return nil } +// UpdateRoleRequestMultiError is an error wrapping multiple validation errors +// returned by UpdateRoleRequest.ValidateAll() if the designated constraints +// aren't met. +type UpdateRoleRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateRoleRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UpdateRoleRequestMultiError) AllErrors() []error { return m } + // UpdateRoleRequestValidationError is the validation error returned by // UpdateRoleRequest.Validate if the designated constraints aren't met. type UpdateRoleRequestValidationError struct { @@ -2857,16 +4706,50 @@ var _ interface { } = UpdateRoleRequestValidationError{} // Validate checks the field values on ListRolesRequest with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *ListRolesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListRolesRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListRolesRequestMultiError, or nil if none found. +func (m *ListRolesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListRolesRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + + if len(errors) > 0 { + return ListRolesRequestMultiError(errors) + } return nil } +// ListRolesRequestMultiError is an error wrapping multiple validation errors +// returned by ListRolesRequest.ValidateAll() if the designated constraints +// aren't met. +type ListRolesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListRolesRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListRolesRequestMultiError) AllErrors() []error { return m } + // ListRolesRequestValidationError is the validation error returned by // ListRolesRequest.Validate if the designated constraints aren't met. type ListRolesRequestValidationError struct { @@ -2922,17 +4805,50 @@ var _ interface { } = ListRolesRequestValidationError{} // Validate checks the field values on ListRolesResponse with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *ListRolesResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListRolesResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListRolesResponseMultiError, or nil if none found. +func (m *ListRolesResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListRolesResponse) validate(all bool) error { if m == nil { return nil } + var errors []error + for idx, item := range m.GetRoles() { _, _ = idx, item - if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListRolesResponseValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListRolesResponseValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListRolesResponseValidationError{ field: fmt.Sprintf("Roles[%v]", idx), @@ -2944,9 +4860,29 @@ func (m *ListRolesResponse) Validate() error { } + if len(errors) > 0 { + return ListRolesResponseMultiError(errors) + } return nil } +// ListRolesResponseMultiError is an error wrapping multiple validation errors +// returned by ListRolesResponse.ValidateAll() if the designated constraints +// aren't met. +type ListRolesResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListRolesResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListRolesResponseMultiError) AllErrors() []error { return m } + // ListRolesResponseValidationError is the validation error returned by // ListRolesResponse.Validate if the designated constraints aren't met. type ListRolesResponseValidationError struct { @@ -3005,22 +4941,59 @@ var _ interface { // Validate checks the field values on OrganizationRequestBody with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *OrganizationRequestBody) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on OrganizationRequestBody with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// OrganizationRequestBodyMultiError, or nil if none found. +func (m *OrganizationRequestBody) ValidateAll() error { + return m.validate(true) +} + +func (m *OrganizationRequestBody) validate(all bool) error { if m == nil { return nil } + var errors []error + if !_OrganizationRequestBody_Name_Pattern.MatchString(m.GetName()) { - return OrganizationRequestBodyValidationError{ + err := OrganizationRequestBodyValidationError{ field: "Name", reason: "value does not match regex pattern \"^[A-Za-z0-9_-]+$\"", } + if !all { + return err + } + errors = append(errors, err) } // no validation rules for Slug - if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, OrganizationRequestBodyValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, OrganizationRequestBodyValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return OrganizationRequestBodyValidationError{ field: "Metadata", @@ -3030,9 +5003,29 @@ func (m *OrganizationRequestBody) Validate() error { } } + if len(errors) > 0 { + return OrganizationRequestBodyMultiError(errors) + } return nil } +// OrganizationRequestBodyMultiError is an error wrapping multiple validation +// errors returned by OrganizationRequestBody.ValidateAll() if the designated +// constraints aren't met. +type OrganizationRequestBodyMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m OrganizationRequestBodyMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m OrganizationRequestBodyMultiError) AllErrors() []error { return m } + // OrganizationRequestBodyValidationError is the validation error returned by // OrganizationRequestBody.Validate if the designated constraints aren't met. type OrganizationRequestBodyValidationError struct { @@ -3093,13 +5086,46 @@ var _OrganizationRequestBody_Name_Pattern = regexp.MustCompile("^[A-Za-z0-9_-]+$ // Validate checks the field values on CreateOrganizationRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *CreateOrganizationRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateOrganizationRequest with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CreateOrganizationRequestMultiError, or nil if none found. +func (m *CreateOrganizationRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateOrganizationRequest) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetBody()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateOrganizationRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateOrganizationRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CreateOrganizationRequestValidationError{ field: "Body", @@ -3109,9 +5135,29 @@ func (m *CreateOrganizationRequest) Validate() error { } } + if len(errors) > 0 { + return CreateOrganizationRequestMultiError(errors) + } return nil } +// CreateOrganizationRequestMultiError is an error wrapping multiple validation +// errors returned by CreateOrganizationRequest.ValidateAll() if the +// designated constraints aren't met. +type CreateOrganizationRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateOrganizationRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CreateOrganizationRequestMultiError) AllErrors() []error { return m } + // CreateOrganizationRequestValidationError is the validation error returned by // CreateOrganizationRequest.Validate if the designated constraints aren't met. type CreateOrganizationRequestValidationError struct { @@ -3169,25 +5215,62 @@ var _ interface { } = CreateOrganizationRequestValidationError{} // Validate checks the field values on Organization with the rules defined in -// the proto definition for this message. If any rules are violated, an error -// is returned. +// the proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. func (m *Organization) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Organization with the rules defined +// in the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in OrganizationMultiError, or +// nil if none found. +func (m *Organization) ValidateAll() error { + return m.validate(true) +} + +func (m *Organization) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id if !_Organization_Name_Pattern.MatchString(m.GetName()) { - return OrganizationValidationError{ + err := OrganizationValidationError{ field: "Name", reason: "value does not match regex pattern \"^[A-Za-z0-9_-]+$\"", } + if !all { + return err + } + errors = append(errors, err) } // no validation rules for Slug - if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, OrganizationValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, OrganizationValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return OrganizationValidationError{ field: "Metadata", @@ -3197,7 +5280,26 @@ func (m *Organization) Validate() error { } } - if v, ok := interface{}(m.GetCreatedAt()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetCreatedAt()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, OrganizationValidationError{ + field: "CreatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, OrganizationValidationError{ + field: "CreatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreatedAt()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return OrganizationValidationError{ field: "CreatedAt", @@ -3207,7 +5309,26 @@ func (m *Organization) Validate() error { } } - if v, ok := interface{}(m.GetUpdatedAt()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetUpdatedAt()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, OrganizationValidationError{ + field: "UpdatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, OrganizationValidationError{ + field: "UpdatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdatedAt()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return OrganizationValidationError{ field: "UpdatedAt", @@ -3217,9 +5338,28 @@ func (m *Organization) Validate() error { } } + if len(errors) > 0 { + return OrganizationMultiError(errors) + } return nil } +// OrganizationMultiError is an error wrapping multiple validation errors +// returned by Organization.ValidateAll() if the designated constraints aren't met. +type OrganizationMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m OrganizationMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m OrganizationMultiError) AllErrors() []error { return m } + // OrganizationValidationError is the validation error returned by // Organization.Validate if the designated constraints aren't met. type OrganizationValidationError struct { @@ -3278,13 +5418,46 @@ var _Organization_Name_Pattern = regexp.MustCompile("^[A-Za-z0-9_-]+$") // Validate checks the field values on CreateOrganizationResponse with the // rules defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *CreateOrganizationResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateOrganizationResponse with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CreateOrganizationResponseMultiError, or nil if none found. +func (m *CreateOrganizationResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateOrganizationResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetOrganization()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetOrganization()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateOrganizationResponseValidationError{ + field: "Organization", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateOrganizationResponseValidationError{ + field: "Organization", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetOrganization()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CreateOrganizationResponseValidationError{ field: "Organization", @@ -3294,9 +5467,29 @@ func (m *CreateOrganizationResponse) Validate() error { } } + if len(errors) > 0 { + return CreateOrganizationResponseMultiError(errors) + } return nil } +// CreateOrganizationResponseMultiError is an error wrapping multiple +// validation errors returned by CreateOrganizationResponse.ValidateAll() if +// the designated constraints aren't met. +type CreateOrganizationResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateOrganizationResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CreateOrganizationResponseMultiError) AllErrors() []error { return m } + // CreateOrganizationResponseValidationError is the validation error returned // by CreateOrganizationResponse.Validate if the designated constraints aren't met. type CreateOrganizationResponseValidationError struct { @@ -3355,13 +5548,46 @@ var _ interface { // Validate checks the field values on GetOrganizationResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *GetOrganizationResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetOrganizationResponse with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetOrganizationResponseMultiError, or nil if none found. +func (m *GetOrganizationResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetOrganizationResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetOrganization()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetOrganization()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetOrganizationResponseValidationError{ + field: "Organization", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetOrganizationResponseValidationError{ + field: "Organization", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetOrganization()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GetOrganizationResponseValidationError{ field: "Organization", @@ -3371,9 +5597,29 @@ func (m *GetOrganizationResponse) Validate() error { } } + if len(errors) > 0 { + return GetOrganizationResponseMultiError(errors) + } return nil } +// GetOrganizationResponseMultiError is an error wrapping multiple validation +// errors returned by GetOrganizationResponse.ValidateAll() if the designated +// constraints aren't met. +type GetOrganizationResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetOrganizationResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetOrganizationResponseMultiError) AllErrors() []error { return m } + // GetOrganizationResponseValidationError is the validation error returned by // GetOrganizationResponse.Validate if the designated constraints aren't met. type GetOrganizationResponseValidationError struct { @@ -3432,13 +5678,46 @@ var _ interface { // Validate checks the field values on UpdateOrganizationResponse with the // rules defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *UpdateOrganizationResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateOrganizationResponse with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdateOrganizationResponseMultiError, or nil if none found. +func (m *UpdateOrganizationResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateOrganizationResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetOrganization()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetOrganization()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateOrganizationResponseValidationError{ + field: "Organization", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateOrganizationResponseValidationError{ + field: "Organization", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetOrganization()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UpdateOrganizationResponseValidationError{ field: "Organization", @@ -3448,9 +5727,29 @@ func (m *UpdateOrganizationResponse) Validate() error { } } + if len(errors) > 0 { + return UpdateOrganizationResponseMultiError(errors) + } return nil } +// UpdateOrganizationResponseMultiError is an error wrapping multiple +// validation errors returned by UpdateOrganizationResponse.ValidateAll() if +// the designated constraints aren't met. +type UpdateOrganizationResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateOrganizationResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UpdateOrganizationResponseMultiError) AllErrors() []error { return m } + // UpdateOrganizationResponseValidationError is the validation error returned // by UpdateOrganizationResponse.Validate if the designated constraints aren't met. type UpdateOrganizationResponseValidationError struct { @@ -3509,15 +5808,49 @@ var _ interface { // Validate checks the field values on ListOrganizationsRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *ListOrganizationsRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListOrganizationsRequest with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListOrganizationsRequestMultiError, or nil if none found. +func (m *ListOrganizationsRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListOrganizationsRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + + if len(errors) > 0 { + return ListOrganizationsRequestMultiError(errors) + } return nil } +// ListOrganizationsRequestMultiError is an error wrapping multiple validation +// errors returned by ListOrganizationsRequest.ValidateAll() if the designated +// constraints aren't met. +type ListOrganizationsRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListOrganizationsRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListOrganizationsRequestMultiError) AllErrors() []error { return m } + // ListOrganizationsRequestValidationError is the validation error returned by // ListOrganizationsRequest.Validate if the designated constraints aren't met. type ListOrganizationsRequestValidationError struct { @@ -3576,16 +5909,49 @@ var _ interface { // Validate checks the field values on ListOrganizationsResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *ListOrganizationsResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListOrganizationsResponse with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListOrganizationsResponseMultiError, or nil if none found. +func (m *ListOrganizationsResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListOrganizationsResponse) validate(all bool) error { if m == nil { return nil } + var errors []error + for idx, item := range m.GetOrganizations() { _, _ = idx, item - if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListOrganizationsResponseValidationError{ + field: fmt.Sprintf("Organizations[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListOrganizationsResponseValidationError{ + field: fmt.Sprintf("Organizations[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListOrganizationsResponseValidationError{ field: fmt.Sprintf("Organizations[%v]", idx), @@ -3597,9 +5963,29 @@ func (m *ListOrganizationsResponse) Validate() error { } + if len(errors) > 0 { + return ListOrganizationsResponseMultiError(errors) + } return nil } +// ListOrganizationsResponseMultiError is an error wrapping multiple validation +// errors returned by ListOrganizationsResponse.ValidateAll() if the +// designated constraints aren't met. +type ListOrganizationsResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListOrganizationsResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListOrganizationsResponseMultiError) AllErrors() []error { return m } + // ListOrganizationsResponseValidationError is the validation error returned by // ListOrganizationsResponse.Validate if the designated constraints aren't met. type ListOrganizationsResponseValidationError struct { @@ -3658,17 +6044,51 @@ var _ interface { // Validate checks the field values on GetOrganizationRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *GetOrganizationRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetOrganizationRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetOrganizationRequestMultiError, or nil if none found. +func (m *GetOrganizationRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetOrganizationRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id + if len(errors) > 0 { + return GetOrganizationRequestMultiError(errors) + } return nil } +// GetOrganizationRequestMultiError is an error wrapping multiple validation +// errors returned by GetOrganizationRequest.ValidateAll() if the designated +// constraints aren't met. +type GetOrganizationRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetOrganizationRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetOrganizationRequestMultiError) AllErrors() []error { return m } + // GetOrganizationRequestValidationError is the validation error returned by // GetOrganizationRequest.Validate if the designated constraints aren't met. type GetOrganizationRequestValidationError struct { @@ -3727,15 +6147,48 @@ var _ interface { // Validate checks the field values on UpdateOrganizationRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *UpdateOrganizationRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateOrganizationRequest with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdateOrganizationRequestMultiError, or nil if none found. +func (m *UpdateOrganizationRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateOrganizationRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id - if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetBody()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateOrganizationRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateOrganizationRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UpdateOrganizationRequestValidationError{ field: "Body", @@ -3745,9 +6198,29 @@ func (m *UpdateOrganizationRequest) Validate() error { } } + if len(errors) > 0 { + return UpdateOrganizationRequestMultiError(errors) + } return nil } +// UpdateOrganizationRequestMultiError is an error wrapping multiple validation +// errors returned by UpdateOrganizationRequest.ValidateAll() if the +// designated constraints aren't met. +type UpdateOrganizationRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateOrganizationRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UpdateOrganizationRequestMultiError) AllErrors() []error { return m } + // UpdateOrganizationRequestValidationError is the validation error returned by // UpdateOrganizationRequest.Validate if the designated constraints aren't met. type UpdateOrganizationRequestValidationError struct { @@ -3806,22 +6279,59 @@ var _ interface { // Validate checks the field values on ProjectRequestBody with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *ProjectRequestBody) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ProjectRequestBody with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ProjectRequestBodyMultiError, or nil if none found. +func (m *ProjectRequestBody) ValidateAll() error { + return m.validate(true) +} + +func (m *ProjectRequestBody) validate(all bool) error { if m == nil { return nil } + var errors []error + if !_ProjectRequestBody_Name_Pattern.MatchString(m.GetName()) { - return ProjectRequestBodyValidationError{ + err := ProjectRequestBodyValidationError{ field: "Name", reason: "value does not match regex pattern \"^[A-Za-z0-9_-]+$\"", } + if !all { + return err + } + errors = append(errors, err) } // no validation rules for Slug - if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ProjectRequestBodyValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ProjectRequestBodyValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ProjectRequestBodyValidationError{ field: "Metadata", @@ -3833,9 +6343,29 @@ func (m *ProjectRequestBody) Validate() error { // no validation rules for OrgId + if len(errors) > 0 { + return ProjectRequestBodyMultiError(errors) + } return nil } +// ProjectRequestBodyMultiError is an error wrapping multiple validation errors +// returned by ProjectRequestBody.ValidateAll() if the designated constraints +// aren't met. +type ProjectRequestBodyMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ProjectRequestBodyMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ProjectRequestBodyMultiError) AllErrors() []error { return m } + // ProjectRequestBodyValidationError is the validation error returned by // ProjectRequestBody.Validate if the designated constraints aren't met. type ProjectRequestBodyValidationError struct { @@ -3896,13 +6426,46 @@ var _ProjectRequestBody_Name_Pattern = regexp.MustCompile("^[A-Za-z0-9_-]+$") // Validate checks the field values on CreateProjectRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *CreateProjectRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateProjectRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CreateProjectRequestMultiError, or nil if none found. +func (m *CreateProjectRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateProjectRequest) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetBody()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateProjectRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateProjectRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CreateProjectRequestValidationError{ field: "Body", @@ -3912,9 +6475,29 @@ func (m *CreateProjectRequest) Validate() error { } } + if len(errors) > 0 { + return CreateProjectRequestMultiError(errors) + } return nil } +// CreateProjectRequestMultiError is an error wrapping multiple validation +// errors returned by CreateProjectRequest.ValidateAll() if the designated +// constraints aren't met. +type CreateProjectRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateProjectRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CreateProjectRequestMultiError) AllErrors() []error { return m } + // CreateProjectRequestValidationError is the validation error returned by // CreateProjectRequest.Validate if the designated constraints aren't met. type CreateProjectRequestValidationError struct { @@ -3972,26 +6555,63 @@ var _ interface { } = CreateProjectRequestValidationError{} // Validate checks the field values on Project with the rules defined in the -// proto definition for this message. If any rules are violated, an error is returned. +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. func (m *Project) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Project with the rules defined in the +// proto definition for this message. If any rules are violated, the result is +// a list of violation errors wrapped in ProjectMultiError, or nil if none found. +func (m *Project) ValidateAll() error { + return m.validate(true) +} + +func (m *Project) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id if !_Project_Name_Pattern.MatchString(m.GetName()) { - return ProjectValidationError{ + err := ProjectValidationError{ field: "Name", reason: "value does not match regex pattern \"^[A-Za-z0-9_-]+$\"", } + if !all { + return err + } + errors = append(errors, err) } // no validation rules for Slug // no validation rules for OrgId - if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetMetadata()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ProjectValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ProjectValidationError{ + field: "Metadata", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ProjectValidationError{ field: "Metadata", @@ -4001,7 +6621,26 @@ func (m *Project) Validate() error { } } - if v, ok := interface{}(m.GetCreatedAt()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetCreatedAt()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ProjectValidationError{ + field: "CreatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ProjectValidationError{ + field: "CreatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreatedAt()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ProjectValidationError{ field: "CreatedAt", @@ -4011,7 +6650,26 @@ func (m *Project) Validate() error { } } - if v, ok := interface{}(m.GetUpdatedAt()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetUpdatedAt()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ProjectValidationError{ + field: "UpdatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ProjectValidationError{ + field: "UpdatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdatedAt()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ProjectValidationError{ field: "UpdatedAt", @@ -4021,9 +6679,28 @@ func (m *Project) Validate() error { } } + if len(errors) > 0 { + return ProjectMultiError(errors) + } return nil } +// ProjectMultiError is an error wrapping multiple validation errors returned +// by Project.ValidateAll() if the designated constraints aren't met. +type ProjectMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ProjectMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ProjectMultiError) AllErrors() []error { return m } + // ProjectValidationError is the validation error returned by Project.Validate // if the designated constraints aren't met. type ProjectValidationError struct { @@ -4082,13 +6759,46 @@ var _Project_Name_Pattern = regexp.MustCompile("^[A-Za-z0-9_-]+$") // Validate checks the field values on CreateProjectResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *CreateProjectResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateProjectResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CreateProjectResponseMultiError, or nil if none found. +func (m *CreateProjectResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateProjectResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetProject()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetProject()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateProjectResponseValidationError{ + field: "Project", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateProjectResponseValidationError{ + field: "Project", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetProject()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CreateProjectResponseValidationError{ field: "Project", @@ -4098,9 +6808,29 @@ func (m *CreateProjectResponse) Validate() error { } } + if len(errors) > 0 { + return CreateProjectResponseMultiError(errors) + } return nil } +// CreateProjectResponseMultiError is an error wrapping multiple validation +// errors returned by CreateProjectResponse.ValidateAll() if the designated +// constraints aren't met. +type CreateProjectResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateProjectResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CreateProjectResponseMultiError) AllErrors() []error { return m } + // CreateProjectResponseValidationError is the validation error returned by // CreateProjectResponse.Validate if the designated constraints aren't met. type CreateProjectResponseValidationError struct { @@ -4159,13 +6889,46 @@ var _ interface { // Validate checks the field values on GetProjectResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *GetProjectResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetProjectResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetProjectResponseMultiError, or nil if none found. +func (m *GetProjectResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetProjectResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetProject()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetProject()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetProjectResponseValidationError{ + field: "Project", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetProjectResponseValidationError{ + field: "Project", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetProject()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GetProjectResponseValidationError{ field: "Project", @@ -4175,9 +6938,29 @@ func (m *GetProjectResponse) Validate() error { } } + if len(errors) > 0 { + return GetProjectResponseMultiError(errors) + } return nil } +// GetProjectResponseMultiError is an error wrapping multiple validation errors +// returned by GetProjectResponse.ValidateAll() if the designated constraints +// aren't met. +type GetProjectResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetProjectResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetProjectResponseMultiError) AllErrors() []error { return m } + // GetProjectResponseValidationError is the validation error returned by // GetProjectResponse.Validate if the designated constraints aren't met. type GetProjectResponseValidationError struct { @@ -4236,13 +7019,46 @@ var _ interface { // Validate checks the field values on UpdateProjectResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *UpdateProjectResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateProjectResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdateProjectResponseMultiError, or nil if none found. +func (m *UpdateProjectResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateProjectResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetProject()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetProject()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateProjectResponseValidationError{ + field: "Project", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateProjectResponseValidationError{ + field: "Project", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetProject()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UpdateProjectResponseValidationError{ field: "Project", @@ -4252,9 +7068,29 @@ func (m *UpdateProjectResponse) Validate() error { } } + if len(errors) > 0 { + return UpdateProjectResponseMultiError(errors) + } return nil } +// UpdateProjectResponseMultiError is an error wrapping multiple validation +// errors returned by UpdateProjectResponse.ValidateAll() if the designated +// constraints aren't met. +type UpdateProjectResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateProjectResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UpdateProjectResponseMultiError) AllErrors() []error { return m } + // UpdateProjectResponseValidationError is the validation error returned by // UpdateProjectResponse.Validate if the designated constraints aren't met. type UpdateProjectResponseValidationError struct { @@ -4313,15 +7149,49 @@ var _ interface { // Validate checks the field values on ListProjectsRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *ListProjectsRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListProjectsRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListProjectsRequestMultiError, or nil if none found. +func (m *ListProjectsRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListProjectsRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + + if len(errors) > 0 { + return ListProjectsRequestMultiError(errors) + } return nil } +// ListProjectsRequestMultiError is an error wrapping multiple validation +// errors returned by ListProjectsRequest.ValidateAll() if the designated +// constraints aren't met. +type ListProjectsRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListProjectsRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListProjectsRequestMultiError) AllErrors() []error { return m } + // ListProjectsRequestValidationError is the validation error returned by // ListProjectsRequest.Validate if the designated constraints aren't met. type ListProjectsRequestValidationError struct { @@ -4380,16 +7250,49 @@ var _ interface { // Validate checks the field values on ListProjectsResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *ListProjectsResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListProjectsResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListProjectsResponseMultiError, or nil if none found. +func (m *ListProjectsResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListProjectsResponse) validate(all bool) error { if m == nil { return nil } + var errors []error + for idx, item := range m.GetProjects() { _, _ = idx, item - if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListProjectsResponseValidationError{ + field: fmt.Sprintf("Projects[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListProjectsResponseValidationError{ + field: fmt.Sprintf("Projects[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListProjectsResponseValidationError{ field: fmt.Sprintf("Projects[%v]", idx), @@ -4401,9 +7304,29 @@ func (m *ListProjectsResponse) Validate() error { } + if len(errors) > 0 { + return ListProjectsResponseMultiError(errors) + } return nil } +// ListProjectsResponseMultiError is an error wrapping multiple validation +// errors returned by ListProjectsResponse.ValidateAll() if the designated +// constraints aren't met. +type ListProjectsResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListProjectsResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListProjectsResponseMultiError) AllErrors() []error { return m } + // ListProjectsResponseValidationError is the validation error returned by // ListProjectsResponse.Validate if the designated constraints aren't met. type ListProjectsResponseValidationError struct { @@ -4461,18 +7384,52 @@ var _ interface { } = ListProjectsResponseValidationError{} // Validate checks the field values on GetProjectRequest with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *GetProjectRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetProjectRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetProjectRequestMultiError, or nil if none found. +func (m *GetProjectRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetProjectRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id + if len(errors) > 0 { + return GetProjectRequestMultiError(errors) + } return nil } +// GetProjectRequestMultiError is an error wrapping multiple validation errors +// returned by GetProjectRequest.ValidateAll() if the designated constraints +// aren't met. +type GetProjectRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetProjectRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetProjectRequestMultiError) AllErrors() []error { return m } + // GetProjectRequestValidationError is the validation error returned by // GetProjectRequest.Validate if the designated constraints aren't met. type GetProjectRequestValidationError struct { @@ -4531,15 +7488,48 @@ var _ interface { // Validate checks the field values on UpdateProjectRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *UpdateProjectRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateProjectRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdateProjectRequestMultiError, or nil if none found. +func (m *UpdateProjectRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateProjectRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id - if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetBody()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateProjectRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateProjectRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UpdateProjectRequestValidationError{ field: "Body", @@ -4549,9 +7539,29 @@ func (m *UpdateProjectRequest) Validate() error { } } + if len(errors) > 0 { + return UpdateProjectRequestMultiError(errors) + } return nil } +// UpdateProjectRequestMultiError is an error wrapping multiple validation +// errors returned by UpdateProjectRequest.ValidateAll() if the designated +// constraints aren't met. +type UpdateProjectRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateProjectRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UpdateProjectRequestMultiError) AllErrors() []error { return m } + // UpdateProjectRequestValidationError is the validation error returned by // UpdateProjectRequest.Validate if the designated constraints aren't met. type UpdateProjectRequestValidationError struct { @@ -4609,22 +7619,59 @@ var _ interface { } = UpdateProjectRequestValidationError{} // Validate checks the field values on Action with the rules defined in the -// proto definition for this message. If any rules are violated, an error is returned. +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. func (m *Action) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Action with the rules defined in the +// proto definition for this message. If any rules are violated, the result is +// a list of violation errors wrapped in ActionMultiError, or nil if none found. +func (m *Action) ValidateAll() error { + return m.validate(true) +} + +func (m *Action) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id if !_Action_Name_Pattern.MatchString(m.GetName()) { - return ActionValidationError{ + err := ActionValidationError{ field: "Name", reason: "value does not match regex pattern \"^[A-Za-z0-9_-]+$\"", } + if !all { + return err + } + errors = append(errors, err) } - if v, ok := interface{}(m.GetNamespace()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetNamespace()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ActionValidationError{ + field: "Namespace", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ActionValidationError{ + field: "Namespace", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetNamespace()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ActionValidationError{ field: "Namespace", @@ -4634,7 +7681,26 @@ func (m *Action) Validate() error { } } - if v, ok := interface{}(m.GetCreatedAt()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetCreatedAt()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ActionValidationError{ + field: "CreatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ActionValidationError{ + field: "CreatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreatedAt()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ActionValidationError{ field: "CreatedAt", @@ -4644,7 +7710,26 @@ func (m *Action) Validate() error { } } - if v, ok := interface{}(m.GetUpdatedAt()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetUpdatedAt()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ActionValidationError{ + field: "UpdatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ActionValidationError{ + field: "UpdatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdatedAt()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ActionValidationError{ field: "UpdatedAt", @@ -4654,9 +7739,28 @@ func (m *Action) Validate() error { } } + if len(errors) > 0 { + return ActionMultiError(errors) + } return nil } +// ActionMultiError is an error wrapping multiple validation errors returned by +// Action.ValidateAll() if the designated constraints aren't met. +type ActionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ActionMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ActionMultiError) AllErrors() []error { return m } + // ActionValidationError is the validation error returned by Action.Validate if // the designated constraints aren't met. type ActionValidationError struct { @@ -4714,22 +7818,60 @@ var _ interface { var _Action_Name_Pattern = regexp.MustCompile("^[A-Za-z0-9_-]+$") // Validate checks the field values on Namespace with the rules defined in the -// proto definition for this message. If any rules are violated, an error is returned. +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. func (m *Namespace) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Namespace with the rules defined in +// the proto definition for this message. If any rules are violated, the +// result is a list of violation errors wrapped in NamespaceMultiError, or nil +// if none found. +func (m *Namespace) ValidateAll() error { + return m.validate(true) +} + +func (m *Namespace) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id if !_Namespace_Name_Pattern.MatchString(m.GetName()) { - return NamespaceValidationError{ + err := NamespaceValidationError{ field: "Name", reason: "value does not match regex pattern \"^[A-Za-z0-9_-]+$\"", } - } - - if v, ok := interface{}(m.GetCreatedAt()).(interface{ Validate() error }); ok { + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetCreatedAt()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, NamespaceValidationError{ + field: "CreatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, NamespaceValidationError{ + field: "CreatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreatedAt()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return NamespaceValidationError{ field: "CreatedAt", @@ -4739,7 +7881,26 @@ func (m *Namespace) Validate() error { } } - if v, ok := interface{}(m.GetUpdatedAt()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetUpdatedAt()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, NamespaceValidationError{ + field: "UpdatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, NamespaceValidationError{ + field: "UpdatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdatedAt()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return NamespaceValidationError{ field: "UpdatedAt", @@ -4749,9 +7910,28 @@ func (m *Namespace) Validate() error { } } + if len(errors) > 0 { + return NamespaceMultiError(errors) + } return nil } +// NamespaceMultiError is an error wrapping multiple validation errors returned +// by Namespace.ValidateAll() if the designated constraints aren't met. +type NamespaceMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m NamespaceMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m NamespaceMultiError) AllErrors() []error { return m } + // NamespaceValidationError is the validation error returned by // Namespace.Validate if the designated constraints aren't met. type NamespaceValidationError struct { @@ -4809,15 +7989,48 @@ var _ interface { var _Namespace_Name_Pattern = regexp.MustCompile("^[A-Za-z0-9_-]+$") // Validate checks the field values on Policy with the rules defined in the -// proto definition for this message. If any rules are violated, an error is returned. +// proto definition for this message. If any rules are violated, the first +// error encountered is returned, or nil if there are no violations. func (m *Policy) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Policy with the rules defined in the +// proto definition for this message. If any rules are violated, the result is +// a list of violation errors wrapped in PolicyMultiError, or nil if none found. +func (m *Policy) ValidateAll() error { + return m.validate(true) +} + +func (m *Policy) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id - if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PolicyValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PolicyValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return PolicyValidationError{ field: "Role", @@ -4827,7 +8040,26 @@ func (m *Policy) Validate() error { } } - if v, ok := interface{}(m.GetAction()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetAction()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PolicyValidationError{ + field: "Action", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PolicyValidationError{ + field: "Action", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetAction()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return PolicyValidationError{ field: "Action", @@ -4837,7 +8069,26 @@ func (m *Policy) Validate() error { } } - if v, ok := interface{}(m.GetNamespace()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetNamespace()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PolicyValidationError{ + field: "Namespace", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PolicyValidationError{ + field: "Namespace", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetNamespace()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return PolicyValidationError{ field: "Namespace", @@ -4847,7 +8098,26 @@ func (m *Policy) Validate() error { } } - if v, ok := interface{}(m.GetCreatedAt()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetCreatedAt()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PolicyValidationError{ + field: "CreatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PolicyValidationError{ + field: "CreatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreatedAt()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return PolicyValidationError{ field: "CreatedAt", @@ -4857,7 +8127,26 @@ func (m *Policy) Validate() error { } } - if v, ok := interface{}(m.GetUpdatedAt()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetUpdatedAt()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PolicyValidationError{ + field: "UpdatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PolicyValidationError{ + field: "UpdatedAt", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdatedAt()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return PolicyValidationError{ field: "UpdatedAt", @@ -4867,9 +8156,28 @@ func (m *Policy) Validate() error { } } + if len(errors) > 0 { + return PolicyMultiError(errors) + } return nil } +// PolicyMultiError is an error wrapping multiple validation errors returned by +// Policy.ValidateAll() if the designated constraints aren't met. +type PolicyMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PolicyMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m PolicyMultiError) AllErrors() []error { return m } + // PolicyValidationError is the validation error returned by Policy.Validate if // the designated constraints aren't met. type PolicyValidationError struct { @@ -4925,27 +8233,65 @@ var _ interface { } = PolicyValidationError{} // Validate checks the field values on ActionRequestBody with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *ActionRequestBody) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ActionRequestBody with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ActionRequestBodyMultiError, or nil if none found. +func (m *ActionRequestBody) ValidateAll() error { + return m.validate(true) +} + +func (m *ActionRequestBody) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id if !_ActionRequestBody_Name_Pattern.MatchString(m.GetName()) { - return ActionRequestBodyValidationError{ + err := ActionRequestBodyValidationError{ field: "Name", reason: "value does not match regex pattern \"^[A-Za-z0-9_-]+$\"", } + if !all { + return err + } + errors = append(errors, err) } // no validation rules for NamespaceId + if len(errors) > 0 { + return ActionRequestBodyMultiError(errors) + } return nil } +// ActionRequestBodyMultiError is an error wrapping multiple validation errors +// returned by ActionRequestBody.ValidateAll() if the designated constraints +// aren't met. +type ActionRequestBodyMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ActionRequestBodyMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ActionRequestBodyMultiError) AllErrors() []error { return m } + // ActionRequestBodyValidationError is the validation error returned by // ActionRequestBody.Validate if the designated constraints aren't met. type ActionRequestBodyValidationError struct { @@ -5006,24 +8352,62 @@ var _ActionRequestBody_Name_Pattern = regexp.MustCompile("^[A-Za-z0-9_-]+$") // Validate checks the field values on NamespaceRequestBody with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *NamespaceRequestBody) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on NamespaceRequestBody with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// NamespaceRequestBodyMultiError, or nil if none found. +func (m *NamespaceRequestBody) ValidateAll() error { + return m.validate(true) +} + +func (m *NamespaceRequestBody) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id if !_NamespaceRequestBody_Name_Pattern.MatchString(m.GetName()) { - return NamespaceRequestBodyValidationError{ + err := NamespaceRequestBodyValidationError{ field: "Name", reason: "value does not match regex pattern \"^[A-Za-z0-9_-]+$\"", } + if !all { + return err + } + errors = append(errors, err) } + if len(errors) > 0 { + return NamespaceRequestBodyMultiError(errors) + } return nil } +// NamespaceRequestBodyMultiError is an error wrapping multiple validation +// errors returned by NamespaceRequestBody.ValidateAll() if the designated +// constraints aren't met. +type NamespaceRequestBodyMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m NamespaceRequestBodyMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m NamespaceRequestBodyMultiError) AllErrors() []error { return m } + // NamespaceRequestBodyValidationError is the validation error returned by // NamespaceRequestBody.Validate if the designated constraints aren't met. type NamespaceRequestBodyValidationError struct { @@ -5083,22 +8467,56 @@ var _ interface { var _NamespaceRequestBody_Name_Pattern = regexp.MustCompile("^[A-Za-z0-9_-]+$") // Validate checks the field values on PolicyRequestBody with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *PolicyRequestBody) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PolicyRequestBody with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// PolicyRequestBodyMultiError, or nil if none found. +func (m *PolicyRequestBody) ValidateAll() error { + return m.validate(true) +} + +func (m *PolicyRequestBody) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for RoleId // no validation rules for ActionId // no validation rules for NamespaceId + if len(errors) > 0 { + return PolicyRequestBodyMultiError(errors) + } return nil } +// PolicyRequestBodyMultiError is an error wrapping multiple validation errors +// returned by PolicyRequestBody.ValidateAll() if the designated constraints +// aren't met. +type PolicyRequestBodyMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PolicyRequestBodyMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m PolicyRequestBodyMultiError) AllErrors() []error { return m } + // PolicyRequestBodyValidationError is the validation error returned by // PolicyRequestBody.Validate if the designated constraints aren't met. type PolicyRequestBodyValidationError struct { @@ -5157,15 +8575,49 @@ var _ interface { // Validate checks the field values on ListActionsRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *ListActionsRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListActionsRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListActionsRequestMultiError, or nil if none found. +func (m *ListActionsRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListActionsRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + + if len(errors) > 0 { + return ListActionsRequestMultiError(errors) + } return nil } +// ListActionsRequestMultiError is an error wrapping multiple validation errors +// returned by ListActionsRequest.ValidateAll() if the designated constraints +// aren't met. +type ListActionsRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListActionsRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListActionsRequestMultiError) AllErrors() []error { return m } + // ListActionsRequestValidationError is the validation error returned by // ListActionsRequest.Validate if the designated constraints aren't met. type ListActionsRequestValidationError struct { @@ -5224,16 +8676,49 @@ var _ interface { // Validate checks the field values on ListActionsResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *ListActionsResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListActionsResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListActionsResponseMultiError, or nil if none found. +func (m *ListActionsResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListActionsResponse) validate(all bool) error { if m == nil { return nil } + var errors []error + for idx, item := range m.GetActions() { _, _ = idx, item - if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListActionsResponseValidationError{ + field: fmt.Sprintf("Actions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListActionsResponseValidationError{ + field: fmt.Sprintf("Actions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListActionsResponseValidationError{ field: fmt.Sprintf("Actions[%v]", idx), @@ -5245,9 +8730,29 @@ func (m *ListActionsResponse) Validate() error { } + if len(errors) > 0 { + return ListActionsResponseMultiError(errors) + } return nil } +// ListActionsResponseMultiError is an error wrapping multiple validation +// errors returned by ListActionsResponse.ValidateAll() if the designated +// constraints aren't met. +type ListActionsResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListActionsResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListActionsResponseMultiError) AllErrors() []error { return m } + // ListActionsResponseValidationError is the validation error returned by // ListActionsResponse.Validate if the designated constraints aren't met. type ListActionsResponseValidationError struct { @@ -5306,13 +8811,46 @@ var _ interface { // Validate checks the field values on CreateActionRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *CreateActionRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateActionRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CreateActionRequestMultiError, or nil if none found. +func (m *CreateActionRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateActionRequest) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetBody()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateActionRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateActionRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CreateActionRequestValidationError{ field: "Body", @@ -5322,9 +8860,29 @@ func (m *CreateActionRequest) Validate() error { } } + if len(errors) > 0 { + return CreateActionRequestMultiError(errors) + } return nil } +// CreateActionRequestMultiError is an error wrapping multiple validation +// errors returned by CreateActionRequest.ValidateAll() if the designated +// constraints aren't met. +type CreateActionRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateActionRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CreateActionRequestMultiError) AllErrors() []error { return m } + // CreateActionRequestValidationError is the validation error returned by // CreateActionRequest.Validate if the designated constraints aren't met. type CreateActionRequestValidationError struct { @@ -5383,13 +8941,46 @@ var _ interface { // Validate checks the field values on CreateActionResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *CreateActionResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateActionResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CreateActionResponseMultiError, or nil if none found. +func (m *CreateActionResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateActionResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetAction()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetAction()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateActionResponseValidationError{ + field: "Action", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateActionResponseValidationError{ + field: "Action", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetAction()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CreateActionResponseValidationError{ field: "Action", @@ -5399,9 +8990,29 @@ func (m *CreateActionResponse) Validate() error { } } + if len(errors) > 0 { + return CreateActionResponseMultiError(errors) + } return nil } +// CreateActionResponseMultiError is an error wrapping multiple validation +// errors returned by CreateActionResponse.ValidateAll() if the designated +// constraints aren't met. +type CreateActionResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateActionResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CreateActionResponseMultiError) AllErrors() []error { return m } + // CreateActionResponseValidationError is the validation error returned by // CreateActionResponse.Validate if the designated constraints aren't met. type CreateActionResponseValidationError struct { @@ -5459,18 +9070,52 @@ var _ interface { } = CreateActionResponseValidationError{} // Validate checks the field values on GetActionRequest with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *GetActionRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetActionRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetActionRequestMultiError, or nil if none found. +func (m *GetActionRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetActionRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id + if len(errors) > 0 { + return GetActionRequestMultiError(errors) + } return nil } +// GetActionRequestMultiError is an error wrapping multiple validation errors +// returned by GetActionRequest.ValidateAll() if the designated constraints +// aren't met. +type GetActionRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetActionRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetActionRequestMultiError) AllErrors() []error { return m } + // GetActionRequestValidationError is the validation error returned by // GetActionRequest.Validate if the designated constraints aren't met. type GetActionRequestValidationError struct { @@ -5526,14 +9171,47 @@ var _ interface { } = GetActionRequestValidationError{} // Validate checks the field values on GetActionResponse with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *GetActionResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetActionResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetActionResponseMultiError, or nil if none found. +func (m *GetActionResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetActionResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetAction()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetAction()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetActionResponseValidationError{ + field: "Action", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetActionResponseValidationError{ + field: "Action", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetAction()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GetActionResponseValidationError{ field: "Action", @@ -5543,9 +9221,29 @@ func (m *GetActionResponse) Validate() error { } } + if len(errors) > 0 { + return GetActionResponseMultiError(errors) + } return nil } +// GetActionResponseMultiError is an error wrapping multiple validation errors +// returned by GetActionResponse.ValidateAll() if the designated constraints +// aren't met. +type GetActionResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetActionResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetActionResponseMultiError) AllErrors() []error { return m } + // GetActionResponseValidationError is the validation error returned by // GetActionResponse.Validate if the designated constraints aren't met. type GetActionResponseValidationError struct { @@ -5604,15 +9302,48 @@ var _ interface { // Validate checks the field values on UpdateActionRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *UpdateActionRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateActionRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdateActionRequestMultiError, or nil if none found. +func (m *UpdateActionRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateActionRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id - if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetBody()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateActionRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateActionRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UpdateActionRequestValidationError{ field: "Body", @@ -5622,9 +9353,29 @@ func (m *UpdateActionRequest) Validate() error { } } + if len(errors) > 0 { + return UpdateActionRequestMultiError(errors) + } return nil } +// UpdateActionRequestMultiError is an error wrapping multiple validation +// errors returned by UpdateActionRequest.ValidateAll() if the designated +// constraints aren't met. +type UpdateActionRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateActionRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UpdateActionRequestMultiError) AllErrors() []error { return m } + // UpdateActionRequestValidationError is the validation error returned by // UpdateActionRequest.Validate if the designated constraints aren't met. type UpdateActionRequestValidationError struct { @@ -5683,13 +9434,46 @@ var _ interface { // Validate checks the field values on UpdateActionResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *UpdateActionResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateActionResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdateActionResponseMultiError, or nil if none found. +func (m *UpdateActionResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateActionResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetAction()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetAction()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateActionResponseValidationError{ + field: "Action", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateActionResponseValidationError{ + field: "Action", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetAction()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UpdateActionResponseValidationError{ field: "Action", @@ -5699,9 +9483,29 @@ func (m *UpdateActionResponse) Validate() error { } } + if len(errors) > 0 { + return UpdateActionResponseMultiError(errors) + } return nil } +// UpdateActionResponseMultiError is an error wrapping multiple validation +// errors returned by UpdateActionResponse.ValidateAll() if the designated +// constraints aren't met. +type UpdateActionResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateActionResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UpdateActionResponseMultiError) AllErrors() []error { return m } + // UpdateActionResponseValidationError is the validation error returned by // UpdateActionResponse.Validate if the designated constraints aren't met. type UpdateActionResponseValidationError struct { @@ -5760,15 +9564,49 @@ var _ interface { // Validate checks the field values on ListNamespacesRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *ListNamespacesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListNamespacesRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListNamespacesRequestMultiError, or nil if none found. +func (m *ListNamespacesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListNamespacesRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + + if len(errors) > 0 { + return ListNamespacesRequestMultiError(errors) + } return nil } +// ListNamespacesRequestMultiError is an error wrapping multiple validation +// errors returned by ListNamespacesRequest.ValidateAll() if the designated +// constraints aren't met. +type ListNamespacesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListNamespacesRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListNamespacesRequestMultiError) AllErrors() []error { return m } + // ListNamespacesRequestValidationError is the validation error returned by // ListNamespacesRequest.Validate if the designated constraints aren't met. type ListNamespacesRequestValidationError struct { @@ -5827,16 +9665,49 @@ var _ interface { // Validate checks the field values on ListNamespacesResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *ListNamespacesResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListNamespacesResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListNamespacesResponseMultiError, or nil if none found. +func (m *ListNamespacesResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListNamespacesResponse) validate(all bool) error { if m == nil { return nil } + var errors []error + for idx, item := range m.GetNamespaces() { _, _ = idx, item - if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListNamespacesResponseValidationError{ + field: fmt.Sprintf("Namespaces[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListNamespacesResponseValidationError{ + field: fmt.Sprintf("Namespaces[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListNamespacesResponseValidationError{ field: fmt.Sprintf("Namespaces[%v]", idx), @@ -5848,9 +9719,29 @@ func (m *ListNamespacesResponse) Validate() error { } + if len(errors) > 0 { + return ListNamespacesResponseMultiError(errors) + } return nil } +// ListNamespacesResponseMultiError is an error wrapping multiple validation +// errors returned by ListNamespacesResponse.ValidateAll() if the designated +// constraints aren't met. +type ListNamespacesResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListNamespacesResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListNamespacesResponseMultiError) AllErrors() []error { return m } + // ListNamespacesResponseValidationError is the validation error returned by // ListNamespacesResponse.Validate if the designated constraints aren't met. type ListNamespacesResponseValidationError struct { @@ -5909,13 +9800,46 @@ var _ interface { // Validate checks the field values on CreateNamespaceRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *CreateNamespaceRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateNamespaceRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CreateNamespaceRequestMultiError, or nil if none found. +func (m *CreateNamespaceRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateNamespaceRequest) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetBody()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateNamespaceRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateNamespaceRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CreateNamespaceRequestValidationError{ field: "Body", @@ -5925,9 +9849,29 @@ func (m *CreateNamespaceRequest) Validate() error { } } + if len(errors) > 0 { + return CreateNamespaceRequestMultiError(errors) + } return nil } +// CreateNamespaceRequestMultiError is an error wrapping multiple validation +// errors returned by CreateNamespaceRequest.ValidateAll() if the designated +// constraints aren't met. +type CreateNamespaceRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateNamespaceRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CreateNamespaceRequestMultiError) AllErrors() []error { return m } + // CreateNamespaceRequestValidationError is the validation error returned by // CreateNamespaceRequest.Validate if the designated constraints aren't met. type CreateNamespaceRequestValidationError struct { @@ -5986,13 +9930,46 @@ var _ interface { // Validate checks the field values on CreateNamespaceResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *CreateNamespaceResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateNamespaceResponse with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CreateNamespaceResponseMultiError, or nil if none found. +func (m *CreateNamespaceResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateNamespaceResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetNamespace()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetNamespace()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateNamespaceResponseValidationError{ + field: "Namespace", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateNamespaceResponseValidationError{ + field: "Namespace", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetNamespace()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CreateNamespaceResponseValidationError{ field: "Namespace", @@ -6002,9 +9979,29 @@ func (m *CreateNamespaceResponse) Validate() error { } } + if len(errors) > 0 { + return CreateNamespaceResponseMultiError(errors) + } return nil } +// CreateNamespaceResponseMultiError is an error wrapping multiple validation +// errors returned by CreateNamespaceResponse.ValidateAll() if the designated +// constraints aren't met. +type CreateNamespaceResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateNamespaceResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CreateNamespaceResponseMultiError) AllErrors() []error { return m } + // CreateNamespaceResponseValidationError is the validation error returned by // CreateNamespaceResponse.Validate if the designated constraints aren't met. type CreateNamespaceResponseValidationError struct { @@ -6063,17 +10060,51 @@ var _ interface { // Validate checks the field values on GetNamespaceRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *GetNamespaceRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetNamespaceRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetNamespaceRequestMultiError, or nil if none found. +func (m *GetNamespaceRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetNamespaceRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id + if len(errors) > 0 { + return GetNamespaceRequestMultiError(errors) + } return nil } +// GetNamespaceRequestMultiError is an error wrapping multiple validation +// errors returned by GetNamespaceRequest.ValidateAll() if the designated +// constraints aren't met. +type GetNamespaceRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetNamespaceRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetNamespaceRequestMultiError) AllErrors() []error { return m } + // GetNamespaceRequestValidationError is the validation error returned by // GetNamespaceRequest.Validate if the designated constraints aren't met. type GetNamespaceRequestValidationError struct { @@ -6132,13 +10163,46 @@ var _ interface { // Validate checks the field values on GetNamespaceResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *GetNamespaceResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetNamespaceResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetNamespaceResponseMultiError, or nil if none found. +func (m *GetNamespaceResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetNamespaceResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetNamespace()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetNamespace()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetNamespaceResponseValidationError{ + field: "Namespace", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetNamespaceResponseValidationError{ + field: "Namespace", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetNamespace()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GetNamespaceResponseValidationError{ field: "Namespace", @@ -6148,9 +10212,29 @@ func (m *GetNamespaceResponse) Validate() error { } } + if len(errors) > 0 { + return GetNamespaceResponseMultiError(errors) + } return nil } +// GetNamespaceResponseMultiError is an error wrapping multiple validation +// errors returned by GetNamespaceResponse.ValidateAll() if the designated +// constraints aren't met. +type GetNamespaceResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetNamespaceResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetNamespaceResponseMultiError) AllErrors() []error { return m } + // GetNamespaceResponseValidationError is the validation error returned by // GetNamespaceResponse.Validate if the designated constraints aren't met. type GetNamespaceResponseValidationError struct { @@ -6209,15 +10293,48 @@ var _ interface { // Validate checks the field values on UpdateNamespaceRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *UpdateNamespaceRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateNamespaceRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdateNamespaceRequestMultiError, or nil if none found. +func (m *UpdateNamespaceRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateNamespaceRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id - if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetBody()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateNamespaceRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateNamespaceRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UpdateNamespaceRequestValidationError{ field: "Body", @@ -6227,9 +10344,29 @@ func (m *UpdateNamespaceRequest) Validate() error { } } + if len(errors) > 0 { + return UpdateNamespaceRequestMultiError(errors) + } return nil } +// UpdateNamespaceRequestMultiError is an error wrapping multiple validation +// errors returned by UpdateNamespaceRequest.ValidateAll() if the designated +// constraints aren't met. +type UpdateNamespaceRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateNamespaceRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UpdateNamespaceRequestMultiError) AllErrors() []error { return m } + // UpdateNamespaceRequestValidationError is the validation error returned by // UpdateNamespaceRequest.Validate if the designated constraints aren't met. type UpdateNamespaceRequestValidationError struct { @@ -6288,13 +10425,46 @@ var _ interface { // Validate checks the field values on UpdateNamespaceResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *UpdateNamespaceResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateNamespaceResponse with the +// rules defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdateNamespaceResponseMultiError, or nil if none found. +func (m *UpdateNamespaceResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateNamespaceResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetNamespace()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetNamespace()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateNamespaceResponseValidationError{ + field: "Namespace", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateNamespaceResponseValidationError{ + field: "Namespace", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetNamespace()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UpdateNamespaceResponseValidationError{ field: "Namespace", @@ -6304,9 +10474,29 @@ func (m *UpdateNamespaceResponse) Validate() error { } } + if len(errors) > 0 { + return UpdateNamespaceResponseMultiError(errors) + } return nil } +// UpdateNamespaceResponseMultiError is an error wrapping multiple validation +// errors returned by UpdateNamespaceResponse.ValidateAll() if the designated +// constraints aren't met. +type UpdateNamespaceResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateNamespaceResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UpdateNamespaceResponseMultiError) AllErrors() []error { return m } + // UpdateNamespaceResponseValidationError is the validation error returned by // UpdateNamespaceResponse.Validate if the designated constraints aren't met. type UpdateNamespaceResponseValidationError struct { @@ -6365,15 +10555,49 @@ var _ interface { // Validate checks the field values on ListPoliciesRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *ListPoliciesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPoliciesRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListPoliciesRequestMultiError, or nil if none found. +func (m *ListPoliciesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPoliciesRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + + if len(errors) > 0 { + return ListPoliciesRequestMultiError(errors) + } return nil } +// ListPoliciesRequestMultiError is an error wrapping multiple validation +// errors returned by ListPoliciesRequest.ValidateAll() if the designated +// constraints aren't met. +type ListPoliciesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPoliciesRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListPoliciesRequestMultiError) AllErrors() []error { return m } + // ListPoliciesRequestValidationError is the validation error returned by // ListPoliciesRequest.Validate if the designated constraints aren't met. type ListPoliciesRequestValidationError struct { @@ -6432,16 +10656,49 @@ var _ interface { // Validate checks the field values on ListPoliciesResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *ListPoliciesResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPoliciesResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// ListPoliciesResponseMultiError, or nil if none found. +func (m *ListPoliciesResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPoliciesResponse) validate(all bool) error { if m == nil { return nil } + var errors []error + for idx, item := range m.GetPolicies() { _, _ = idx, item - if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListPoliciesResponseValidationError{ + field: fmt.Sprintf("Policies[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListPoliciesResponseValidationError{ + field: fmt.Sprintf("Policies[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListPoliciesResponseValidationError{ field: fmt.Sprintf("Policies[%v]", idx), @@ -6453,9 +10710,29 @@ func (m *ListPoliciesResponse) Validate() error { } + if len(errors) > 0 { + return ListPoliciesResponseMultiError(errors) + } return nil } +// ListPoliciesResponseMultiError is an error wrapping multiple validation +// errors returned by ListPoliciesResponse.ValidateAll() if the designated +// constraints aren't met. +type ListPoliciesResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPoliciesResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ListPoliciesResponseMultiError) AllErrors() []error { return m } + // ListPoliciesResponseValidationError is the validation error returned by // ListPoliciesResponse.Validate if the designated constraints aren't met. type ListPoliciesResponseValidationError struct { @@ -6514,13 +10791,46 @@ var _ interface { // Validate checks the field values on CreatePolicyRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *CreatePolicyRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreatePolicyRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CreatePolicyRequestMultiError, or nil if none found. +func (m *CreatePolicyRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreatePolicyRequest) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetBody()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreatePolicyRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreatePolicyRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CreatePolicyRequestValidationError{ field: "Body", @@ -6530,9 +10840,29 @@ func (m *CreatePolicyRequest) Validate() error { } } + if len(errors) > 0 { + return CreatePolicyRequestMultiError(errors) + } return nil } +// CreatePolicyRequestMultiError is an error wrapping multiple validation +// errors returned by CreatePolicyRequest.ValidateAll() if the designated +// constraints aren't met. +type CreatePolicyRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreatePolicyRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CreatePolicyRequestMultiError) AllErrors() []error { return m } + // CreatePolicyRequestValidationError is the validation error returned by // CreatePolicyRequest.Validate if the designated constraints aren't met. type CreatePolicyRequestValidationError struct { @@ -6591,16 +10921,49 @@ var _ interface { // Validate checks the field values on CreatePolicyResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *CreatePolicyResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreatePolicyResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// CreatePolicyResponseMultiError, or nil if none found. +func (m *CreatePolicyResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreatePolicyResponse) validate(all bool) error { if m == nil { return nil } + var errors []error + for idx, item := range m.GetPolicies() { _, _ = idx, item - if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreatePolicyResponseValidationError{ + field: fmt.Sprintf("Policies[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreatePolicyResponseValidationError{ + field: fmt.Sprintf("Policies[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CreatePolicyResponseValidationError{ field: fmt.Sprintf("Policies[%v]", idx), @@ -6612,9 +10975,29 @@ func (m *CreatePolicyResponse) Validate() error { } + if len(errors) > 0 { + return CreatePolicyResponseMultiError(errors) + } return nil } +// CreatePolicyResponseMultiError is an error wrapping multiple validation +// errors returned by CreatePolicyResponse.ValidateAll() if the designated +// constraints aren't met. +type CreatePolicyResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreatePolicyResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m CreatePolicyResponseMultiError) AllErrors() []error { return m } + // CreatePolicyResponseValidationError is the validation error returned by // CreatePolicyResponse.Validate if the designated constraints aren't met. type CreatePolicyResponseValidationError struct { @@ -6672,18 +11055,52 @@ var _ interface { } = CreatePolicyResponseValidationError{} // Validate checks the field values on GetPolicyRequest with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *GetPolicyRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetPolicyRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetPolicyRequestMultiError, or nil if none found. +func (m *GetPolicyRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetPolicyRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id + if len(errors) > 0 { + return GetPolicyRequestMultiError(errors) + } return nil } +// GetPolicyRequestMultiError is an error wrapping multiple validation errors +// returned by GetPolicyRequest.ValidateAll() if the designated constraints +// aren't met. +type GetPolicyRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetPolicyRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetPolicyRequestMultiError) AllErrors() []error { return m } + // GetPolicyRequestValidationError is the validation error returned by // GetPolicyRequest.Validate if the designated constraints aren't met. type GetPolicyRequestValidationError struct { @@ -6739,14 +11156,47 @@ var _ interface { } = GetPolicyRequestValidationError{} // Validate checks the field values on GetPolicyResponse with the rules defined -// in the proto definition for this message. If any rules are violated, an -// error is returned. +// in the proto definition for this message. If any rules are violated, the +// first error encountered is returned, or nil if there are no violations. func (m *GetPolicyResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetPolicyResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetPolicyResponseMultiError, or nil if none found. +func (m *GetPolicyResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetPolicyResponse) validate(all bool) error { if m == nil { return nil } - if v, ok := interface{}(m.GetPolicy()).(interface{ Validate() error }); ok { + var errors []error + + if all { + switch v := interface{}(m.GetPolicy()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetPolicyResponseValidationError{ + field: "Policy", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetPolicyResponseValidationError{ + field: "Policy", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPolicy()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GetPolicyResponseValidationError{ field: "Policy", @@ -6756,9 +11206,29 @@ func (m *GetPolicyResponse) Validate() error { } } + if len(errors) > 0 { + return GetPolicyResponseMultiError(errors) + } return nil } +// GetPolicyResponseMultiError is an error wrapping multiple validation errors +// returned by GetPolicyResponse.ValidateAll() if the designated constraints +// aren't met. +type GetPolicyResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetPolicyResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetPolicyResponseMultiError) AllErrors() []error { return m } + // GetPolicyResponseValidationError is the validation error returned by // GetPolicyResponse.Validate if the designated constraints aren't met. type GetPolicyResponseValidationError struct { @@ -6817,15 +11287,48 @@ var _ interface { // Validate checks the field values on UpdatePolicyRequest with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *UpdatePolicyRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePolicyRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdatePolicyRequestMultiError, or nil if none found. +func (m *UpdatePolicyRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePolicyRequest) validate(all bool) error { if m == nil { return nil } + var errors []error + // no validation rules for Id - if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(m.GetBody()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePolicyRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePolicyRequestValidationError{ + field: "Body", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetBody()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UpdatePolicyRequestValidationError{ field: "Body", @@ -6835,9 +11338,29 @@ func (m *UpdatePolicyRequest) Validate() error { } } + if len(errors) > 0 { + return UpdatePolicyRequestMultiError(errors) + } return nil } +// UpdatePolicyRequestMultiError is an error wrapping multiple validation +// errors returned by UpdatePolicyRequest.ValidateAll() if the designated +// constraints aren't met. +type UpdatePolicyRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePolicyRequestMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UpdatePolicyRequestMultiError) AllErrors() []error { return m } + // UpdatePolicyRequestValidationError is the validation error returned by // UpdatePolicyRequest.Validate if the designated constraints aren't met. type UpdatePolicyRequestValidationError struct { @@ -6896,16 +11419,49 @@ var _ interface { // Validate checks the field values on UpdatePolicyResponse with the rules // defined in the proto definition for this message. If any rules are -// violated, an error is returned. +// violated, the first error encountered is returned, or nil if there are no violations. func (m *UpdatePolicyResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePolicyResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// UpdatePolicyResponseMultiError, or nil if none found. +func (m *UpdatePolicyResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePolicyResponse) validate(all bool) error { if m == nil { return nil } + var errors []error + for idx, item := range m.GetPolicies() { _, _ = idx, item - if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePolicyResponseValidationError{ + field: fmt.Sprintf("Policies[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePolicyResponseValidationError{ + field: fmt.Sprintf("Policies[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return UpdatePolicyResponseValidationError{ field: fmt.Sprintf("Policies[%v]", idx), @@ -6917,9 +11473,29 @@ func (m *UpdatePolicyResponse) Validate() error { } + if len(errors) > 0 { + return UpdatePolicyResponseMultiError(errors) + } return nil } +// UpdatePolicyResponseMultiError is an error wrapping multiple validation +// errors returned by UpdatePolicyResponse.ValidateAll() if the designated +// constraints aren't met. +type UpdatePolicyResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePolicyResponseMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m UpdatePolicyResponseMultiError) AllErrors() []error { return m } + // UpdatePolicyResponseValidationError is the validation error returned by // UpdatePolicyResponse.Validate if the designated constraints aren't met. type UpdatePolicyResponseValidationError struct { diff --git a/store/postgres/action.go b/store/postgres/action.go new file mode 100644 index 000000000..89c88d981 --- /dev/null +++ b/store/postgres/action.go @@ -0,0 +1,135 @@ +package postgres + +import ( + "context" + "database/sql" + "errors" + "fmt" + "time" + + "github.com/jmoiron/sqlx" + "github.com/odpf/shield/internal/schema" + "github.com/odpf/shield/model" +) + +type Action struct { + Id string `db:"id"` + Name string `db:"name"` + NamespaceID string `db:"namespace_id"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` +} + +const ( + getActionQuery = `SELECT id, name, namespace_id, created_at, updated_at from actions where id=$1;` + createActionQuery = `INSERT INTO actions(id, name, namespace_id) values($1, $2, $3) RETURNING id, name, namespace_id, created_at, updated_at;` + listActionsQuery = `SELECT id, name, namespace_id, created_at, updated_at from actions;` + updateActionQuery = `UPDATE actions set name = $2, namespace_id = $3, updated_at = now() where id = $1 RETURNING id, name, namespace_id, created_at, updated_at;` +) + +func (s Store) GetAction(ctx context.Context, id string) (model.Action, error) { + fetchedAction, err := s.selectAction(ctx, id, nil) + return fetchedAction, err +} + +func (s Store) selectAction(ctx context.Context, id string, txn *sqlx.Tx) (model.Action, error) { + var fetchedAction Action + + err := s.DB.WithTimeout(ctx, func(ctx context.Context) error { + return s.DB.GetContext(ctx, &fetchedAction, getActionQuery, id) + }) + + if errors.Is(err, sql.ErrNoRows) { + return model.Action{}, schema.ActionDoesntExist + } else if err != nil && fmt.Sprintf("%s", err.Error()[0:38]) == "pq: invalid input syntax for type uuid" { + // TODO: this uuid syntax is a error defined in db, not in library + // need to look into better ways to implement this + return model.Action{}, schema.InvalidUUID + } else if err != nil { + return model.Action{}, fmt.Errorf("%w: %s", dbErr, err) + } + + transformedAction, err := transformToAction(fetchedAction) + if err != nil { + return model.Action{}, fmt.Errorf("%w: %s", parseErr, err) + } + + return transformedAction, nil +} + +func (s Store) CreateAction(ctx context.Context, actionToCreate model.Action) (model.Action, error) { + var newAction Action + err := s.DB.WithTimeout(ctx, func(ctx context.Context) error { + return s.DB.GetContext(ctx, &newAction, createActionQuery, actionToCreate.Id, actionToCreate.Name, actionToCreate.NamespaceId) + }) + + if err != nil { + return model.Action{}, fmt.Errorf("%w: %s", dbErr, err) + } + + transformedAction, err := transformToAction(newAction) + if err != nil { + return model.Action{}, fmt.Errorf("%w: %s", parseErr, err) + } + + return transformedAction, nil +} + +func (s Store) ListActions(ctx context.Context) ([]model.Action, error) { + var fetchedActions []Action + err := s.DB.WithTimeout(ctx, func(ctx context.Context) error { + return s.DB.SelectContext(ctx, &fetchedActions, listActionsQuery) + }) + + if errors.Is(err, sql.ErrNoRows) { + return []model.Action{}, schema.ActionDoesntExist + } + + if err != nil { + return []model.Action{}, fmt.Errorf("%w: %s", dbErr, err) + } + + var transformedActions []model.Action + + for _, o := range fetchedActions { + transformedAction, err := transformToAction(o) + if err != nil { + return []model.Action{}, fmt.Errorf("%w: %s", parseErr, err) + } + + transformedActions = append(transformedActions, transformedAction) + } + + return transformedActions, nil +} + +func (s Store) UpdateAction(ctx context.Context, toUpdate model.Action) (model.Action, error) { + var updatedAction Action + + err := s.DB.WithTimeout(ctx, func(ctx context.Context) error { + return s.DB.GetContext(ctx, &updatedAction, updateActionQuery, toUpdate.Id, toUpdate.Name, toUpdate.NamespaceId) + }) + + if errors.Is(err, sql.ErrNoRows) { + return model.Action{}, schema.ActionDoesntExist + } else if err != nil { + return model.Action{}, fmt.Errorf("%w: %s", dbErr, err) + } + + transformedAction, err := transformToAction(updatedAction) + if err != nil { + return model.Action{}, fmt.Errorf("%s: %w", parseErr, err) + } + + return transformedAction, nil +} + +func transformToAction(from Action) (model.Action, error) { + return model.Action{ + Id: from.Id, + Name: from.Name, + NamespaceId: from.NamespaceID, + CreatedAt: from.CreatedAt, + UpdatedAt: from.UpdatedAt, + }, nil +} diff --git a/store/postgres/migrations/20211117082042_create_action_table.down.sql b/store/postgres/migrations/20211117082042_create_action_table.down.sql new file mode 100644 index 000000000..eb16c1f80 --- /dev/null +++ b/store/postgres/migrations/20211117082042_create_action_table.down.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS actions; \ No newline at end of file diff --git a/store/postgres/migrations/20211117082042_create_action_table.up.sql b/store/postgres/migrations/20211117082042_create_action_table.up.sql new file mode 100644 index 000000000..aa2a0e24e --- /dev/null +++ b/store/postgres/migrations/20211117082042_create_action_table.up.sql @@ -0,0 +1,7 @@ +CREATE TABLE IF NOT EXISTS actions ( + id varchar PRIMARY KEY, + name varchar UNIQUE NOT NULL, + created_at timestamptz NOT NULL DEFAULT NOW(), + updated_at timestamptz NOT NULL DEFAULT NOW(), + deleted_at timestamptz +); \ No newline at end of file diff --git a/store/postgres/migrations/20211117092528_create_namespace_table.down.sql b/store/postgres/migrations/20211117092528_create_namespace_table.down.sql new file mode 100644 index 000000000..b3ec8ee52 --- /dev/null +++ b/store/postgres/migrations/20211117092528_create_namespace_table.down.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS namespaces; \ No newline at end of file diff --git a/store/postgres/migrations/20211117092528_create_namespace_table.up.sql b/store/postgres/migrations/20211117092528_create_namespace_table.up.sql new file mode 100644 index 000000000..cfec33480 --- /dev/null +++ b/store/postgres/migrations/20211117092528_create_namespace_table.up.sql @@ -0,0 +1,7 @@ +CREATE TABLE IF NOT EXISTS namespaces ( + id varchar PRIMARY KEY, + name varchar UNIQUE NOT NULL, + created_at timestamptz NOT NULL DEFAULT NOW(), + updated_at timestamptz NOT NULL DEFAULT NOW(), + deleted_at timestamptz +); \ No newline at end of file diff --git a/store/postgres/migrations/20211117193407_create_policies_table.down.sql b/store/postgres/migrations/20211117193407_create_policies_table.down.sql new file mode 100644 index 000000000..8f23b29b1 --- /dev/null +++ b/store/postgres/migrations/20211117193407_create_policies_table.down.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS policies; \ No newline at end of file diff --git a/store/postgres/migrations/20211117193407_create_policies_table.up.sql b/store/postgres/migrations/20211117193407_create_policies_table.up.sql new file mode 100644 index 000000000..5a3360e8a --- /dev/null +++ b/store/postgres/migrations/20211117193407_create_policies_table.up.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS policies ( + id uuid PRIMARY KEY DEFAULT uuid_generate_v4(), + role_id VARCHAR REFERENCES roles (id), + namespace_id VARCHAR REFERENCES namespaces (id), + action_id VARCHAR REFERENCES actions (id), + created_at timestamptz NOT NULL DEFAULT NOW(), + updated_at timestamptz NOT NULL DEFAULT NOW(), + deleted_at timestamptz +); \ No newline at end of file diff --git a/store/postgres/migrations/20211120171454_add_namepace_to_actions_roles.down.sql b/store/postgres/migrations/20211120171454_add_namepace_to_actions_roles.down.sql new file mode 100644 index 000000000..fb3f82112 --- /dev/null +++ b/store/postgres/migrations/20211120171454_add_namepace_to_actions_roles.down.sql @@ -0,0 +1,5 @@ +ALTER TABLE roles + DROP COLUMN IF EXISTS namespace_id; + +ALTER TABLE actions + DROP COLUMN IF EXISTS namespace_id; \ No newline at end of file diff --git a/store/postgres/migrations/20211120171454_add_namepace_to_actions_roles.up.sql b/store/postgres/migrations/20211120171454_add_namepace_to_actions_roles.up.sql new file mode 100644 index 000000000..1b6b432e1 --- /dev/null +++ b/store/postgres/migrations/20211120171454_add_namepace_to_actions_roles.up.sql @@ -0,0 +1,5 @@ +ALTER TABLE roles + ADD COLUMN namespace_id VARCHAR REFERENCES namespaces(id); + +ALTER TABLE actions + ADD COLUMN namespace_id VARCHAR REFERENCES namespaces(id); \ No newline at end of file diff --git a/store/postgres/namespace.go b/store/postgres/namespace.go new file mode 100644 index 000000000..c2c00e038 --- /dev/null +++ b/store/postgres/namespace.go @@ -0,0 +1,134 @@ +package postgres + +import ( + "context" + "database/sql" + "errors" + "fmt" + "time" + + "github.com/jmoiron/sqlx" + "github.com/odpf/shield/internal/schema" + "github.com/odpf/shield/model" +) + +type Namespace struct { + Id string `db:"id"` + Name string `db:"name"` + Slug string `db:"slug"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` +} + +const ( + getNamespaceQuery = `SELECT id, name, created_at, updated_at from namespaces where id=$1;` + createNamespaceQuery = `INSERT INTO namespaces(id, name) values($1, $2) RETURNING id, name, created_at, updated_at;` + listNamespacesQuery = `SELECT id, name, created_at, updated_at from namespaces;` + updateNamespaceQuery = `UPDATE namespaces set name = $2, slug = $3 updated_at = now() where id = $1 RETURNING id, name, slug, created_at, updated_at;` +) + +func (s Store) GetNamespace(ctx context.Context, id string) (model.Namespace, error) { + fetchedNamespace, err := s.selectNamespace(ctx, id, nil) + return fetchedNamespace, err +} + +func (s Store) selectNamespace(ctx context.Context, id string, txn *sqlx.Tx) (model.Namespace, error) { + var fetchedNamespace Namespace + + err := s.DB.WithTimeout(ctx, func(ctx context.Context) error { + return s.DB.GetContext(ctx, &fetchedNamespace, getNamespaceQuery, id) + }) + + if errors.Is(err, sql.ErrNoRows) { + return model.Namespace{}, schema.NamespaceDoesntExist + } else if err != nil && fmt.Sprintf("%s", err.Error()[0:38]) == "pq: invalid input syntax for type uuid" { + // TODO: this uuid syntax is a error defined in db, not in library + // need to look into better ways to implement this + return model.Namespace{}, schema.InvalidUUID + } else if err != nil { + return model.Namespace{}, fmt.Errorf("%w: %s", dbErr, err) + } + + transformedNamespace, err := transformToNamespace(fetchedNamespace) + if err != nil { + return model.Namespace{}, fmt.Errorf("%w: %s", parseErr, err) + } + + return transformedNamespace, nil +} + +func (s Store) CreateNamespace(ctx context.Context, namespaceToCreate model.Namespace) (model.Namespace, error) { + var newNamespace Namespace + err := s.DB.WithTimeout(ctx, func(ctx context.Context) error { + return s.DB.GetContext(ctx, &newNamespace, createNamespaceQuery, namespaceToCreate.Id, namespaceToCreate.Name) + }) + + if err != nil { + return model.Namespace{}, fmt.Errorf("%w: %s", dbErr, err) + } + + transformedNamespace, err := transformToNamespace(newNamespace) + if err != nil { + return model.Namespace{}, fmt.Errorf("%w: %s", parseErr, err) + } + + return transformedNamespace, nil +} + +func (s Store) ListNamespaces(ctx context.Context) ([]model.Namespace, error) { + var fetchedNamespaces []Namespace + err := s.DB.WithTimeout(ctx, func(ctx context.Context) error { + return s.DB.SelectContext(ctx, &fetchedNamespaces, listNamespacesQuery) + }) + + if errors.Is(err, sql.ErrNoRows) { + return []model.Namespace{}, schema.NamespaceDoesntExist + } + + if err != nil { + return []model.Namespace{}, fmt.Errorf("%w: %s", dbErr, err) + } + + var transformedNamespaces []model.Namespace + + for _, o := range fetchedNamespaces { + transformedNamespace, err := transformToNamespace(o) + if err != nil { + return []model.Namespace{}, fmt.Errorf("%w: %s", parseErr, err) + } + + transformedNamespaces = append(transformedNamespaces, transformedNamespace) + } + + return transformedNamespaces, nil +} + +func (s Store) UpdateNamespace(ctx context.Context, toUpdate model.Namespace) (model.Namespace, error) { + var updatedNamespace Namespace + + err := s.DB.WithTimeout(ctx, func(ctx context.Context) error { + return s.DB.GetContext(ctx, &updatedNamespace, updateNamespaceQuery, toUpdate.Id, toUpdate.Name) + }) + + if errors.Is(err, sql.ErrNoRows) { + return model.Namespace{}, schema.NamespaceDoesntExist + } else if err != nil { + return model.Namespace{}, fmt.Errorf("%w: %s", dbErr, err) + } + + transformedNamespace, err := transformToNamespace(updatedNamespace) + if err != nil { + return model.Namespace{}, fmt.Errorf("%s: %w", parseErr, err) + } + + return transformedNamespace, nil +} + +func transformToNamespace(from Namespace) (model.Namespace, error) { + return model.Namespace{ + Id: from.Id, + Name: from.Name, + CreatedAt: from.CreatedAt, + UpdatedAt: from.UpdatedAt, + }, nil +} diff --git a/store/postgres/policy.go b/store/postgres/policy.go new file mode 100644 index 000000000..3554d968a --- /dev/null +++ b/store/postgres/policy.go @@ -0,0 +1,176 @@ +package postgres + +import ( + "context" + "database/sql" + "errors" + "fmt" + "time" + + "github.com/odpf/shield/internal/project" + "github.com/odpf/shield/internal/schema" + "github.com/odpf/shield/model" +) + +type Policy struct { + Id string `db:"id"` + Role Role `db:"role"` + RoleID string `db:"role_id"` + Namespace Namespace `db:"namespace"` + NamespaceID string `db:"namespace_id"` + Action Action `db:"action"` + ActionID string `db:"action_id"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` +} + +const selectStatement = `p.id, roles.id "role.id",roles.name "role.name", roles.namespace_id "role.namespace_id", roles.metadata "role.metadata", namespaces.id "namespace.id", namespaces.name "namespace.name", actions.id "action.id", actions.name "action.name", actions.namespace_id "action.namespace_id"` +const joinStatement = `JOIN roles ON roles.id = p.role_id JOIN actions ON actions.id = p.action_id JOIN namespaces on namespaces.id = p.namespace_id` + +var ( + createPolicyQuery = fmt.Sprintf(`INSERT into policies(namespace_id, role_id, action_id) values($1, $2, $3) RETURNING id, namespace_id, role_id, action_id`) + getPolicyQuery = fmt.Sprintf(`SELECT %s FROM policies p %s WHERE p.id = $1`, selectStatement, joinStatement) + listPolicyQuery = fmt.Sprintf(`SELECT %s FROM policies p %s`, selectStatement, joinStatement) + updatePolicyQuery = fmt.Sprintf(`UPDATE policies SET namespace_id = $2, role_id = $3, action_id = $4, updated_at = now() where id = $1 RETURNING id, namespace_id, role_id, action_id;`) +) + +func (s Store) GetPolicy(ctx context.Context, id string) (model.Policy, error) { + fetchedPolicy, err := s.selectPolicy(ctx, id) + return fetchedPolicy, err +} + +func (s Store) selectPolicy(ctx context.Context, id string) (model.Policy, error) { + var fetchedPolicy Policy + + err := s.DB.WithTimeout(ctx, func(ctx context.Context) error { + return s.DB.GetContext(ctx, &fetchedPolicy, getPolicyQuery, id) + }) + + if errors.Is(err, sql.ErrNoRows) { + return model.Policy{}, schema.PolicyDoesntExist + } else if err != nil && fmt.Sprintf("%s", err.Error()[0:38]) == "pq: invalid input syntax for type uuid" { + // TODO: this uuid syntax is a error defined in db, not in library + // need to look into better ways to implement this + return model.Policy{}, schema.InvalidUUID + } else if err != nil { + return model.Policy{}, fmt.Errorf("%w: %s", dbErr, err) + } + + transformedPolicy, err := transformToPolicy(fetchedPolicy) + if err != nil { + return model.Policy{}, fmt.Errorf("%w: %s", parseErr, err) + } + + return transformedPolicy, nil +} + +func (s Store) ListPolicies(ctx context.Context) ([]model.Policy, error) { + var fetchedPolicies []Policy + err := s.DB.WithTimeout(ctx, func(ctx context.Context) error { + return s.DB.SelectContext(ctx, &fetchedPolicies, listPolicyQuery) + }) + + if errors.Is(err, sql.ErrNoRows) { + return []model.Policy{}, project.ProjectDoesntExist + } else if err != nil { + return []model.Policy{}, fmt.Errorf("%w: %s", dbErr, err) + } + + var transformedPolicies []model.Policy + for _, p := range fetchedPolicies { + transformedPolicy, err := transformToPolicy(p) + if err != nil { + return []model.Policy{}, fmt.Errorf("%w: %s", parseErr, err) + } + transformedPolicies = append(transformedPolicies, transformedPolicy) + } + + return transformedPolicies, nil +} + +func (s Store) fetchNamespacePolicies(ctx context.Context, namespaceId string) ([]model.Policy, error) { + var fetchedPolicies []Policy + + query := fmt.Sprintf("%s %s", listPolicyQuery, "WHERE p.namespace_id='$1'") + + err := s.DB.WithTimeout(ctx, func(ctx context.Context) error { + return s.DB.SelectContext(ctx, &fetchedPolicies, query, namespaceId) + }) + + if errors.Is(err, sql.ErrNoRows) { + return []model.Policy{}, schema.PolicyDoesntExist + } else if err != nil { + return []model.Policy{}, fmt.Errorf("%w: %s", dbErr, err) + } + + var transformedPolicies []model.Policy + for _, p := range fetchedPolicies { + transformedPolicy, err := transformToPolicy(p) + if err != nil { + return []model.Policy{}, fmt.Errorf("%w: %s", parseErr, err) + } + transformedPolicies = append(transformedPolicies, transformedPolicy) + } + + return transformedPolicies, nil +} + +func (s Store) CreatePolicy(ctx context.Context, policyToCreate model.Policy) ([]model.Policy, error) { + var newPolicy Policy + + err := s.DB.WithTimeout(ctx, func(ctx context.Context) error { + return s.DB.GetContext(ctx, &newPolicy, createPolicyQuery, policyToCreate.NamespaceId, policyToCreate.RoleId, policyToCreate.ActionId) + }) + if err != nil { + return []model.Policy{}, fmt.Errorf("%w: %s", dbErr, err) + } + return s.fetchNamespacePolicies(ctx, newPolicy.NamespaceID) +} + +func (s Store) UpdatePolicy(ctx context.Context, id string, toUpdate model.Policy) ([]model.Policy, error) { + var updatedPolicy Policy + + err := s.DB.WithTimeout(ctx, func(ctx context.Context) error { + return s.DB.GetContext(ctx, &updatedPolicy, updatePolicyQuery, id, toUpdate.NamespaceId, toUpdate.RoleId, toUpdate.ActionId) + }) + + if err != nil { + return []model.Policy{}, fmt.Errorf("%w: %s", dbErr, err) + } + + return s.fetchNamespacePolicies(ctx, updatedPolicy.NamespaceID) +} + +func transformToPolicy(from Policy) (model.Policy, error) { + var role model.Role + var err error + + if from.Role.Id != "" { + role, err = transformToRole(from.Role) + if err != nil { + return model.Policy{}, fmt.Errorf("%w: %s", parseErr, err) + } + } + + action, err := transformToAction(from.Action) + if err != nil { + return model.Policy{}, fmt.Errorf("%w: %s", parseErr, err) + } + + namespace, err := transformToNamespace(from.Namespace) + if err != nil { + return model.Policy{}, fmt.Errorf("%w: %s", parseErr, err) + } + + return model.Policy{ + Id: from.Id, + Role: role, + RoleId: from.RoleID, + Action: action, + ActionId: from.ActionID, + Namespace: namespace, + NamespaceId: from.NamespaceID, + CreatedAt: from.CreatedAt, + UpdatedAt: from.UpdatedAt, + }, nil +} diff --git a/store/postgres/roles.go b/store/postgres/roles.go index b05d13a58..40ba743b9 100644 --- a/store/postgres/roles.go +++ b/store/postgres/roles.go @@ -8,26 +8,28 @@ import ( "fmt" "time" + "github.com/lib/pq" "github.com/odpf/shield/internal/project" "github.com/odpf/shield/internal/roles" "github.com/odpf/shield/model" ) type Role struct { - Id string `db:"id"` - Name string `db:"name"` - Types []string `db:"types"` - Namespace string `db:"namespace"` - Metadata []byte `db:"metadata"` - CreatedAt time.Time `db:"created_at"` - UpdatedAt time.Time `db:"updated_at"` + Id string `db:"id"` + Name string `db:"name"` + Types pq.StringArray `db:"types"` + Namespace Namespace `db:"namespace"` + NamespaceID string `db:"namespace_id"` + Metadata []byte `db:"metadata"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` } const ( - createRoleQuery = `INSERT into roles(id, name, types, namespace, metadata) values($1, $2, $3, $4, $5) RETURNING id, name, types, namespace, metadata, created_at, updated_at;` - getRoleQuery = `SELECT id, name, types, namespace, metadata, created_at, updated_at from roles where id=$1;` - listRolesQuery = `SELECT id, name, types, namespace, metadata, created_at, updated_at from roles;` - updateRoleQuery = `UPDATE roles SET name = $2, types = $3, namespace = $4, metadata = $5, updated_at = now() where id = $1;` + createRoleQuery = `INSERT into roles(id, name, types, namespace_id, metadata) values($1, $2, $3, $4, $5) RETURNING id, name, types, namespace_id, metadata, created_at, updated_at;` + getRoleQuery = `SELECT id, name, types, namespace_id, metadata, created_at, updated_at from roles where id=$1;` + listRolesQuery = `SELECT id, name, types, namespace_id, metadata, created_at, updated_at from roles;` + updateRoleQuery = `UPDATE roles SET name = $2, types = $3, namespace_id = $4, metadata = $5, updated_at = now() where id = $1;` ) func (s Store) GetRole(ctx context.Context, id string) (model.Role, error) { @@ -58,7 +60,7 @@ func (s Store) CreateRole(ctx context.Context, roleToCreate model.Role) (model.R var newRole Role err = s.DB.WithTimeout(ctx, func(ctx context.Context) error { - return s.DB.GetContext(ctx, &newRole, createRoleQuery, marshaledMetadata) + return s.DB.GetContext(ctx, &newRole, createRoleQuery, roleToCreate.Id, roleToCreate.Name, pq.StringArray(roleToCreate.Types), roleToCreate.Namespace, marshaledMetadata) }) if err != nil { return model.Role{}, fmt.Errorf("%w: %s", dbErr, err) @@ -105,7 +107,7 @@ func (s Store) UpdateRole(ctx context.Context, toUpdate model.Role) (model.Role, } err = s.DB.WithTimeout(ctx, func(ctx context.Context) error { - return s.DB.GetContext(ctx, &updatedRole, updateRoleQuery, toUpdate.Id, toUpdate.Name, toUpdate.Types, toUpdate.Namespace, marshaledMetadata) + return s.DB.GetContext(ctx, &updatedRole, updateRoleQuery, toUpdate.Id, toUpdate.Name, toUpdate.Types, toUpdate.NamespaceId, marshaledMetadata) }) if errors.Is(err, sql.ErrNoRows) { @@ -124,17 +126,24 @@ func (s Store) UpdateRole(ctx context.Context, toUpdate model.Role) (model.Role, func transformToRole(from Role) (model.Role, error) { var unmarshalledMetadata map[string]string - if err := json.Unmarshal(from.Metadata, &unmarshalledMetadata); err != nil { - return model.Role{}, err + if len(from.Metadata) > 0 { + if err := json.Unmarshal(from.Metadata, &unmarshalledMetadata); err != nil { + return model.Role{}, err + } } + namespace, err := transformToNamespace(from.Namespace) + if err != nil { + return model.Role{}, err + } return model.Role{ - Id: from.Id, - Name: from.Name, - Types: from.Types, - Namespace: from.Namespace, - Metadata: unmarshalledMetadata, - CreatedAt: from.CreatedAt, - UpdatedAt: from.UpdatedAt, + Id: from.Id, + Name: from.Name, + Types: from.Types, + Namespace: namespace, + NamespaceId: from.NamespaceID, + Metadata: unmarshalledMetadata, + CreatedAt: from.CreatedAt, + UpdatedAt: from.UpdatedAt, }, nil }