From e641d9bcd9b3bafddb0e17f0b37e3b2135598602 Mon Sep 17 00:00:00 2001 From: Miguel Martinez Trivino Date: Thu, 16 Nov 2023 12:25:21 +0100 Subject: [PATCH 1/7] configure index Signed-off-by: Miguel Martinez Trivino --- app/controlplane/cmd/wire.go | 2 +- app/controlplane/cmd/wire_gen.go | 7 +- app/controlplane/configs/config.devel.yaml | 5 + app/controlplane/configs/samples/config.yaml | 12 +- app/controlplane/internal/biz/referrer.go | 107 ++++- .../internal/biz/referrer_test.go | 52 +++ .../internal/biz/testhelpers/database.go | 8 + .../internal/biz/testhelpers/wire.go | 5 +- .../internal/biz/testhelpers/wire_gen.go | 17 +- app/controlplane/internal/conf/conf.go | 41 ++ app/controlplane/internal/conf/conf.pb.go | 414 +++++++++++------- .../internal/conf/conf.pb.validate.go | 133 ++++++ app/controlplane/internal/conf/conf.proto | 13 + app/controlplane/internal/conf/conf_test.go | 69 +++ 14 files changed, 696 insertions(+), 189 deletions(-) create mode 100644 app/controlplane/internal/conf/conf.go create mode 100644 app/controlplane/internal/conf/conf_test.go diff --git a/app/controlplane/cmd/wire.go b/app/controlplane/cmd/wire.go index 45c23368f..48fc024e7 100644 --- a/app/controlplane/cmd/wire.go +++ b/app/controlplane/cmd/wire.go @@ -46,7 +46,7 @@ func wireApp(*conf.Bootstrap, credentials.ReaderWriter, log.Logger, sdk.Availabl wire.Bind(new(biz.CASClient), new(*biz.CASClientUseCase)), serviceOpts, wire.Value([]biz.CASClientOpts{}), - wire.FieldsOf(new(*conf.Bootstrap), "Server", "Auth", "Data", "CasServer"), + wire.FieldsOf(new(*conf.Bootstrap), "Server", "Auth", "Data", "CasServer", "ReferrerSharedIndex"), dispatcher.New, newApp, ), diff --git a/app/controlplane/cmd/wire_gen.go b/app/controlplane/cmd/wire_gen.go index 3c55b6554..6dd1c7053 100644 --- a/app/controlplane/cmd/wire_gen.go +++ b/app/controlplane/cmd/wire_gen.go @@ -65,7 +65,12 @@ func wireApp(bootstrap *conf.Bootstrap, readerWriter credentials.ReaderWriter, l v := _wireValue casClientUseCase := biz.NewCASClientUseCase(casCredentialsUseCase, bootstrap_CASServer, logger, v...) referrerRepo := data.NewReferrerRepo(dataData, workflowRepo, logger) - referrerUseCase := biz.NewReferrerUseCase(referrerRepo, workflowRepo, membershipRepo, logger) + referrerSharedIndex := bootstrap.ReferrerSharedIndex + referrerUseCase, err := biz.NewReferrerUseCase(referrerRepo, workflowRepo, membershipRepo, referrerSharedIndex, logger) + if err != nil { + cleanup() + return nil, nil, err + } workflowContractRepo := data.NewWorkflowContractRepo(dataData, logger) workflowContractUseCase := biz.NewWorkflowContractUseCase(workflowContractRepo, logger) workflowUseCase := biz.NewWorkflowUsecase(workflowRepo, workflowContractUseCase, logger) diff --git a/app/controlplane/configs/config.devel.yaml b/app/controlplane/configs/config.devel.yaml index 36d1f1076..0c81706f2 100644 --- a/app/controlplane/configs/config.devel.yaml +++ b/app/controlplane/configs/config.devel.yaml @@ -47,3 +47,8 @@ auth: # Private key used to sign the JWTs meant to be consumed by the CAS cas_robot_account_private_key_path: "../../devel/devkeys/cas.pem" + +referrer_shared_index: + enabled: false + allowed_orgs: + - deadbeef diff --git a/app/controlplane/configs/samples/config.yaml b/app/controlplane/configs/samples/config.yaml index 9f6efb58c..cd3556347 100644 --- a/app/controlplane/configs/samples/config.yaml +++ b/app/controlplane/configs/samples/config.yaml @@ -45,4 +45,14 @@ credentials_service: # tenant_id: AD-tenant-id # client_id: Service Principal ID # client_secret: Service Principal Secret - # vault_uri: https://myvault.vault.azure.net/ \ No newline at end of file + # vault_uri: https://myvault.vault.azure.net/ + +# referrer shared index configuration. +# This is used to enable a shared index API endpoint that can be used to discover metadata referrers +# To populate the shared index you need to enable the feature and configure the allowed orgs +# The reason to have an org allowList is to avoid leaking metadata from other organizations +# and set the stage for a trusted publisher model +referrer_shared_index: + enabled: true + allowed_orgs: + - deadbeef \ No newline at end of file diff --git a/app/controlplane/internal/biz/referrer.go b/app/controlplane/internal/biz/referrer.go index eac2fedae..7013d574a 100644 --- a/app/controlplane/internal/biz/referrer.go +++ b/app/controlplane/internal/biz/referrer.go @@ -25,6 +25,7 @@ import ( "sort" "time" + "github.com/chainloop-dev/chainloop/app/controlplane/internal/conf" "github.com/chainloop-dev/chainloop/internal/attestation/renderer/chainloop" "github.com/chainloop-dev/chainloop/internal/servicelogger" "github.com/go-kratos/kratos/v2/log" @@ -34,6 +35,47 @@ import ( "github.com/secure-systems-lab/go-securesystemslib/dsse" ) +type ReferrerUseCase struct { + repo ReferrerRepo + membershipRepo MembershipRepo + workflowRepo WorkflowRepo + logger *log.Helper + indexConfig *conf.ReferrerSharedIndex +} + +func NewReferrerUseCase(repo ReferrerRepo, wfRepo WorkflowRepo, mRepo MembershipRepo, indexCfg *conf.ReferrerSharedIndex, l log.Logger) (*ReferrerUseCase, error) { + if l == nil { + l = log.NewStdLogger(io.Discard) + } + logger := servicelogger.ScopedHelper(l, "biz/referrer") + + if indexCfg != nil { + if err := indexCfg.ValidateOrgs(); err != nil { + return nil, fmt.Errorf("invalid shared index config: %w", err) + } + + if indexCfg.Enabled { + logger.Infow("msg", "shared index enabled", "allowedOrgs", indexCfg.AllowedOrgs) + } + } + + return &ReferrerUseCase{ + repo: repo, + membershipRepo: mRepo, + indexConfig: indexCfg, + workflowRepo: wfRepo, + logger: logger, + }, nil +} + +type ReferrerRepo interface { + Save(ctx context.Context, input []*Referrer, workflowID uuid.UUID) error + // GetFromRoot returns the referrer identified by the provided content digest, including its first-level references + // For example if sha:deadbeef represents an attestation, the result will contain the attestation + materials associated to it + // OrgIDs represent an allowList of organizations where the referrers should be looked for + GetFromRoot(ctx context.Context, digest string, orgIDS []uuid.UUID, filters ...GetFromRootFilter) (*StoredReferrer, error) +} + type Referrer struct { Digest string Kind string @@ -54,14 +96,6 @@ type StoredReferrer struct { OrgIDs, WorkflowIDs []uuid.UUID } -type ReferrerRepo interface { - Save(ctx context.Context, input []*Referrer, workflowID uuid.UUID) error - // GetFromRoot returns the referrer identified by the provided content digest, including its first-level references - // For example if sha:deadbeef represents an attestation, the result will contain the attestation + materials associated to it - // OrgIDs represent an allowList of organizations where the referrers should be looked for - GetFromRoot(ctx context.Context, digest string, orgIDS []uuid.UUID, filters ...GetFromRootFilter) (*StoredReferrer, error) -} - type GetFromRootFilters struct { // RootKind is the kind of the root referrer, i.e ATTESTATION RootKind *string @@ -83,21 +117,6 @@ func WithPublicVisibility(public bool) func(*GetFromRootFilters) { } } -type ReferrerUseCase struct { - repo ReferrerRepo - membershipRepo MembershipRepo - workflowRepo WorkflowRepo - logger *log.Helper -} - -func NewReferrerUseCase(repo ReferrerRepo, wfRepo WorkflowRepo, mRepo MembershipRepo, l log.Logger) *ReferrerUseCase { - if l == nil { - l = log.NewStdLogger(io.Discard) - } - - return &ReferrerUseCase{repo, mRepo, wfRepo, servicelogger.ScopedHelper(l, "biz/Referrer")} -} - // ExtractAndPersist extracts the referrers (subject + materials) from the given attestation // and store it as part of the referrers index table func (s *ReferrerUseCase) ExtractAndPersist(ctx context.Context, att *dsse.Envelope, workflowID string) error { @@ -128,7 +147,7 @@ func (s *ReferrerUseCase) ExtractAndPersist(ctx context.Context, att *dsse.Envel // GetFromRoot returns the referrer identified by the provided content digest, including its first-level references // For example if sha:deadbeef represents an attestation, the result will contain the attestation + materials associated to it // It only returns referrers that belong to organizations the user is member of -func (s *ReferrerUseCase) GetFromRoot(ctx context.Context, digest string, rootKind, userID string) (*StoredReferrer, error) { +func (s *ReferrerUseCase) GetFromRoot(ctx context.Context, digest, rootKind, userID string) (*StoredReferrer, error) { userUUID, err := uuid.Parse(userID) if err != nil { return nil, NewErrInvalidUUID(err) @@ -170,6 +189,46 @@ func (s *ReferrerUseCase) GetFromRoot(ctx context.Context, digest string, rootKi return ref, nil } +// Get the list of public referrers from organizations that have been allowed to be shown in a shared index +func (s *ReferrerUseCase) GetFromRootInPublicSharedIndex(ctx context.Context, digest, rootKind string) (*StoredReferrer, error) { + if s.indexConfig == nil || !s.indexConfig.Enabled { + return nil, NewErrUnauthorizedStr("shared referrer index functionality is not enabled") + } + + if _, err := cr_v1.NewHash(digest); err != nil { + return nil, NewErrValidation(fmt.Errorf("invalid digest format: %w", err)) + } + + // Load the organizations that are allowed to appear in the shared index + orgIDs := make([]uuid.UUID, 0) + for _, orgID := range s.indexConfig.AllowedOrgs { + orgUUID, err := uuid.Parse(orgID) + if err != nil { + return nil, NewErrInvalidUUID(err) + } + orgIDs = append(orgIDs, orgUUID) + } + + // and ask only for the public referrers of those orgs + filters := []GetFromRootFilter{WithPublicVisibility(true)} + if rootKind != "" { + filters = append(filters, WithKind(rootKind)) + } + + ref, err := s.repo.GetFromRoot(ctx, digest, orgIDs, filters...) + if err != nil { + if errors.As(err, &ErrAmbiguousReferrer{}) { + return nil, NewErrValidation(fmt.Errorf("please provide the referrer kind: %w", err)) + } + + return nil, fmt.Errorf("getting referrer from root: %w", err) + } else if ref == nil { + return nil, NewErrNotFound("referrer") + } + + return ref, nil +} + const ( referrerAttestationType = "ATTESTATION" referrerGitHeadType = "GIT_HEAD_COMMIT" diff --git a/app/controlplane/internal/biz/referrer_test.go b/app/controlplane/internal/biz/referrer_test.go index 7b147192c..ef8bc5db1 100644 --- a/app/controlplane/internal/biz/referrer_test.go +++ b/app/controlplane/internal/biz/referrer_test.go @@ -20,12 +20,64 @@ import ( "os" "testing" + "github.com/chainloop-dev/chainloop/app/controlplane/internal/conf" "github.com/secure-systems-lab/go-securesystemslib/dsse" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" ) +func (s *referrerTestSuite) TestInitialization() { + testCases := []struct { + name string + conf *conf.ReferrerSharedIndex + wantErrMsg string + }{ + { + name: "nil configuration", + }, + { + name: "disabled", + conf: &conf.ReferrerSharedIndex{ + Enabled: false, + }, + }, + { + name: "enabled but without orgs", + conf: &conf.ReferrerSharedIndex{ + Enabled: true, + }, + wantErrMsg: "invalid shared index config: index is enabled, but no orgs are allowed", + }, + { + name: "enabled with invalid orgs", + conf: &conf.ReferrerSharedIndex{ + Enabled: true, + AllowedOrgs: []string{"invalid"}, + }, + wantErrMsg: "invalid shared index config: invalid org id: invalid", + }, + { + name: "enabled with valid orgs", + conf: &conf.ReferrerSharedIndex{ + Enabled: true, + AllowedOrgs: []string{"00000000-0000-0000-0000-000000000000"}, + }, + }, + } + + for _, tc := range testCases { + s.T().Run(tc.name, func(t *testing.T) { + _, err := NewReferrerUseCase(nil, nil, nil, tc.conf, nil) + if tc.wantErrMsg != "" { + assert.EqualError(t, err, tc.wantErrMsg) + } else { + assert.NoError(t, err) + } + }) + } +} + func (s *referrerTestSuite) TestExtractReferrers() { testCases := []struct { name string diff --git a/app/controlplane/internal/biz/testhelpers/database.go b/app/controlplane/internal/biz/testhelpers/database.go index f649677bd..e10f9790f 100644 --- a/app/controlplane/internal/biz/testhelpers/database.go +++ b/app/controlplane/internal/biz/testhelpers/database.go @@ -66,6 +66,14 @@ type TestingUseCases struct { CASMapping *biz.CASMappingUseCase OrgInvitation *biz.OrgInvitationUseCase Referrer *biz.ReferrerUseCase + // Repositories that can be used for custom crafting of use-cases + Repos *TestingRepos +} + +type TestingRepos struct { + Membership biz.MembershipRepo + Referrer biz.ReferrerRepo + Workflow biz.WorkflowRepo } type newTestingOpts struct { diff --git a/app/controlplane/internal/biz/testhelpers/wire.go b/app/controlplane/internal/biz/testhelpers/wire.go index f4d919a02..5ee7847fb 100644 --- a/app/controlplane/internal/biz/testhelpers/wire.go +++ b/app/controlplane/internal/biz/testhelpers/wire.go @@ -21,6 +21,8 @@ package testhelpers import ( + "testing" + "github.com/chainloop-dev/chainloop/app/controlplane/internal/biz" "github.com/chainloop-dev/chainloop/app/controlplane/internal/conf" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data" @@ -30,7 +32,6 @@ import ( robotaccount "github.com/chainloop-dev/chainloop/internal/robotaccount/cas" "github.com/go-kratos/kratos/v2/log" "github.com/google/wire" - "testing" ) // wireTestData init testing data @@ -39,7 +40,9 @@ func WireTestData(*TestDatabase, *testing.T, log.Logger, credentials.ReaderWrite wire.Build( data.ProviderSet, biz.ProviderSet, + wire.Value(&conf.ReferrerSharedIndex{}), wire.Struct(new(TestingUseCases), "*"), + wire.Struct(new(TestingRepos), "*"), newConfData, ), ) diff --git a/app/controlplane/internal/biz/testhelpers/wire_gen.go b/app/controlplane/internal/biz/testhelpers/wire_gen.go index 246f77834..afcb5f161 100644 --- a/app/controlplane/internal/biz/testhelpers/wire_gen.go +++ b/app/controlplane/internal/biz/testhelpers/wire_gen.go @@ -76,7 +76,17 @@ func WireTestData(testDatabase *TestDatabase, t *testing.T, logger log.Logger, r return nil, nil, err } referrerRepo := data.NewReferrerRepo(dataData, workflowRepo, logger) - referrerUseCase := biz.NewReferrerUseCase(referrerRepo, workflowRepo, membershipRepo, logger) + referrerSharedIndex := _wireReferrerSharedIndexValue + referrerUseCase, err := biz.NewReferrerUseCase(referrerRepo, workflowRepo, membershipRepo, referrerSharedIndex, logger) + if err != nil { + cleanup() + return nil, nil, err + } + testingRepos := &TestingRepos{ + Membership: membershipRepo, + Referrer: referrerRepo, + Workflow: workflowRepo, + } testingUseCases := &TestingUseCases{ DB: testDatabase, Data: dataData, @@ -94,8 +104,13 @@ func WireTestData(testDatabase *TestDatabase, t *testing.T, logger log.Logger, r CASMapping: casMappingUseCase, OrgInvitation: orgInvitationUseCase, Referrer: referrerUseCase, + Repos: testingRepos, } return testingUseCases, func() { cleanup() }, nil } + +var ( + _wireReferrerSharedIndexValue = &conf.ReferrerSharedIndex{} +) diff --git a/app/controlplane/internal/conf/conf.go b/app/controlplane/internal/conf/conf.go new file mode 100644 index 000000000..1d3b0d056 --- /dev/null +++ b/app/controlplane/internal/conf/conf.go @@ -0,0 +1,41 @@ +// +// Copyright 2023 The Chainloop Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package conf + +import ( + "errors" + "fmt" + + "github.com/google/uuid" +) + +func (c *ReferrerSharedIndex) ValidateOrgs() error { + if c == nil { + return nil + } + + if c.Enabled && len(c.AllowedOrgs) == 0 { + return errors.New("index is enabled, but no orgs are allowed") + } + + for _, orgID := range c.AllowedOrgs { + if _, err := uuid.Parse(orgID); err != nil { + return fmt.Errorf("invalid org id: %s", orgID) + } + } + + return nil +} diff --git a/app/controlplane/internal/conf/conf.pb.go b/app/controlplane/internal/conf/conf.pb.go index c5392a7e9..0c32e0a01 100644 --- a/app/controlplane/internal/conf/conf.pb.go +++ b/app/controlplane/internal/conf/conf.pb.go @@ -53,6 +53,8 @@ type Bootstrap struct { // Plugins directory // NOTE: plugins have the form of chainloop-plugin- PluginsDir string `protobuf:"bytes,7,opt,name=plugins_dir,json=pluginsDir,proto3" json:"plugins_dir,omitempty"` + // Configuration about the shared referrer index + ReferrerSharedIndex *ReferrerSharedIndex `protobuf:"bytes,8,opt,name=referrer_shared_index,json=referrerSharedIndex,proto3" json:"referrer_shared_index,omitempty"` } func (x *Bootstrap) Reset() { @@ -136,6 +138,74 @@ func (x *Bootstrap) GetPluginsDir() string { return "" } +func (x *Bootstrap) GetReferrerSharedIndex() *ReferrerSharedIndex { + if x != nil { + return x.ReferrerSharedIndex + } + return nil +} + +// Configuration used to enable a shared index API endpoint that can be used to discover metadata referrers +// To populate the shared index you need to enable the feature and configure the allowed orgs +// The reason to have an org allowList is to avoid leaking metadata from other organizations and set the stage for a trusted publisher model +type ReferrerSharedIndex struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // If the shared, public index feature is enabled + Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` + // list of organizations uuids that are allowed to appear in the shared referrer index + // think of it as a list of trusted publishers + AllowedOrgs []string `protobuf:"bytes,2,rep,name=allowed_orgs,json=allowedOrgs,proto3" json:"allowed_orgs,omitempty"` +} + +func (x *ReferrerSharedIndex) Reset() { + *x = ReferrerSharedIndex{} + if protoimpl.UnsafeEnabled { + mi := &file_conf_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReferrerSharedIndex) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReferrerSharedIndex) ProtoMessage() {} + +func (x *ReferrerSharedIndex) ProtoReflect() protoreflect.Message { + mi := &file_conf_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReferrerSharedIndex.ProtoReflect.Descriptor instead. +func (*ReferrerSharedIndex) Descriptor() ([]byte, []int) { + return file_conf_proto_rawDescGZIP(), []int{1} +} + +func (x *ReferrerSharedIndex) GetEnabled() bool { + if x != nil { + return x.Enabled + } + return false +} + +func (x *ReferrerSharedIndex) GetAllowedOrgs() []string { + if x != nil { + return x.AllowedOrgs + } + return nil +} + type Server struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -150,7 +220,7 @@ type Server struct { func (x *Server) Reset() { *x = Server{} if protoimpl.UnsafeEnabled { - mi := &file_conf_proto_msgTypes[1] + mi := &file_conf_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -163,7 +233,7 @@ func (x *Server) String() string { func (*Server) ProtoMessage() {} func (x *Server) ProtoReflect() protoreflect.Message { - mi := &file_conf_proto_msgTypes[1] + mi := &file_conf_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -176,7 +246,7 @@ func (x *Server) ProtoReflect() protoreflect.Message { // Deprecated: Use Server.ProtoReflect.Descriptor instead. func (*Server) Descriptor() ([]byte, []int) { - return file_conf_proto_rawDescGZIP(), []int{1} + return file_conf_proto_rawDescGZIP(), []int{2} } func (x *Server) GetHttp() *Server_HTTP { @@ -211,7 +281,7 @@ type Data struct { func (x *Data) Reset() { *x = Data{} if protoimpl.UnsafeEnabled { - mi := &file_conf_proto_msgTypes[2] + mi := &file_conf_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -224,7 +294,7 @@ func (x *Data) String() string { func (*Data) ProtoMessage() {} func (x *Data) ProtoReflect() protoreflect.Message { - mi := &file_conf_proto_msgTypes[2] + mi := &file_conf_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -237,7 +307,7 @@ func (x *Data) ProtoReflect() protoreflect.Message { // Deprecated: Use Data.ProtoReflect.Descriptor instead. func (*Data) Descriptor() ([]byte, []int) { - return file_conf_proto_rawDescGZIP(), []int{2} + return file_conf_proto_rawDescGZIP(), []int{3} } func (x *Data) GetDatabase() *Data_Database { @@ -262,7 +332,7 @@ type Auth struct { func (x *Auth) Reset() { *x = Auth{} if protoimpl.UnsafeEnabled { - mi := &file_conf_proto_msgTypes[3] + mi := &file_conf_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -275,7 +345,7 @@ func (x *Auth) String() string { func (*Auth) ProtoMessage() {} func (x *Auth) ProtoReflect() protoreflect.Message { - mi := &file_conf_proto_msgTypes[3] + mi := &file_conf_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -288,7 +358,7 @@ func (x *Auth) ProtoReflect() protoreflect.Message { // Deprecated: Use Auth.ProtoReflect.Descriptor instead. func (*Auth) Descriptor() ([]byte, []int) { - return file_conf_proto_rawDescGZIP(), []int{3} + return file_conf_proto_rawDescGZIP(), []int{4} } func (x *Auth) GetGeneratedJwsHmacSecret() string { @@ -330,7 +400,7 @@ type Bootstrap_Observability struct { func (x *Bootstrap_Observability) Reset() { *x = Bootstrap_Observability{} if protoimpl.UnsafeEnabled { - mi := &file_conf_proto_msgTypes[4] + mi := &file_conf_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -343,7 +413,7 @@ func (x *Bootstrap_Observability) String() string { func (*Bootstrap_Observability) ProtoMessage() {} func (x *Bootstrap_Observability) ProtoReflect() protoreflect.Message { - mi := &file_conf_proto_msgTypes[4] + mi := &file_conf_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -384,7 +454,7 @@ type Bootstrap_CASServer struct { func (x *Bootstrap_CASServer) Reset() { *x = Bootstrap_CASServer{} if protoimpl.UnsafeEnabled { - mi := &file_conf_proto_msgTypes[5] + mi := &file_conf_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -397,7 +467,7 @@ func (x *Bootstrap_CASServer) String() string { func (*Bootstrap_CASServer) ProtoMessage() {} func (x *Bootstrap_CASServer) ProtoReflect() protoreflect.Message { - mi := &file_conf_proto_msgTypes[5] + mi := &file_conf_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -446,7 +516,7 @@ type Bootstrap_Observability_Sentry struct { func (x *Bootstrap_Observability_Sentry) Reset() { *x = Bootstrap_Observability_Sentry{} if protoimpl.UnsafeEnabled { - mi := &file_conf_proto_msgTypes[6] + mi := &file_conf_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -459,7 +529,7 @@ func (x *Bootstrap_Observability_Sentry) String() string { func (*Bootstrap_Observability_Sentry) ProtoMessage() {} func (x *Bootstrap_Observability_Sentry) ProtoReflect() protoreflect.Message { - mi := &file_conf_proto_msgTypes[6] + mi := &file_conf_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -505,7 +575,7 @@ type Server_HTTP struct { func (x *Server_HTTP) Reset() { *x = Server_HTTP{} if protoimpl.UnsafeEnabled { - mi := &file_conf_proto_msgTypes[7] + mi := &file_conf_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -518,7 +588,7 @@ func (x *Server_HTTP) String() string { func (*Server_HTTP) ProtoMessage() {} func (x *Server_HTTP) ProtoReflect() protoreflect.Message { - mi := &file_conf_proto_msgTypes[7] + mi := &file_conf_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -531,7 +601,7 @@ func (x *Server_HTTP) ProtoReflect() protoreflect.Message { // Deprecated: Use Server_HTTP.ProtoReflect.Descriptor instead. func (*Server_HTTP) Descriptor() ([]byte, []int) { - return file_conf_proto_rawDescGZIP(), []int{1, 0} + return file_conf_proto_rawDescGZIP(), []int{2, 0} } func (x *Server_HTTP) GetNetwork() string { @@ -575,7 +645,7 @@ type Server_TLS struct { func (x *Server_TLS) Reset() { *x = Server_TLS{} if protoimpl.UnsafeEnabled { - mi := &file_conf_proto_msgTypes[8] + mi := &file_conf_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -588,7 +658,7 @@ func (x *Server_TLS) String() string { func (*Server_TLS) ProtoMessage() {} func (x *Server_TLS) ProtoReflect() protoreflect.Message { - mi := &file_conf_proto_msgTypes[8] + mi := &file_conf_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -601,7 +671,7 @@ func (x *Server_TLS) ProtoReflect() protoreflect.Message { // Deprecated: Use Server_TLS.ProtoReflect.Descriptor instead. func (*Server_TLS) Descriptor() ([]byte, []int) { - return file_conf_proto_rawDescGZIP(), []int{1, 1} + return file_conf_proto_rawDescGZIP(), []int{2, 1} } func (x *Server_TLS) GetCertificate() string { @@ -632,7 +702,7 @@ type Server_GRPC struct { func (x *Server_GRPC) Reset() { *x = Server_GRPC{} if protoimpl.UnsafeEnabled { - mi := &file_conf_proto_msgTypes[9] + mi := &file_conf_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -645,7 +715,7 @@ func (x *Server_GRPC) String() string { func (*Server_GRPC) ProtoMessage() {} func (x *Server_GRPC) ProtoReflect() protoreflect.Message { - mi := &file_conf_proto_msgTypes[9] + mi := &file_conf_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -658,7 +728,7 @@ func (x *Server_GRPC) ProtoReflect() protoreflect.Message { // Deprecated: Use Server_GRPC.ProtoReflect.Descriptor instead. func (*Server_GRPC) Descriptor() ([]byte, []int) { - return file_conf_proto_rawDescGZIP(), []int{1, 2} + return file_conf_proto_rawDescGZIP(), []int{2, 2} } func (x *Server_GRPC) GetNetwork() string { @@ -701,7 +771,7 @@ type Data_Database struct { func (x *Data_Database) Reset() { *x = Data_Database{} if protoimpl.UnsafeEnabled { - mi := &file_conf_proto_msgTypes[10] + mi := &file_conf_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -714,7 +784,7 @@ func (x *Data_Database) String() string { func (*Data_Database) ProtoMessage() {} func (x *Data_Database) ProtoReflect() protoreflect.Message { - mi := &file_conf_proto_msgTypes[10] + mi := &file_conf_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -727,7 +797,7 @@ func (x *Data_Database) ProtoReflect() protoreflect.Message { // Deprecated: Use Data_Database.ProtoReflect.Descriptor instead. func (*Data_Database) Descriptor() ([]byte, []int) { - return file_conf_proto_rawDescGZIP(), []int{2, 0} + return file_conf_proto_rawDescGZIP(), []int{3, 0} } func (x *Data_Database) GetDriver() string { @@ -758,7 +828,7 @@ type Auth_OIDC struct { func (x *Auth_OIDC) Reset() { *x = Auth_OIDC{} if protoimpl.UnsafeEnabled { - mi := &file_conf_proto_msgTypes[11] + mi := &file_conf_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -771,7 +841,7 @@ func (x *Auth_OIDC) String() string { func (*Auth_OIDC) ProtoMessage() {} func (x *Auth_OIDC) ProtoReflect() protoreflect.Message { - mi := &file_conf_proto_msgTypes[11] + mi := &file_conf_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -784,7 +854,7 @@ func (x *Auth_OIDC) ProtoReflect() protoreflect.Message { // Deprecated: Use Auth_OIDC.ProtoReflect.Descriptor instead. func (*Auth_OIDC) Descriptor() ([]byte, []int) { - return file_conf_proto_rawDescGZIP(), []int{3, 0} + return file_conf_proto_rawDescGZIP(), []int{4, 0} } func (x *Auth_OIDC) GetDomain() string { @@ -824,7 +894,7 @@ var file_conf_proto_rawDesc = []byte{ 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x22, 0xc7, 0x04, 0x0a, 0x09, 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, + 0x74, 0x6f, 0x22, 0x91, 0x05, 0x0a, 0x09, 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x12, 0x1f, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x19, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, @@ -844,89 +914,99 @@ var file_conf_proto_rawDesc = []byte{ 0x73, 0x74, 0x72, 0x61, 0x70, 0x2e, 0x43, 0x41, 0x53, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x09, 0x63, 0x61, 0x73, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x5f, 0x64, 0x69, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0a, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x44, 0x69, 0x72, 0x1a, 0x86, 0x01, 0x0a, 0x0d, - 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x37, 0x0a, - 0x06, 0x73, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, - 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, - 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x53, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, - 0x73, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x1a, 0x3c, 0x0a, 0x06, 0x53, 0x65, 0x6e, 0x74, 0x72, 0x79, - 0x12, 0x10, 0x0a, 0x03, 0x64, 0x73, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x64, - 0x73, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, - 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, - 0x6d, 0x65, 0x6e, 0x74, 0x1a, 0x76, 0x0a, 0x09, 0x43, 0x41, 0x53, 0x53, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x12, 0x2a, 0x0a, 0x04, 0x67, 0x72, 0x70, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x0c, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x47, 0x52, 0x50, 0x43, 0x42, 0x08, 0xfa, - 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x04, 0x67, 0x72, 0x70, 0x63, 0x12, 0x1a, 0x0a, - 0x08, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x08, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, 0x77, - 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0b, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x55, 0x72, 0x6c, 0x22, 0xf7, 0x03, 0x0a, - 0x06, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x04, 0x68, 0x74, 0x74, 0x70, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x48, - 0x54, 0x54, 0x50, 0x52, 0x04, 0x68, 0x74, 0x74, 0x70, 0x12, 0x20, 0x0a, 0x04, 0x67, 0x72, 0x70, - 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x2e, 0x47, 0x52, 0x50, 0x43, 0x52, 0x04, 0x67, 0x72, 0x70, 0x63, 0x12, 0x2f, 0x0a, 0x0c, 0x68, - 0x74, 0x74, 0x70, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x0c, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x48, 0x54, 0x54, 0x50, 0x52, - 0x0b, 0x68, 0x74, 0x74, 0x70, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x1a, 0x8c, 0x01, 0x0a, - 0x04, 0x48, 0x54, 0x54, 0x50, 0x12, 0x18, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, - 0x12, 0x0a, 0x04, 0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x61, - 0x64, 0x64, 0x72, 0x12, 0x21, 0x0a, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, - 0x75, 0x72, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x78, 0x74, 0x65, 0x72, - 0x6e, 0x61, 0x6c, 0x55, 0x72, 0x6c, 0x12, 0x33, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, - 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x1a, 0x48, 0x0a, 0x03, 0x54, - 0x4c, 0x53, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, - 0x63, 0x61, 0x74, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x5f, - 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x69, 0x76, 0x61, - 0x74, 0x65, 0x4b, 0x65, 0x79, 0x1a, 0x9e, 0x01, 0x0a, 0x04, 0x47, 0x52, 0x50, 0x43, 0x12, 0x18, - 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x1b, 0x0a, 0x04, 0x61, 0x64, 0x64, 0x72, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, - 0x04, 0x61, 0x64, 0x64, 0x72, 0x12, 0x33, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x2a, 0x0a, 0x0a, 0x74, 0x6c, - 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, - 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x4c, 0x53, 0x52, 0x09, 0x74, 0x6c, 0x73, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x6e, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12, 0x2a, - 0x0a, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x0e, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, - 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x1a, 0x3a, 0x0a, 0x08, 0x44, 0x61, - 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x12, 0x16, - 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0xde, 0x02, 0x0a, 0x04, 0x41, 0x75, 0x74, 0x68, 0x12, - 0x39, 0x0a, 0x19, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x6a, 0x77, 0x73, - 0x5f, 0x68, 0x6d, 0x61, 0x63, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x16, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x4a, 0x77, 0x73, - 0x48, 0x6d, 0x61, 0x63, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x6c, - 0x6c, 0x6f, 0x77, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, - 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x49, 0x0a, 0x22, 0x63, 0x61, 0x73, - 0x5f, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x70, - 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x1d, 0x63, 0x61, 0x73, 0x52, 0x6f, 0x62, 0x6f, 0x74, 0x41, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, - 0x50, 0x61, 0x74, 0x68, 0x12, 0x1e, 0x0a, 0x04, 0x6f, 0x69, 0x64, 0x63, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x2e, 0x4f, 0x49, 0x44, 0x43, 0x52, 0x04, - 0x6f, 0x69, 0x64, 0x63, 0x1a, 0x90, 0x01, 0x0a, 0x04, 0x4f, 0x49, 0x44, 0x43, 0x12, 0x16, 0x0a, - 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, - 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x49, 0x64, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x65, 0x63, - 0x72, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x2e, 0x0a, 0x13, 0x72, 0x65, 0x64, 0x69, 0x72, - 0x65, 0x63, 0x74, 0x5f, 0x75, 0x72, 0x6c, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x72, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x55, 0x72, - 0x6c, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2d, - 0x64, 0x65, 0x76, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2f, 0x61, 0x70, - 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x3b, 0x63, 0x6f, 0x6e, - 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x0a, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x73, 0x44, 0x69, 0x72, 0x12, 0x48, 0x0a, 0x15, 0x72, + 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x72, 0x5f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x5f, 0x69, + 0x6e, 0x64, 0x65, 0x78, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x52, 0x65, 0x66, + 0x65, 0x72, 0x72, 0x65, 0x72, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x49, 0x6e, 0x64, 0x65, 0x78, + 0x52, 0x13, 0x72, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x72, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, + 0x49, 0x6e, 0x64, 0x65, 0x78, 0x1a, 0x86, 0x01, 0x0a, 0x0d, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, + 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x12, 0x37, 0x0a, 0x06, 0x73, 0x65, 0x6e, 0x74, 0x72, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, + 0x72, 0x61, 0x70, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, + 0x79, 0x2e, 0x53, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x74, 0x72, 0x79, + 0x1a, 0x3c, 0x0a, 0x06, 0x53, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x64, 0x73, + 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x64, 0x73, 0x6e, 0x12, 0x20, 0x0a, 0x0b, + 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x1a, 0x76, + 0x0a, 0x09, 0x43, 0x41, 0x53, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x2a, 0x0a, 0x04, 0x67, + 0x72, 0x70, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x53, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x2e, 0x47, 0x52, 0x50, 0x43, 0x42, 0x08, 0xfa, 0x42, 0x05, 0x8a, 0x01, 0x02, 0x10, + 0x01, 0x52, 0x04, 0x67, 0x72, 0x70, 0x63, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x65, 0x63, + 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x65, 0x63, + 0x75, 0x72, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x5f, + 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x6f, 0x77, 0x6e, 0x6c, + 0x6f, 0x61, 0x64, 0x55, 0x72, 0x6c, 0x22, 0x52, 0x0a, 0x13, 0x52, 0x65, 0x66, 0x65, 0x72, 0x72, + 0x65, 0x72, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x18, 0x0a, + 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, + 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x6c, 0x6c, 0x6f, 0x77, + 0x65, 0x64, 0x5f, 0x6f, 0x72, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x61, + 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x4f, 0x72, 0x67, 0x73, 0x22, 0xf7, 0x03, 0x0a, 0x06, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x04, 0x68, 0x74, 0x74, 0x70, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x48, 0x54, 0x54, + 0x50, 0x52, 0x04, 0x68, 0x74, 0x74, 0x70, 0x12, 0x20, 0x0a, 0x04, 0x67, 0x72, 0x70, 0x63, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x47, + 0x52, 0x50, 0x43, 0x52, 0x04, 0x67, 0x72, 0x70, 0x63, 0x12, 0x2f, 0x0a, 0x0c, 0x68, 0x74, 0x74, + 0x70, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0c, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x48, 0x54, 0x54, 0x50, 0x52, 0x0b, 0x68, + 0x74, 0x74, 0x70, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x1a, 0x8c, 0x01, 0x0a, 0x04, 0x48, + 0x54, 0x54, 0x50, 0x12, 0x18, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x12, 0x0a, + 0x04, 0x61, 0x64, 0x64, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x61, 0x64, 0x64, + 0x72, 0x12, 0x21, 0x0a, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x75, 0x72, + 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, + 0x6c, 0x55, 0x72, 0x6c, 0x12, 0x33, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x1a, 0x48, 0x0a, 0x03, 0x54, 0x4c, 0x53, + 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, + 0x74, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x5f, 0x6b, 0x65, + 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, + 0x4b, 0x65, 0x79, 0x1a, 0x9e, 0x01, 0x0a, 0x04, 0x47, 0x52, 0x50, 0x43, 0x12, 0x18, 0x0a, 0x07, + 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, + 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x1b, 0x0a, 0x04, 0x61, 0x64, 0x64, 0x72, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x04, 0x61, + 0x64, 0x64, 0x72, 0x12, 0x33, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x2a, 0x0a, 0x0a, 0x74, 0x6c, 0x73, 0x5f, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, 0x4c, 0x53, 0x52, 0x09, 0x74, 0x6c, 0x73, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x22, 0x6e, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12, 0x2a, 0x0a, 0x08, + 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, + 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x08, + 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x1a, 0x3a, 0x0a, 0x08, 0x44, 0x61, 0x74, 0x61, + 0x62, 0x61, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x22, 0xde, 0x02, 0x0a, 0x04, 0x41, 0x75, 0x74, 0x68, 0x12, 0x39, 0x0a, + 0x19, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x6a, 0x77, 0x73, 0x5f, 0x68, + 0x6d, 0x61, 0x63, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x16, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x4a, 0x77, 0x73, 0x48, 0x6d, + 0x61, 0x63, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x6c, 0x6c, 0x6f, + 0x77, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x61, 0x6c, + 0x6c, 0x6f, 0x77, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x49, 0x0a, 0x22, 0x63, 0x61, 0x73, 0x5f, 0x72, + 0x6f, 0x62, 0x6f, 0x74, 0x5f, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x70, 0x72, 0x69, + 0x76, 0x61, 0x74, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x1d, 0x63, 0x61, 0x73, 0x52, 0x6f, 0x62, 0x6f, 0x74, 0x41, 0x63, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x50, 0x61, + 0x74, 0x68, 0x12, 0x1e, 0x0a, 0x04, 0x6f, 0x69, 0x64, 0x63, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0a, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x2e, 0x4f, 0x49, 0x44, 0x43, 0x52, 0x04, 0x6f, 0x69, + 0x64, 0x63, 0x1a, 0x90, 0x01, 0x0a, 0x04, 0x4f, 0x49, 0x44, 0x43, 0x12, 0x16, 0x0a, 0x06, 0x64, + 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, + 0x61, 0x69, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x64, + 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65, + 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, + 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x2e, 0x0a, 0x13, 0x72, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, + 0x74, 0x5f, 0x75, 0x72, 0x6c, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x11, 0x72, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x55, 0x72, 0x6c, 0x53, + 0x63, 0x68, 0x65, 0x6d, 0x65, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2d, 0x64, 0x65, + 0x76, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2f, 0x61, 0x70, 0x70, 0x2f, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x3b, 0x63, 0x6f, 0x6e, 0x66, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -941,45 +1021,47 @@ func file_conf_proto_rawDescGZIP() []byte { return file_conf_proto_rawDescData } -var file_conf_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_conf_proto_msgTypes = make([]protoimpl.MessageInfo, 13) var file_conf_proto_goTypes = []interface{}{ (*Bootstrap)(nil), // 0: Bootstrap - (*Server)(nil), // 1: Server - (*Data)(nil), // 2: Data - (*Auth)(nil), // 3: Auth - (*Bootstrap_Observability)(nil), // 4: Bootstrap.Observability - (*Bootstrap_CASServer)(nil), // 5: Bootstrap.CASServer - (*Bootstrap_Observability_Sentry)(nil), // 6: Bootstrap.Observability.Sentry - (*Server_HTTP)(nil), // 7: Server.HTTP - (*Server_TLS)(nil), // 8: Server.TLS - (*Server_GRPC)(nil), // 9: Server.GRPC - (*Data_Database)(nil), // 10: Data.Database - (*Auth_OIDC)(nil), // 11: Auth.OIDC - (*v1.Credentials)(nil), // 12: credentials.v1.Credentials - (*durationpb.Duration)(nil), // 13: google.protobuf.Duration + (*ReferrerSharedIndex)(nil), // 1: ReferrerSharedIndex + (*Server)(nil), // 2: Server + (*Data)(nil), // 3: Data + (*Auth)(nil), // 4: Auth + (*Bootstrap_Observability)(nil), // 5: Bootstrap.Observability + (*Bootstrap_CASServer)(nil), // 6: Bootstrap.CASServer + (*Bootstrap_Observability_Sentry)(nil), // 7: Bootstrap.Observability.Sentry + (*Server_HTTP)(nil), // 8: Server.HTTP + (*Server_TLS)(nil), // 9: Server.TLS + (*Server_GRPC)(nil), // 10: Server.GRPC + (*Data_Database)(nil), // 11: Data.Database + (*Auth_OIDC)(nil), // 12: Auth.OIDC + (*v1.Credentials)(nil), // 13: credentials.v1.Credentials + (*durationpb.Duration)(nil), // 14: google.protobuf.Duration } var file_conf_proto_depIdxs = []int32{ - 1, // 0: Bootstrap.server:type_name -> Server - 2, // 1: Bootstrap.data:type_name -> Data - 3, // 2: Bootstrap.auth:type_name -> Auth - 4, // 3: Bootstrap.observability:type_name -> Bootstrap.Observability - 12, // 4: Bootstrap.credentials_service:type_name -> credentials.v1.Credentials - 5, // 5: Bootstrap.cas_server:type_name -> Bootstrap.CASServer - 7, // 6: Server.http:type_name -> Server.HTTP - 9, // 7: Server.grpc:type_name -> Server.GRPC - 7, // 8: Server.http_metrics:type_name -> Server.HTTP - 10, // 9: Data.database:type_name -> Data.Database - 11, // 10: Auth.oidc:type_name -> Auth.OIDC - 6, // 11: Bootstrap.Observability.sentry:type_name -> Bootstrap.Observability.Sentry - 9, // 12: Bootstrap.CASServer.grpc:type_name -> Server.GRPC - 13, // 13: Server.HTTP.timeout:type_name -> google.protobuf.Duration - 13, // 14: Server.GRPC.timeout:type_name -> google.protobuf.Duration - 8, // 15: Server.GRPC.tls_config:type_name -> Server.TLS - 16, // [16:16] is the sub-list for method output_type - 16, // [16:16] is the sub-list for method input_type - 16, // [16:16] is the sub-list for extension type_name - 16, // [16:16] is the sub-list for extension extendee - 0, // [0:16] is the sub-list for field type_name + 2, // 0: Bootstrap.server:type_name -> Server + 3, // 1: Bootstrap.data:type_name -> Data + 4, // 2: Bootstrap.auth:type_name -> Auth + 5, // 3: Bootstrap.observability:type_name -> Bootstrap.Observability + 13, // 4: Bootstrap.credentials_service:type_name -> credentials.v1.Credentials + 6, // 5: Bootstrap.cas_server:type_name -> Bootstrap.CASServer + 1, // 6: Bootstrap.referrer_shared_index:type_name -> ReferrerSharedIndex + 8, // 7: Server.http:type_name -> Server.HTTP + 10, // 8: Server.grpc:type_name -> Server.GRPC + 8, // 9: Server.http_metrics:type_name -> Server.HTTP + 11, // 10: Data.database:type_name -> Data.Database + 12, // 11: Auth.oidc:type_name -> Auth.OIDC + 7, // 12: Bootstrap.Observability.sentry:type_name -> Bootstrap.Observability.Sentry + 10, // 13: Bootstrap.CASServer.grpc:type_name -> Server.GRPC + 14, // 14: Server.HTTP.timeout:type_name -> google.protobuf.Duration + 14, // 15: Server.GRPC.timeout:type_name -> google.protobuf.Duration + 9, // 16: Server.GRPC.tls_config:type_name -> Server.TLS + 17, // [17:17] is the sub-list for method output_type + 17, // [17:17] is the sub-list for method input_type + 17, // [17:17] is the sub-list for extension type_name + 17, // [17:17] is the sub-list for extension extendee + 0, // [0:17] is the sub-list for field type_name } func init() { file_conf_proto_init() } @@ -1001,7 +1083,7 @@ func file_conf_proto_init() { } } file_conf_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Server); i { + switch v := v.(*ReferrerSharedIndex); i { case 0: return &v.state case 1: @@ -1013,7 +1095,7 @@ func file_conf_proto_init() { } } file_conf_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Data); i { + switch v := v.(*Server); i { case 0: return &v.state case 1: @@ -1025,7 +1107,7 @@ func file_conf_proto_init() { } } file_conf_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Auth); i { + switch v := v.(*Data); i { case 0: return &v.state case 1: @@ -1037,7 +1119,7 @@ func file_conf_proto_init() { } } file_conf_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Bootstrap_Observability); i { + switch v := v.(*Auth); i { case 0: return &v.state case 1: @@ -1049,7 +1131,7 @@ func file_conf_proto_init() { } } file_conf_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Bootstrap_CASServer); i { + switch v := v.(*Bootstrap_Observability); i { case 0: return &v.state case 1: @@ -1061,7 +1143,7 @@ func file_conf_proto_init() { } } file_conf_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Bootstrap_Observability_Sentry); i { + switch v := v.(*Bootstrap_CASServer); i { case 0: return &v.state case 1: @@ -1073,7 +1155,7 @@ func file_conf_proto_init() { } } file_conf_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Server_HTTP); i { + switch v := v.(*Bootstrap_Observability_Sentry); i { case 0: return &v.state case 1: @@ -1085,7 +1167,7 @@ func file_conf_proto_init() { } } file_conf_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Server_TLS); i { + switch v := v.(*Server_HTTP); i { case 0: return &v.state case 1: @@ -1097,7 +1179,7 @@ func file_conf_proto_init() { } } file_conf_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Server_GRPC); i { + switch v := v.(*Server_TLS); i { case 0: return &v.state case 1: @@ -1109,7 +1191,7 @@ func file_conf_proto_init() { } } file_conf_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Data_Database); i { + switch v := v.(*Server_GRPC); i { case 0: return &v.state case 1: @@ -1121,6 +1203,18 @@ func file_conf_proto_init() { } } file_conf_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Data_Database); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_conf_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Auth_OIDC); i { case 0: return &v.state @@ -1139,7 +1233,7 @@ func file_conf_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_conf_proto_rawDesc, NumEnums: 0, - NumMessages: 12, + NumMessages: 13, NumExtensions: 0, NumServices: 0, }, diff --git a/app/controlplane/internal/conf/conf.pb.validate.go b/app/controlplane/internal/conf/conf.pb.validate.go index f5758a1e0..5df988d93 100644 --- a/app/controlplane/internal/conf/conf.pb.validate.go +++ b/app/controlplane/internal/conf/conf.pb.validate.go @@ -233,6 +233,35 @@ func (m *Bootstrap) validate(all bool) error { // no validation rules for PluginsDir + if all { + switch v := interface{}(m.GetReferrerSharedIndex()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "ReferrerSharedIndex", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "ReferrerSharedIndex", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetReferrerSharedIndex()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return BootstrapValidationError{ + field: "ReferrerSharedIndex", + reason: "embedded message failed validation", + cause: err, + } + } + } + if len(errors) > 0 { return BootstrapMultiError(errors) } @@ -310,6 +339,110 @@ var _ interface { ErrorName() string } = BootstrapValidationError{} +// Validate checks the field values on ReferrerSharedIndex with the rules +// defined 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 *ReferrerSharedIndex) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ReferrerSharedIndex 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 +// ReferrerSharedIndexMultiError, or nil if none found. +func (m *ReferrerSharedIndex) ValidateAll() error { + return m.validate(true) +} + +func (m *ReferrerSharedIndex) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Enabled + + if len(errors) > 0 { + return ReferrerSharedIndexMultiError(errors) + } + + return nil +} + +// ReferrerSharedIndexMultiError is an error wrapping multiple validation +// errors returned by ReferrerSharedIndex.ValidateAll() if the designated +// constraints aren't met. +type ReferrerSharedIndexMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ReferrerSharedIndexMultiError) 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 ReferrerSharedIndexMultiError) AllErrors() []error { return m } + +// ReferrerSharedIndexValidationError is the validation error returned by +// ReferrerSharedIndex.Validate if the designated constraints aren't met. +type ReferrerSharedIndexValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ReferrerSharedIndexValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ReferrerSharedIndexValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ReferrerSharedIndexValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ReferrerSharedIndexValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ReferrerSharedIndexValidationError) ErrorName() string { + return "ReferrerSharedIndexValidationError" +} + +// Error satisfies the builtin error interface +func (e ReferrerSharedIndexValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sReferrerSharedIndex.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ReferrerSharedIndexValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ReferrerSharedIndexValidationError{} + // Validate checks the field values on Server with the rules defined 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. diff --git a/app/controlplane/internal/conf/conf.proto b/app/controlplane/internal/conf/conf.proto index fadab5149..ffaad1ccb 100644 --- a/app/controlplane/internal/conf/conf.proto +++ b/app/controlplane/internal/conf/conf.proto @@ -32,6 +32,8 @@ message Bootstrap { // Plugins directory // NOTE: plugins have the form of chainloop-plugin- string plugins_dir = 7; + // Configuration about the shared referrer index + ReferrerSharedIndex referrer_shared_index = 8; message Observability { Sentry sentry = 1; @@ -53,6 +55,17 @@ message Bootstrap { } } +// Configuration used to enable a shared index API endpoint that can be used to discover metadata referrers +// To populate the shared index you need to enable the feature and configure the allowed orgs +// The reason to have an org allowList is to avoid leaking metadata from other organizations and set the stage for a trusted publisher model +message ReferrerSharedIndex { + // If the shared, public index feature is enabled + bool enabled = 1; + // list of organizations uuids that are allowed to appear in the shared referrer index + // think of it as a list of trusted publishers + repeated string allowed_orgs = 2; +} + message Server { message HTTP { string network = 1; diff --git a/app/controlplane/internal/conf/conf_test.go b/app/controlplane/internal/conf/conf_test.go new file mode 100644 index 000000000..878d57788 --- /dev/null +++ b/app/controlplane/internal/conf/conf_test.go @@ -0,0 +1,69 @@ +// +// Copyright 2023 The Chainloop Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package conf + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestValidateOrgs(t *testing.T) { + testCases := []struct { + name string + index *ReferrerSharedIndex + wantErrMsg string + }{ + { + name: "nil configuration", + index: nil, + }, + { + name: "enabled but without orgs", + index: &ReferrerSharedIndex{ + Enabled: true, + }, + wantErrMsg: "index is enabled, but no orgs are allowed", + }, + { + name: "enabled with invalid orgs", + index: &ReferrerSharedIndex{ + Enabled: true, + AllowedOrgs: []string{"invalid"}, + }, + wantErrMsg: "invalid org id: invalid", + }, + { + name: "enabled with valid orgs", + index: &ReferrerSharedIndex{ + Enabled: true, + AllowedOrgs: []string{"00000000-0000-0000-0000-000000000000"}, + }, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + err := tc.index.ValidateOrgs() + if tc.wantErrMsg != "" { + assert.EqualError(t, err, tc.wantErrMsg) + } else { + assert.NoError(t, err) + } + }) + } + +} From d3f4feb576729cc77de655f786038505043fa993 Mon Sep 17 00:00:00 2001 From: Miguel Martinez Trivino Date: Thu, 16 Nov 2023 15:10:41 +0100 Subject: [PATCH 2/7] configure index Signed-off-by: Miguel Martinez Trivino --- app/cli/cmd/referrer_discover.go | 13 +- app/cli/internal/action/referrer_discover.go | 23 +- .../api/controlplane/v1/referrer.pb.go | 313 +++++++++++---- .../controlplane/v1/referrer.pb.validate.go | 375 +++++++++++++++--- .../api/controlplane/v1/referrer.proto | 20 +- .../api/controlplane/v1/referrer_grpc.pb.go | 71 +++- .../api/controlplane/v1/referrer_http.pb.go | 25 +- .../gen/frontend/controlplane/v1/referrer.ts | 267 +++++++++++-- app/controlplane/configs/config.devel.yaml | 4 +- app/controlplane/internal/biz/referrer.go | 1 + app/controlplane/internal/conf/conf.go | 2 +- app/controlplane/internal/conf/conf_test.go | 8 +- app/controlplane/internal/data/referrer.go | 14 +- app/controlplane/internal/server/grpc.go | 2 +- app/controlplane/internal/service/referrer.go | 15 +- 15 files changed, 931 insertions(+), 222 deletions(-) diff --git a/app/cli/cmd/referrer_discover.go b/app/cli/cmd/referrer_discover.go index b9a8cf2a6..9607f7b3d 100644 --- a/app/cli/cmd/referrer_discover.go +++ b/app/cli/cmd/referrer_discover.go @@ -24,12 +24,21 @@ import ( func newReferrerDiscoverCmd() *cobra.Command { var digest, kind string + var fromPublicIndex bool cmd := &cobra.Command{ Use: "discover", Short: "(Preview) inspect pieces of evidence or artifacts stored through Chainloop", RunE: func(cmd *cobra.Command, args []string) error { - res, err := action.NewReferrerDiscover(actionOpts).Run(context.Background(), digest, kind) + var res *action.ReferrerItem + var err error + + if fromPublicIndex { + res, err = action.NewReferrerDiscoverPublicIndex(actionOpts).Run(context.Background(), digest, kind) + } else { + res, err = action.NewReferrerDiscoverPrivate(actionOpts).Run(context.Background(), digest, kind) + } + if err != nil { return err } @@ -43,6 +52,8 @@ func newReferrerDiscoverCmd() *cobra.Command { err := cmd.MarkFlagRequired("digest") cobra.CheckErr(err) cmd.Flags().StringVarP(&kind, "kind", "k", "", "optional kind of the referrer, used to disambiguate between multiple referrers with the same digest") + cobra.CheckErr(err) + cmd.Flags().BoolVar(&fromPublicIndex, "public", false, "discover from public shared index instead of your organizations'") return cmd } diff --git a/app/cli/internal/action/referrer_discover.go b/app/cli/internal/action/referrer_discover.go index 22d722f98..b776b06e9 100644 --- a/app/cli/internal/action/referrer_discover.go +++ b/app/cli/internal/action/referrer_discover.go @@ -25,6 +25,9 @@ import ( type ReferrerDiscover struct { cfg *ActionsOpts } +type ReferrerDiscoverPublic struct { + cfg *ActionsOpts +} type ReferrerItem struct { Digest string `json:"digest"` @@ -35,13 +38,29 @@ type ReferrerItem struct { References []*ReferrerItem `json:"references"` } -func NewReferrerDiscover(cfg *ActionsOpts) *ReferrerDiscover { +func NewReferrerDiscoverPrivate(cfg *ActionsOpts) *ReferrerDiscover { return &ReferrerDiscover{cfg} } func (action *ReferrerDiscover) Run(ctx context.Context, digest, kind string) (*ReferrerItem, error) { client := pb.NewReferrerServiceClient(action.cfg.CPConnection) - resp, err := client.Discover(ctx, &pb.ReferrerServiceDiscoverRequest{ + resp, err := client.DiscoverPrivate(ctx, &pb.ReferrerServiceDiscoverPrivateRequest{ + Digest: digest, Kind: kind, + }) + if err != nil { + return nil, err + } + + return pbReferrerItemToAction(resp.Result), nil +} + +func NewReferrerDiscoverPublicIndex(cfg *ActionsOpts) *ReferrerDiscoverPublic { + return &ReferrerDiscoverPublic{cfg} +} + +func (action *ReferrerDiscoverPublic) Run(ctx context.Context, digest, kind string) (*ReferrerItem, error) { + client := pb.NewReferrerServiceClient(action.cfg.CPConnection) + resp, err := client.DiscoverPublicShared(ctx, &pb.DiscoverPublicSharedRequest{ Digest: digest, Kind: kind, }) if err != nil { diff --git a/app/controlplane/api/controlplane/v1/referrer.pb.go b/app/controlplane/api/controlplane/v1/referrer.pb.go index 0e5faea84..0e0ccd8b7 100644 --- a/app/controlplane/api/controlplane/v1/referrer.pb.go +++ b/app/controlplane/api/controlplane/v1/referrer.pb.go @@ -38,7 +38,7 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type ReferrerServiceDiscoverRequest struct { +type ReferrerServiceDiscoverPrivateRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -49,8 +49,8 @@ type ReferrerServiceDiscoverRequest struct { Kind string `protobuf:"bytes,2,opt,name=kind,proto3" json:"kind,omitempty"` } -func (x *ReferrerServiceDiscoverRequest) Reset() { - *x = ReferrerServiceDiscoverRequest{} +func (x *ReferrerServiceDiscoverPrivateRequest) Reset() { + *x = ReferrerServiceDiscoverPrivateRequest{} if protoimpl.UnsafeEnabled { mi := &file_controlplane_v1_referrer_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -58,13 +58,13 @@ func (x *ReferrerServiceDiscoverRequest) Reset() { } } -func (x *ReferrerServiceDiscoverRequest) String() string { +func (x *ReferrerServiceDiscoverPrivateRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ReferrerServiceDiscoverRequest) ProtoMessage() {} +func (*ReferrerServiceDiscoverPrivateRequest) ProtoMessage() {} -func (x *ReferrerServiceDiscoverRequest) ProtoReflect() protoreflect.Message { +func (x *ReferrerServiceDiscoverPrivateRequest) ProtoReflect() protoreflect.Message { mi := &file_controlplane_v1_referrer_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -76,35 +76,38 @@ func (x *ReferrerServiceDiscoverRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ReferrerServiceDiscoverRequest.ProtoReflect.Descriptor instead. -func (*ReferrerServiceDiscoverRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use ReferrerServiceDiscoverPrivateRequest.ProtoReflect.Descriptor instead. +func (*ReferrerServiceDiscoverPrivateRequest) Descriptor() ([]byte, []int) { return file_controlplane_v1_referrer_proto_rawDescGZIP(), []int{0} } -func (x *ReferrerServiceDiscoverRequest) GetDigest() string { +func (x *ReferrerServiceDiscoverPrivateRequest) GetDigest() string { if x != nil { return x.Digest } return "" } -func (x *ReferrerServiceDiscoverRequest) GetKind() string { +func (x *ReferrerServiceDiscoverPrivateRequest) GetKind() string { if x != nil { return x.Kind } return "" } -type ReferrerServiceDiscoverResponse struct { +type DiscoverPublicSharedRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Result *ReferrerItem `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` + Digest string `protobuf:"bytes,1,opt,name=digest,proto3" json:"digest,omitempty"` + // Optional kind of referrer, i.e CONTAINER_IMAGE, GIT_HEAD, ... + // Used to filter and resolve ambiguities + Kind string `protobuf:"bytes,2,opt,name=kind,proto3" json:"kind,omitempty"` } -func (x *ReferrerServiceDiscoverResponse) Reset() { - *x = ReferrerServiceDiscoverResponse{} +func (x *DiscoverPublicSharedRequest) Reset() { + *x = DiscoverPublicSharedRequest{} if protoimpl.UnsafeEnabled { mi := &file_controlplane_v1_referrer_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -112,13 +115,13 @@ func (x *ReferrerServiceDiscoverResponse) Reset() { } } -func (x *ReferrerServiceDiscoverResponse) String() string { +func (x *DiscoverPublicSharedRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ReferrerServiceDiscoverResponse) ProtoMessage() {} +func (*DiscoverPublicSharedRequest) ProtoMessage() {} -func (x *ReferrerServiceDiscoverResponse) ProtoReflect() protoreflect.Message { +func (x *DiscoverPublicSharedRequest) ProtoReflect() protoreflect.Message { mi := &file_controlplane_v1_referrer_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -130,12 +133,113 @@ func (x *ReferrerServiceDiscoverResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ReferrerServiceDiscoverResponse.ProtoReflect.Descriptor instead. -func (*ReferrerServiceDiscoverResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use DiscoverPublicSharedRequest.ProtoReflect.Descriptor instead. +func (*DiscoverPublicSharedRequest) Descriptor() ([]byte, []int) { return file_controlplane_v1_referrer_proto_rawDescGZIP(), []int{1} } -func (x *ReferrerServiceDiscoverResponse) GetResult() *ReferrerItem { +func (x *DiscoverPublicSharedRequest) GetDigest() string { + if x != nil { + return x.Digest + } + return "" +} + +func (x *DiscoverPublicSharedRequest) GetKind() string { + if x != nil { + return x.Kind + } + return "" +} + +type DiscoverPublicSharedResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Result *ReferrerItem `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` +} + +func (x *DiscoverPublicSharedResponse) Reset() { + *x = DiscoverPublicSharedResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_controlplane_v1_referrer_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DiscoverPublicSharedResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DiscoverPublicSharedResponse) ProtoMessage() {} + +func (x *DiscoverPublicSharedResponse) ProtoReflect() protoreflect.Message { + mi := &file_controlplane_v1_referrer_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DiscoverPublicSharedResponse.ProtoReflect.Descriptor instead. +func (*DiscoverPublicSharedResponse) Descriptor() ([]byte, []int) { + return file_controlplane_v1_referrer_proto_rawDescGZIP(), []int{2} +} + +func (x *DiscoverPublicSharedResponse) GetResult() *ReferrerItem { + if x != nil { + return x.Result + } + return nil +} + +type ReferrerServiceDiscoverPrivateResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Result *ReferrerItem `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` +} + +func (x *ReferrerServiceDiscoverPrivateResponse) Reset() { + *x = ReferrerServiceDiscoverPrivateResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_controlplane_v1_referrer_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReferrerServiceDiscoverPrivateResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReferrerServiceDiscoverPrivateResponse) ProtoMessage() {} + +func (x *ReferrerServiceDiscoverPrivateResponse) ProtoReflect() protoreflect.Message { + mi := &file_controlplane_v1_referrer_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReferrerServiceDiscoverPrivateResponse.ProtoReflect.Descriptor instead. +func (*ReferrerServiceDiscoverPrivateResponse) Descriptor() ([]byte, []int) { + return file_controlplane_v1_referrer_proto_rawDescGZIP(), []int{3} +} + +func (x *ReferrerServiceDiscoverPrivateResponse) GetResult() *ReferrerItem { if x != nil { return x.Result } @@ -162,7 +266,7 @@ type ReferrerItem struct { func (x *ReferrerItem) Reset() { *x = ReferrerItem{} if protoimpl.UnsafeEnabled { - mi := &file_controlplane_v1_referrer_proto_msgTypes[2] + mi := &file_controlplane_v1_referrer_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -175,7 +279,7 @@ func (x *ReferrerItem) String() string { func (*ReferrerItem) ProtoMessage() {} func (x *ReferrerItem) ProtoReflect() protoreflect.Message { - mi := &file_controlplane_v1_referrer_proto_msgTypes[2] + mi := &file_controlplane_v1_referrer_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -188,7 +292,7 @@ func (x *ReferrerItem) ProtoReflect() protoreflect.Message { // Deprecated: Use ReferrerItem.ProtoReflect.Descriptor instead. func (*ReferrerItem) Descriptor() ([]byte, []int) { - return file_controlplane_v1_referrer_proto_rawDescGZIP(), []int{2} + return file_controlplane_v1_referrer_proto_rawDescGZIP(), []int{4} } func (x *ReferrerItem) GetDigest() string { @@ -244,49 +348,69 @@ var file_controlplane_v1_referrer_proto_rawDesc = []byte{ 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x55, 0x0a, 0x1e, 0x52, 0x65, 0x66, + 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5c, 0x0a, 0x25, 0x52, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x69, 0x73, 0x63, - 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x06, 0x64, - 0x69, 0x67, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, - 0x72, 0x02, 0x10, 0x01, 0x52, 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, - 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, - 0x22, 0x58, 0x0a, 0x1f, 0x52, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, - 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x72, 0x49, 0x74, - 0x65, 0x6d, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0xf0, 0x01, 0x0a, 0x0c, 0x52, - 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x72, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x16, 0x0a, 0x06, 0x64, - 0x69, 0x67, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x69, 0x67, + 0x6f, 0x76, 0x65, 0x72, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x64, 0x6f, 0x77, 0x6e, 0x6c, - 0x6f, 0x61, 0x64, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x64, - 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, - 0x75, 0x62, 0x6c, 0x69, 0x63, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x70, 0x75, 0x62, - 0x6c, 0x69, 0x63, 0x12, 0x3d, 0x0a, 0x0a, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, - 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x72, - 0x65, 0x72, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x0a, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, - 0x65, 0x73, 0x12, 0x39, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x32, 0x9d, 0x01, - 0x0a, 0x0f, 0x52, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x89, 0x01, 0x0a, 0x08, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x12, 0x2f, + 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x22, 0x52, 0x0a, 0x1b, 0x44, 0x69, 0x73, 0x63, 0x6f, + 0x76, 0x65, 0x72, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, + 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x22, 0x55, 0x0a, 0x1c, 0x44, + 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x53, 0x68, 0x61, + 0x72, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x06, 0x72, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x6f, + 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, + 0x66, 0x65, 0x72, 0x72, 0x65, 0x72, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, + 0x6c, 0x74, 0x22, 0x5f, 0x0a, 0x26, 0x52, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x72, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x50, 0x72, 0x69, + 0x76, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x06, + 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, + 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, + 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x72, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x06, 0x72, 0x65, 0x73, + 0x75, 0x6c, 0x74, 0x22, 0xf0, 0x01, 0x0a, 0x0c, 0x52, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x72, + 0x49, 0x74, 0x65, 0x6d, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, + 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, + 0x12, 0x22, 0x0a, 0x0c, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x61, 0x62, 0x6c, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, + 0x61, 0x62, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x12, 0x3d, 0x0a, 0x0a, + 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, + 0x76, 0x31, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x72, 0x49, 0x74, 0x65, 0x6d, 0x52, + 0x0a, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x39, 0x0a, 0x0a, 0x63, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x63, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x32, 0xa8, 0x02, 0x0a, 0x0f, 0x52, 0x65, 0x66, 0x65, 0x72, + 0x72, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x82, 0x01, 0x0a, 0x0f, 0x44, + 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x12, 0x36, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x30, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, - 0x31, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x12, 0x12, 0x2f, 0x64, 0x69, 0x73, 0x63, - 0x6f, 0x76, 0x65, 0x72, 0x2f, 0x7b, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x7d, 0x42, 0x4c, 0x5a, - 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x68, 0x61, 0x69, - 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, - 0x6f, 0x6f, 0x70, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x70, - 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, + 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, + 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, + 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x8f, 0x01, 0x0a, 0x14, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x50, 0x75, 0x62, 0x6c, + 0x69, 0x63, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x12, 0x2c, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x63, 0x6f, + 0x76, 0x65, 0x72, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, + 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, + 0x72, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x53, 0x68, 0x61, 0x72, 0x65, 0x64, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x12, 0x12, 0x2f, + 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x2f, 0x7b, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, + 0x7d, 0x42, 0x4c, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x63, 0x68, 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2d, 0x64, 0x65, 0x76, 0x2f, 0x63, 0x68, + 0x61, 0x69, 0x6e, 0x6c, 0x6f, 0x6f, 0x70, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x74, + 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x6e, + 0x74, 0x72, 0x6f, 0x6c, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x31, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -301,24 +425,29 @@ func file_controlplane_v1_referrer_proto_rawDescGZIP() []byte { return file_controlplane_v1_referrer_proto_rawDescData } -var file_controlplane_v1_referrer_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_controlplane_v1_referrer_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_controlplane_v1_referrer_proto_goTypes = []interface{}{ - (*ReferrerServiceDiscoverRequest)(nil), // 0: controlplane.v1.ReferrerServiceDiscoverRequest - (*ReferrerServiceDiscoverResponse)(nil), // 1: controlplane.v1.ReferrerServiceDiscoverResponse - (*ReferrerItem)(nil), // 2: controlplane.v1.ReferrerItem - (*timestamppb.Timestamp)(nil), // 3: google.protobuf.Timestamp + (*ReferrerServiceDiscoverPrivateRequest)(nil), // 0: controlplane.v1.ReferrerServiceDiscoverPrivateRequest + (*DiscoverPublicSharedRequest)(nil), // 1: controlplane.v1.DiscoverPublicSharedRequest + (*DiscoverPublicSharedResponse)(nil), // 2: controlplane.v1.DiscoverPublicSharedResponse + (*ReferrerServiceDiscoverPrivateResponse)(nil), // 3: controlplane.v1.ReferrerServiceDiscoverPrivateResponse + (*ReferrerItem)(nil), // 4: controlplane.v1.ReferrerItem + (*timestamppb.Timestamp)(nil), // 5: google.protobuf.Timestamp } var file_controlplane_v1_referrer_proto_depIdxs = []int32{ - 2, // 0: controlplane.v1.ReferrerServiceDiscoverResponse.result:type_name -> controlplane.v1.ReferrerItem - 2, // 1: controlplane.v1.ReferrerItem.references:type_name -> controlplane.v1.ReferrerItem - 3, // 2: controlplane.v1.ReferrerItem.created_at:type_name -> google.protobuf.Timestamp - 0, // 3: controlplane.v1.ReferrerService.Discover:input_type -> controlplane.v1.ReferrerServiceDiscoverRequest - 1, // 4: controlplane.v1.ReferrerService.Discover:output_type -> controlplane.v1.ReferrerServiceDiscoverResponse - 4, // [4:5] is the sub-list for method output_type - 3, // [3:4] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 4, // 0: controlplane.v1.DiscoverPublicSharedResponse.result:type_name -> controlplane.v1.ReferrerItem + 4, // 1: controlplane.v1.ReferrerServiceDiscoverPrivateResponse.result:type_name -> controlplane.v1.ReferrerItem + 4, // 2: controlplane.v1.ReferrerItem.references:type_name -> controlplane.v1.ReferrerItem + 5, // 3: controlplane.v1.ReferrerItem.created_at:type_name -> google.protobuf.Timestamp + 0, // 4: controlplane.v1.ReferrerService.DiscoverPrivate:input_type -> controlplane.v1.ReferrerServiceDiscoverPrivateRequest + 1, // 5: controlplane.v1.ReferrerService.DiscoverPublicShared:input_type -> controlplane.v1.DiscoverPublicSharedRequest + 3, // 6: controlplane.v1.ReferrerService.DiscoverPrivate:output_type -> controlplane.v1.ReferrerServiceDiscoverPrivateResponse + 2, // 7: controlplane.v1.ReferrerService.DiscoverPublicShared:output_type -> controlplane.v1.DiscoverPublicSharedResponse + 6, // [6:8] is the sub-list for method output_type + 4, // [4:6] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_controlplane_v1_referrer_proto_init() } @@ -328,7 +457,7 @@ func file_controlplane_v1_referrer_proto_init() { } if !protoimpl.UnsafeEnabled { file_controlplane_v1_referrer_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReferrerServiceDiscoverRequest); i { + switch v := v.(*ReferrerServiceDiscoverPrivateRequest); i { case 0: return &v.state case 1: @@ -340,7 +469,7 @@ func file_controlplane_v1_referrer_proto_init() { } } file_controlplane_v1_referrer_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ReferrerServiceDiscoverResponse); i { + switch v := v.(*DiscoverPublicSharedRequest); i { case 0: return &v.state case 1: @@ -352,6 +481,30 @@ func file_controlplane_v1_referrer_proto_init() { } } file_controlplane_v1_referrer_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DiscoverPublicSharedResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controlplane_v1_referrer_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReferrerServiceDiscoverPrivateResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_controlplane_v1_referrer_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ReferrerItem); i { case 0: return &v.state @@ -370,7 +523,7 @@ func file_controlplane_v1_referrer_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_controlplane_v1_referrer_proto_rawDesc, NumEnums: 0, - NumMessages: 3, + NumMessages: 5, NumExtensions: 0, NumServices: 1, }, diff --git a/app/controlplane/api/controlplane/v1/referrer.pb.validate.go b/app/controlplane/api/controlplane/v1/referrer.pb.validate.go index 230ddf543..44c508dec 100644 --- a/app/controlplane/api/controlplane/v1/referrer.pb.validate.go +++ b/app/controlplane/api/controlplane/v1/referrer.pb.validate.go @@ -35,22 +35,140 @@ var ( _ = sort.Sort ) -// Validate checks the field values on ReferrerServiceDiscoverRequest with the +// Validate checks the field values on ReferrerServiceDiscoverPrivateRequest +// with the rules defined 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 *ReferrerServiceDiscoverPrivateRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ReferrerServiceDiscoverPrivateRequest +// 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 +// ReferrerServiceDiscoverPrivateRequestMultiError, or nil if none found. +func (m *ReferrerServiceDiscoverPrivateRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ReferrerServiceDiscoverPrivateRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if utf8.RuneCountInString(m.GetDigest()) < 1 { + err := ReferrerServiceDiscoverPrivateRequestValidationError{ + field: "Digest", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + // no validation rules for Kind + + if len(errors) > 0 { + return ReferrerServiceDiscoverPrivateRequestMultiError(errors) + } + + return nil +} + +// ReferrerServiceDiscoverPrivateRequestMultiError is an error wrapping +// multiple validation errors returned by +// ReferrerServiceDiscoverPrivateRequest.ValidateAll() if the designated +// constraints aren't met. +type ReferrerServiceDiscoverPrivateRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ReferrerServiceDiscoverPrivateRequestMultiError) 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 ReferrerServiceDiscoverPrivateRequestMultiError) AllErrors() []error { return m } + +// ReferrerServiceDiscoverPrivateRequestValidationError is the validation error +// returned by ReferrerServiceDiscoverPrivateRequest.Validate if the +// designated constraints aren't met. +type ReferrerServiceDiscoverPrivateRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ReferrerServiceDiscoverPrivateRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ReferrerServiceDiscoverPrivateRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ReferrerServiceDiscoverPrivateRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ReferrerServiceDiscoverPrivateRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ReferrerServiceDiscoverPrivateRequestValidationError) ErrorName() string { + return "ReferrerServiceDiscoverPrivateRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ReferrerServiceDiscoverPrivateRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sReferrerServiceDiscoverPrivateRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ReferrerServiceDiscoverPrivateRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ReferrerServiceDiscoverPrivateRequestValidationError{} + +// Validate checks the field values on DiscoverPublicSharedRequest with the // rules defined 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 *ReferrerServiceDiscoverRequest) Validate() error { +func (m *DiscoverPublicSharedRequest) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on ReferrerServiceDiscoverRequest 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 -// ReferrerServiceDiscoverRequestMultiError, or nil if none found. -func (m *ReferrerServiceDiscoverRequest) ValidateAll() error { +// ValidateAll checks the field values on DiscoverPublicSharedRequest 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 +// DiscoverPublicSharedRequestMultiError, or nil if none found. +func (m *DiscoverPublicSharedRequest) ValidateAll() error { return m.validate(true) } -func (m *ReferrerServiceDiscoverRequest) validate(all bool) error { +func (m *DiscoverPublicSharedRequest) validate(all bool) error { if m == nil { return nil } @@ -58,7 +176,7 @@ func (m *ReferrerServiceDiscoverRequest) validate(all bool) error { var errors []error if utf8.RuneCountInString(m.GetDigest()) < 1 { - err := ReferrerServiceDiscoverRequestValidationError{ + err := DiscoverPublicSharedRequestValidationError{ field: "Digest", reason: "value length must be at least 1 runes", } @@ -71,19 +189,19 @@ func (m *ReferrerServiceDiscoverRequest) validate(all bool) error { // no validation rules for Kind if len(errors) > 0 { - return ReferrerServiceDiscoverRequestMultiError(errors) + return DiscoverPublicSharedRequestMultiError(errors) } return nil } -// ReferrerServiceDiscoverRequestMultiError is an error wrapping multiple -// validation errors returned by ReferrerServiceDiscoverRequest.ValidateAll() -// if the designated constraints aren't met. -type ReferrerServiceDiscoverRequestMultiError []error +// DiscoverPublicSharedRequestMultiError is an error wrapping multiple +// validation errors returned by DiscoverPublicSharedRequest.ValidateAll() if +// the designated constraints aren't met. +type DiscoverPublicSharedRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m ReferrerServiceDiscoverRequestMultiError) Error() string { +func (m DiscoverPublicSharedRequestMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) @@ -92,12 +210,12 @@ func (m ReferrerServiceDiscoverRequestMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m ReferrerServiceDiscoverRequestMultiError) AllErrors() []error { return m } +func (m DiscoverPublicSharedRequestMultiError) AllErrors() []error { return m } -// ReferrerServiceDiscoverRequestValidationError is the validation error -// returned by ReferrerServiceDiscoverRequest.Validate if the designated -// constraints aren't met. -type ReferrerServiceDiscoverRequestValidationError struct { +// DiscoverPublicSharedRequestValidationError is the validation error returned +// by DiscoverPublicSharedRequest.Validate if the designated constraints +// aren't met. +type DiscoverPublicSharedRequestValidationError struct { field string reason string cause error @@ -105,24 +223,24 @@ type ReferrerServiceDiscoverRequestValidationError struct { } // Field function returns field value. -func (e ReferrerServiceDiscoverRequestValidationError) Field() string { return e.field } +func (e DiscoverPublicSharedRequestValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e ReferrerServiceDiscoverRequestValidationError) Reason() string { return e.reason } +func (e DiscoverPublicSharedRequestValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e ReferrerServiceDiscoverRequestValidationError) Cause() error { return e.cause } +func (e DiscoverPublicSharedRequestValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e ReferrerServiceDiscoverRequestValidationError) Key() bool { return e.key } +func (e DiscoverPublicSharedRequestValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e ReferrerServiceDiscoverRequestValidationError) ErrorName() string { - return "ReferrerServiceDiscoverRequestValidationError" +func (e DiscoverPublicSharedRequestValidationError) ErrorName() string { + return "DiscoverPublicSharedRequestValidationError" } // Error satisfies the builtin error interface -func (e ReferrerServiceDiscoverRequestValidationError) Error() string { +func (e DiscoverPublicSharedRequestValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -134,14 +252,14 @@ func (e ReferrerServiceDiscoverRequestValidationError) Error() string { } return fmt.Sprintf( - "invalid %sReferrerServiceDiscoverRequest.%s: %s%s", + "invalid %sDiscoverPublicSharedRequest.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = ReferrerServiceDiscoverRequestValidationError{} +var _ error = DiscoverPublicSharedRequestValidationError{} var _ interface { Field() string @@ -149,24 +267,24 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = ReferrerServiceDiscoverRequestValidationError{} +} = DiscoverPublicSharedRequestValidationError{} -// Validate checks the field values on ReferrerServiceDiscoverResponse with the +// Validate checks the field values on DiscoverPublicSharedResponse with the // rules defined 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 *ReferrerServiceDiscoverResponse) Validate() error { +func (m *DiscoverPublicSharedResponse) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on ReferrerServiceDiscoverResponse 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 -// ReferrerServiceDiscoverResponseMultiError, or nil if none found. -func (m *ReferrerServiceDiscoverResponse) ValidateAll() error { +// ValidateAll checks the field values on DiscoverPublicSharedResponse 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 +// DiscoverPublicSharedResponseMultiError, or nil if none found. +func (m *DiscoverPublicSharedResponse) ValidateAll() error { return m.validate(true) } -func (m *ReferrerServiceDiscoverResponse) validate(all bool) error { +func (m *DiscoverPublicSharedResponse) validate(all bool) error { if m == nil { return nil } @@ -177,7 +295,7 @@ func (m *ReferrerServiceDiscoverResponse) validate(all bool) error { switch v := interface{}(m.GetResult()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, ReferrerServiceDiscoverResponseValidationError{ + errors = append(errors, DiscoverPublicSharedResponseValidationError{ field: "Result", reason: "embedded message failed validation", cause: err, @@ -185,7 +303,7 @@ func (m *ReferrerServiceDiscoverResponse) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, ReferrerServiceDiscoverResponseValidationError{ + errors = append(errors, DiscoverPublicSharedResponseValidationError{ field: "Result", reason: "embedded message failed validation", cause: err, @@ -194,7 +312,7 @@ func (m *ReferrerServiceDiscoverResponse) validate(all bool) error { } } else if v, ok := interface{}(m.GetResult()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return ReferrerServiceDiscoverResponseValidationError{ + return DiscoverPublicSharedResponseValidationError{ field: "Result", reason: "embedded message failed validation", cause: err, @@ -203,19 +321,19 @@ func (m *ReferrerServiceDiscoverResponse) validate(all bool) error { } if len(errors) > 0 { - return ReferrerServiceDiscoverResponseMultiError(errors) + return DiscoverPublicSharedResponseMultiError(errors) } return nil } -// ReferrerServiceDiscoverResponseMultiError is an error wrapping multiple -// validation errors returned by ReferrerServiceDiscoverResponse.ValidateAll() -// if the designated constraints aren't met. -type ReferrerServiceDiscoverResponseMultiError []error +// DiscoverPublicSharedResponseMultiError is an error wrapping multiple +// validation errors returned by DiscoverPublicSharedResponse.ValidateAll() if +// the designated constraints aren't met. +type DiscoverPublicSharedResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m ReferrerServiceDiscoverResponseMultiError) Error() string { +func (m DiscoverPublicSharedResponseMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) @@ -224,12 +342,147 @@ func (m ReferrerServiceDiscoverResponseMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m ReferrerServiceDiscoverResponseMultiError) AllErrors() []error { return m } +func (m DiscoverPublicSharedResponseMultiError) AllErrors() []error { return m } + +// DiscoverPublicSharedResponseValidationError is the validation error returned +// by DiscoverPublicSharedResponse.Validate if the designated constraints +// aren't met. +type DiscoverPublicSharedResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DiscoverPublicSharedResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DiscoverPublicSharedResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DiscoverPublicSharedResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DiscoverPublicSharedResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DiscoverPublicSharedResponseValidationError) ErrorName() string { + return "DiscoverPublicSharedResponseValidationError" +} -// ReferrerServiceDiscoverResponseValidationError is the validation error -// returned by ReferrerServiceDiscoverResponse.Validate if the designated +// Error satisfies the builtin error interface +func (e DiscoverPublicSharedResponseValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sDiscoverPublicSharedResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DiscoverPublicSharedResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DiscoverPublicSharedResponseValidationError{} + +// Validate checks the field values on ReferrerServiceDiscoverPrivateResponse +// with the rules defined 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 *ReferrerServiceDiscoverPrivateResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on +// ReferrerServiceDiscoverPrivateResponse 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 +// ReferrerServiceDiscoverPrivateResponseMultiError, or nil if none found. +func (m *ReferrerServiceDiscoverPrivateResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ReferrerServiceDiscoverPrivateResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetResult()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ReferrerServiceDiscoverPrivateResponseValidationError{ + field: "Result", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ReferrerServiceDiscoverPrivateResponseValidationError{ + field: "Result", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetResult()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ReferrerServiceDiscoverPrivateResponseValidationError{ + field: "Result", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return ReferrerServiceDiscoverPrivateResponseMultiError(errors) + } + + return nil +} + +// ReferrerServiceDiscoverPrivateResponseMultiError is an error wrapping +// multiple validation errors returned by +// ReferrerServiceDiscoverPrivateResponse.ValidateAll() if the designated // constraints aren't met. -type ReferrerServiceDiscoverResponseValidationError struct { +type ReferrerServiceDiscoverPrivateResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ReferrerServiceDiscoverPrivateResponseMultiError) 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 ReferrerServiceDiscoverPrivateResponseMultiError) AllErrors() []error { return m } + +// ReferrerServiceDiscoverPrivateResponseValidationError is the validation +// error returned by ReferrerServiceDiscoverPrivateResponse.Validate if the +// designated constraints aren't met. +type ReferrerServiceDiscoverPrivateResponseValidationError struct { field string reason string cause error @@ -237,24 +490,24 @@ type ReferrerServiceDiscoverResponseValidationError struct { } // Field function returns field value. -func (e ReferrerServiceDiscoverResponseValidationError) Field() string { return e.field } +func (e ReferrerServiceDiscoverPrivateResponseValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e ReferrerServiceDiscoverResponseValidationError) Reason() string { return e.reason } +func (e ReferrerServiceDiscoverPrivateResponseValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e ReferrerServiceDiscoverResponseValidationError) Cause() error { return e.cause } +func (e ReferrerServiceDiscoverPrivateResponseValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e ReferrerServiceDiscoverResponseValidationError) Key() bool { return e.key } +func (e ReferrerServiceDiscoverPrivateResponseValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e ReferrerServiceDiscoverResponseValidationError) ErrorName() string { - return "ReferrerServiceDiscoverResponseValidationError" +func (e ReferrerServiceDiscoverPrivateResponseValidationError) ErrorName() string { + return "ReferrerServiceDiscoverPrivateResponseValidationError" } // Error satisfies the builtin error interface -func (e ReferrerServiceDiscoverResponseValidationError) Error() string { +func (e ReferrerServiceDiscoverPrivateResponseValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -266,14 +519,14 @@ func (e ReferrerServiceDiscoverResponseValidationError) Error() string { } return fmt.Sprintf( - "invalid %sReferrerServiceDiscoverResponse.%s: %s%s", + "invalid %sReferrerServiceDiscoverPrivateResponse.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = ReferrerServiceDiscoverResponseValidationError{} +var _ error = ReferrerServiceDiscoverPrivateResponseValidationError{} var _ interface { Field() string @@ -281,7 +534,7 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = ReferrerServiceDiscoverResponseValidationError{} +} = ReferrerServiceDiscoverPrivateResponseValidationError{} // Validate checks the field values on ReferrerItem with the rules defined in // the proto definition for this message. If any rules are violated, the first diff --git a/app/controlplane/api/controlplane/v1/referrer.proto b/app/controlplane/api/controlplane/v1/referrer.proto index 7b1e230f6..a6cde0f80 100644 --- a/app/controlplane/api/controlplane/v1/referrer.proto +++ b/app/controlplane/api/controlplane/v1/referrer.proto @@ -24,19 +24,33 @@ import "validate/validate.proto"; option go_package = "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1;v1"; service ReferrerService { - rpc Discover(ReferrerServiceDiscoverRequest) returns (ReferrerServiceDiscoverResponse) { + // DiscoverPrivate returns the referrer item for a given digest in the organizations of the logged-in user + rpc DiscoverPrivate(ReferrerServiceDiscoverPrivateRequest) returns (ReferrerServiceDiscoverPrivateResponse); + // DiscoverPublicShared returns the referrer item for a given digest in the public shared index + rpc DiscoverPublicShared(DiscoverPublicSharedRequest) returns (DiscoverPublicSharedResponse) { option (google.api.http) = {get: "/discover/{digest}"}; } } -message ReferrerServiceDiscoverRequest { +message ReferrerServiceDiscoverPrivateRequest { string digest = 1 [(validate.rules).string = {min_len: 1}]; // Optional kind of referrer, i.e CONTAINER_IMAGE, GIT_HEAD, ... // Used to filter and resolve ambiguities string kind = 2; } -message ReferrerServiceDiscoverResponse { +message DiscoverPublicSharedRequest { + string digest = 1 [(validate.rules).string = {min_len: 1}]; + // Optional kind of referrer, i.e CONTAINER_IMAGE, GIT_HEAD, ... + // Used to filter and resolve ambiguities + string kind = 2; +} + +message DiscoverPublicSharedResponse { + ReferrerItem result = 1; +} + +message ReferrerServiceDiscoverPrivateResponse { ReferrerItem result = 1; } diff --git a/app/controlplane/api/controlplane/v1/referrer_grpc.pb.go b/app/controlplane/api/controlplane/v1/referrer_grpc.pb.go index dd7fb9799..5694927e0 100644 --- a/app/controlplane/api/controlplane/v1/referrer_grpc.pb.go +++ b/app/controlplane/api/controlplane/v1/referrer_grpc.pb.go @@ -34,14 +34,18 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - ReferrerService_Discover_FullMethodName = "/controlplane.v1.ReferrerService/Discover" + ReferrerService_DiscoverPrivate_FullMethodName = "/controlplane.v1.ReferrerService/DiscoverPrivate" + ReferrerService_DiscoverPublicShared_FullMethodName = "/controlplane.v1.ReferrerService/DiscoverPublicShared" ) // ReferrerServiceClient is the client API for ReferrerService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type ReferrerServiceClient interface { - Discover(ctx context.Context, in *ReferrerServiceDiscoverRequest, opts ...grpc.CallOption) (*ReferrerServiceDiscoverResponse, error) + // DiscoverPrivate returns the referrer item for a given digest in the organizations of the logged-in user + DiscoverPrivate(ctx context.Context, in *ReferrerServiceDiscoverPrivateRequest, opts ...grpc.CallOption) (*ReferrerServiceDiscoverPrivateResponse, error) + // DiscoverPublicShared returns the referrer item for a given digest in the public shared index + DiscoverPublicShared(ctx context.Context, in *DiscoverPublicSharedRequest, opts ...grpc.CallOption) (*DiscoverPublicSharedResponse, error) } type referrerServiceClient struct { @@ -52,9 +56,18 @@ func NewReferrerServiceClient(cc grpc.ClientConnInterface) ReferrerServiceClient return &referrerServiceClient{cc} } -func (c *referrerServiceClient) Discover(ctx context.Context, in *ReferrerServiceDiscoverRequest, opts ...grpc.CallOption) (*ReferrerServiceDiscoverResponse, error) { - out := new(ReferrerServiceDiscoverResponse) - err := c.cc.Invoke(ctx, ReferrerService_Discover_FullMethodName, in, out, opts...) +func (c *referrerServiceClient) DiscoverPrivate(ctx context.Context, in *ReferrerServiceDiscoverPrivateRequest, opts ...grpc.CallOption) (*ReferrerServiceDiscoverPrivateResponse, error) { + out := new(ReferrerServiceDiscoverPrivateResponse) + err := c.cc.Invoke(ctx, ReferrerService_DiscoverPrivate_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *referrerServiceClient) DiscoverPublicShared(ctx context.Context, in *DiscoverPublicSharedRequest, opts ...grpc.CallOption) (*DiscoverPublicSharedResponse, error) { + out := new(DiscoverPublicSharedResponse) + err := c.cc.Invoke(ctx, ReferrerService_DiscoverPublicShared_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -65,7 +78,10 @@ func (c *referrerServiceClient) Discover(ctx context.Context, in *ReferrerServic // All implementations must embed UnimplementedReferrerServiceServer // for forward compatibility type ReferrerServiceServer interface { - Discover(context.Context, *ReferrerServiceDiscoverRequest) (*ReferrerServiceDiscoverResponse, error) + // DiscoverPrivate returns the referrer item for a given digest in the organizations of the logged-in user + DiscoverPrivate(context.Context, *ReferrerServiceDiscoverPrivateRequest) (*ReferrerServiceDiscoverPrivateResponse, error) + // DiscoverPublicShared returns the referrer item for a given digest in the public shared index + DiscoverPublicShared(context.Context, *DiscoverPublicSharedRequest) (*DiscoverPublicSharedResponse, error) mustEmbedUnimplementedReferrerServiceServer() } @@ -73,8 +89,11 @@ type ReferrerServiceServer interface { type UnimplementedReferrerServiceServer struct { } -func (UnimplementedReferrerServiceServer) Discover(context.Context, *ReferrerServiceDiscoverRequest) (*ReferrerServiceDiscoverResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Discover not implemented") +func (UnimplementedReferrerServiceServer) DiscoverPrivate(context.Context, *ReferrerServiceDiscoverPrivateRequest) (*ReferrerServiceDiscoverPrivateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DiscoverPrivate not implemented") +} +func (UnimplementedReferrerServiceServer) DiscoverPublicShared(context.Context, *DiscoverPublicSharedRequest) (*DiscoverPublicSharedResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DiscoverPublicShared not implemented") } func (UnimplementedReferrerServiceServer) mustEmbedUnimplementedReferrerServiceServer() {} @@ -89,20 +108,38 @@ func RegisterReferrerServiceServer(s grpc.ServiceRegistrar, srv ReferrerServiceS s.RegisterService(&ReferrerService_ServiceDesc, srv) } -func _ReferrerService_Discover_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ReferrerServiceDiscoverRequest) +func _ReferrerService_DiscoverPrivate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ReferrerServiceDiscoverPrivateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ReferrerServiceServer).DiscoverPrivate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ReferrerService_DiscoverPrivate_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ReferrerServiceServer).DiscoverPrivate(ctx, req.(*ReferrerServiceDiscoverPrivateRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ReferrerService_DiscoverPublicShared_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DiscoverPublicSharedRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ReferrerServiceServer).Discover(ctx, in) + return srv.(ReferrerServiceServer).DiscoverPublicShared(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: ReferrerService_Discover_FullMethodName, + FullMethod: ReferrerService_DiscoverPublicShared_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ReferrerServiceServer).Discover(ctx, req.(*ReferrerServiceDiscoverRequest)) + return srv.(ReferrerServiceServer).DiscoverPublicShared(ctx, req.(*DiscoverPublicSharedRequest)) } return interceptor(ctx, in, info, handler) } @@ -115,8 +152,12 @@ var ReferrerService_ServiceDesc = grpc.ServiceDesc{ HandlerType: (*ReferrerServiceServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "Discover", - Handler: _ReferrerService_Discover_Handler, + MethodName: "DiscoverPrivate", + Handler: _ReferrerService_DiscoverPrivate_Handler, + }, + { + MethodName: "DiscoverPublicShared", + Handler: _ReferrerService_DiscoverPublicShared_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/app/controlplane/api/controlplane/v1/referrer_http.pb.go b/app/controlplane/api/controlplane/v1/referrer_http.pb.go index 519925a96..c95bf6237 100644 --- a/app/controlplane/api/controlplane/v1/referrer_http.pb.go +++ b/app/controlplane/api/controlplane/v1/referrer_http.pb.go @@ -19,41 +19,42 @@ var _ = binding.EncodeURL const _ = http.SupportPackageIsVersion1 -const OperationReferrerServiceDiscover = "/controlplane.v1.ReferrerService/Discover" +const OperationReferrerServiceDiscoverPublicShared = "/controlplane.v1.ReferrerService/DiscoverPublicShared" type ReferrerServiceHTTPServer interface { - Discover(context.Context, *ReferrerServiceDiscoverRequest) (*ReferrerServiceDiscoverResponse, error) + // DiscoverPublicShared DiscoverPublicShared returns the referrer item for a given digest in the public shared index + DiscoverPublicShared(context.Context, *DiscoverPublicSharedRequest) (*DiscoverPublicSharedResponse, error) } func RegisterReferrerServiceHTTPServer(s *http.Server, srv ReferrerServiceHTTPServer) { r := s.Route("/") - r.GET("/discover/{digest}", _ReferrerService_Discover0_HTTP_Handler(srv)) + r.GET("/discover/{digest}", _ReferrerService_DiscoverPublicShared0_HTTP_Handler(srv)) } -func _ReferrerService_Discover0_HTTP_Handler(srv ReferrerServiceHTTPServer) func(ctx http.Context) error { +func _ReferrerService_DiscoverPublicShared0_HTTP_Handler(srv ReferrerServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { - var in ReferrerServiceDiscoverRequest + var in DiscoverPublicSharedRequest if err := ctx.BindQuery(&in); err != nil { return err } if err := ctx.BindVars(&in); err != nil { return err } - http.SetOperation(ctx, OperationReferrerServiceDiscover) + http.SetOperation(ctx, OperationReferrerServiceDiscoverPublicShared) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Discover(ctx, req.(*ReferrerServiceDiscoverRequest)) + return srv.DiscoverPublicShared(ctx, req.(*DiscoverPublicSharedRequest)) }) out, err := h(ctx, &in) if err != nil { return err } - reply := out.(*ReferrerServiceDiscoverResponse) + reply := out.(*DiscoverPublicSharedResponse) return ctx.Result(200, reply) } } type ReferrerServiceHTTPClient interface { - Discover(ctx context.Context, req *ReferrerServiceDiscoverRequest, opts ...http.CallOption) (rsp *ReferrerServiceDiscoverResponse, err error) + DiscoverPublicShared(ctx context.Context, req *DiscoverPublicSharedRequest, opts ...http.CallOption) (rsp *DiscoverPublicSharedResponse, err error) } type ReferrerServiceHTTPClientImpl struct { @@ -64,11 +65,11 @@ func NewReferrerServiceHTTPClient(client *http.Client) ReferrerServiceHTTPClient return &ReferrerServiceHTTPClientImpl{client} } -func (c *ReferrerServiceHTTPClientImpl) Discover(ctx context.Context, in *ReferrerServiceDiscoverRequest, opts ...http.CallOption) (*ReferrerServiceDiscoverResponse, error) { - var out ReferrerServiceDiscoverResponse +func (c *ReferrerServiceHTTPClientImpl) DiscoverPublicShared(ctx context.Context, in *DiscoverPublicSharedRequest, opts ...http.CallOption) (*DiscoverPublicSharedResponse, error) { + var out DiscoverPublicSharedResponse pattern := "/discover/{digest}" path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationReferrerServiceDiscover)) + opts = append(opts, http.Operation(OperationReferrerServiceDiscoverPublicShared)) opts = append(opts, http.PathTemplate(pattern)) err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) if err != nil { diff --git a/app/controlplane/api/gen/frontend/controlplane/v1/referrer.ts b/app/controlplane/api/gen/frontend/controlplane/v1/referrer.ts index 36a16bea3..5fe1f4fc6 100644 --- a/app/controlplane/api/gen/frontend/controlplane/v1/referrer.ts +++ b/app/controlplane/api/gen/frontend/controlplane/v1/referrer.ts @@ -6,7 +6,7 @@ import { Timestamp } from "../../google/protobuf/timestamp"; export const protobufPackage = "controlplane.v1"; -export interface ReferrerServiceDiscoverRequest { +export interface ReferrerServiceDiscoverPrivateRequest { digest: string; /** * Optional kind of referrer, i.e CONTAINER_IMAGE, GIT_HEAD, ... @@ -15,7 +15,20 @@ export interface ReferrerServiceDiscoverRequest { kind: string; } -export interface ReferrerServiceDiscoverResponse { +export interface DiscoverPublicSharedRequest { + digest: string; + /** + * Optional kind of referrer, i.e CONTAINER_IMAGE, GIT_HEAD, ... + * Used to filter and resolve ambiguities + */ + kind: string; +} + +export interface DiscoverPublicSharedResponse { + result?: ReferrerItem; +} + +export interface ReferrerServiceDiscoverPrivateResponse { result?: ReferrerItem; } @@ -32,12 +45,12 @@ export interface ReferrerItem { createdAt?: Date; } -function createBaseReferrerServiceDiscoverRequest(): ReferrerServiceDiscoverRequest { +function createBaseReferrerServiceDiscoverPrivateRequest(): ReferrerServiceDiscoverPrivateRequest { return { digest: "", kind: "" }; } -export const ReferrerServiceDiscoverRequest = { - encode(message: ReferrerServiceDiscoverRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { +export const ReferrerServiceDiscoverPrivateRequest = { + encode(message: ReferrerServiceDiscoverPrivateRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.digest !== "") { writer.uint32(10).string(message.digest); } @@ -47,10 +60,10 @@ export const ReferrerServiceDiscoverRequest = { return writer; }, - decode(input: _m0.Reader | Uint8Array, length?: number): ReferrerServiceDiscoverRequest { + decode(input: _m0.Reader | Uint8Array, length?: number): ReferrerServiceDiscoverPrivateRequest { const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseReferrerServiceDiscoverRequest(); + const message = createBaseReferrerServiceDiscoverPrivateRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -77,50 +90,123 @@ export const ReferrerServiceDiscoverRequest = { return message; }, - fromJSON(object: any): ReferrerServiceDiscoverRequest { + fromJSON(object: any): ReferrerServiceDiscoverPrivateRequest { return { digest: isSet(object.digest) ? String(object.digest) : "", kind: isSet(object.kind) ? String(object.kind) : "", }; }, - toJSON(message: ReferrerServiceDiscoverRequest): unknown { + toJSON(message: ReferrerServiceDiscoverPrivateRequest): unknown { const obj: any = {}; message.digest !== undefined && (obj.digest = message.digest); message.kind !== undefined && (obj.kind = message.kind); return obj; }, - create, I>>(base?: I): ReferrerServiceDiscoverRequest { - return ReferrerServiceDiscoverRequest.fromPartial(base ?? {}); + create, I>>( + base?: I, + ): ReferrerServiceDiscoverPrivateRequest { + return ReferrerServiceDiscoverPrivateRequest.fromPartial(base ?? {}); }, - fromPartial, I>>( + fromPartial, I>>( object: I, - ): ReferrerServiceDiscoverRequest { - const message = createBaseReferrerServiceDiscoverRequest(); + ): ReferrerServiceDiscoverPrivateRequest { + const message = createBaseReferrerServiceDiscoverPrivateRequest(); + message.digest = object.digest ?? ""; + message.kind = object.kind ?? ""; + return message; + }, +}; + +function createBaseDiscoverPublicSharedRequest(): DiscoverPublicSharedRequest { + return { digest: "", kind: "" }; +} + +export const DiscoverPublicSharedRequest = { + encode(message: DiscoverPublicSharedRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.digest !== "") { + writer.uint32(10).string(message.digest); + } + if (message.kind !== "") { + writer.uint32(18).string(message.kind); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): DiscoverPublicSharedRequest { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDiscoverPublicSharedRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.digest = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.kind = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): DiscoverPublicSharedRequest { + return { + digest: isSet(object.digest) ? String(object.digest) : "", + kind: isSet(object.kind) ? String(object.kind) : "", + }; + }, + + toJSON(message: DiscoverPublicSharedRequest): unknown { + const obj: any = {}; + message.digest !== undefined && (obj.digest = message.digest); + message.kind !== undefined && (obj.kind = message.kind); + return obj; + }, + + create, I>>(base?: I): DiscoverPublicSharedRequest { + return DiscoverPublicSharedRequest.fromPartial(base ?? {}); + }, + + fromPartial, I>>(object: I): DiscoverPublicSharedRequest { + const message = createBaseDiscoverPublicSharedRequest(); message.digest = object.digest ?? ""; message.kind = object.kind ?? ""; return message; }, }; -function createBaseReferrerServiceDiscoverResponse(): ReferrerServiceDiscoverResponse { +function createBaseDiscoverPublicSharedResponse(): DiscoverPublicSharedResponse { return { result: undefined }; } -export const ReferrerServiceDiscoverResponse = { - encode(message: ReferrerServiceDiscoverResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { +export const DiscoverPublicSharedResponse = { + encode(message: DiscoverPublicSharedResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.result !== undefined) { ReferrerItem.encode(message.result, writer.uint32(10).fork()).ldelim(); } return writer; }, - decode(input: _m0.Reader | Uint8Array, length?: number): ReferrerServiceDiscoverResponse { + decode(input: _m0.Reader | Uint8Array, length?: number): DiscoverPublicSharedResponse { const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseReferrerServiceDiscoverResponse(); + const message = createBaseDiscoverPublicSharedResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -140,24 +226,84 @@ export const ReferrerServiceDiscoverResponse = { return message; }, - fromJSON(object: any): ReferrerServiceDiscoverResponse { + fromJSON(object: any): DiscoverPublicSharedResponse { return { result: isSet(object.result) ? ReferrerItem.fromJSON(object.result) : undefined }; }, - toJSON(message: ReferrerServiceDiscoverResponse): unknown { + toJSON(message: DiscoverPublicSharedResponse): unknown { const obj: any = {}; message.result !== undefined && (obj.result = message.result ? ReferrerItem.toJSON(message.result) : undefined); return obj; }, - create, I>>(base?: I): ReferrerServiceDiscoverResponse { - return ReferrerServiceDiscoverResponse.fromPartial(base ?? {}); + create, I>>(base?: I): DiscoverPublicSharedResponse { + return DiscoverPublicSharedResponse.fromPartial(base ?? {}); }, - fromPartial, I>>( + fromPartial, I>>(object: I): DiscoverPublicSharedResponse { + const message = createBaseDiscoverPublicSharedResponse(); + message.result = (object.result !== undefined && object.result !== null) + ? ReferrerItem.fromPartial(object.result) + : undefined; + return message; + }, +}; + +function createBaseReferrerServiceDiscoverPrivateResponse(): ReferrerServiceDiscoverPrivateResponse { + return { result: undefined }; +} + +export const ReferrerServiceDiscoverPrivateResponse = { + encode(message: ReferrerServiceDiscoverPrivateResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.result !== undefined) { + ReferrerItem.encode(message.result, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): ReferrerServiceDiscoverPrivateResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseReferrerServiceDiscoverPrivateResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.result = ReferrerItem.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): ReferrerServiceDiscoverPrivateResponse { + return { result: isSet(object.result) ? ReferrerItem.fromJSON(object.result) : undefined }; + }, + + toJSON(message: ReferrerServiceDiscoverPrivateResponse): unknown { + const obj: any = {}; + message.result !== undefined && (obj.result = message.result ? ReferrerItem.toJSON(message.result) : undefined); + return obj; + }, + + create, I>>( + base?: I, + ): ReferrerServiceDiscoverPrivateResponse { + return ReferrerServiceDiscoverPrivateResponse.fromPartial(base ?? {}); + }, + + fromPartial, I>>( object: I, - ): ReferrerServiceDiscoverResponse { - const message = createBaseReferrerServiceDiscoverResponse(); + ): ReferrerServiceDiscoverPrivateResponse { + const message = createBaseReferrerServiceDiscoverPrivateResponse(); message.result = (object.result !== undefined && object.result !== null) ? ReferrerItem.fromPartial(object.result) : undefined; @@ -293,10 +439,16 @@ export const ReferrerItem = { }; export interface ReferrerService { - Discover( - request: DeepPartial, + /** DiscoverPrivate returns the referrer item for a given digest in the organizations of the logged-in user */ + DiscoverPrivate( + request: DeepPartial, metadata?: grpc.Metadata, - ): Promise; + ): Promise; + /** DiscoverPublicShared returns the referrer item for a given digest in the public shared index */ + DiscoverPublicShared( + request: DeepPartial, + metadata?: grpc.Metadata, + ): Promise; } export class ReferrerServiceClientImpl implements ReferrerService { @@ -304,32 +456,71 @@ export class ReferrerServiceClientImpl implements ReferrerService { constructor(rpc: Rpc) { this.rpc = rpc; - this.Discover = this.Discover.bind(this); + this.DiscoverPrivate = this.DiscoverPrivate.bind(this); + this.DiscoverPublicShared = this.DiscoverPublicShared.bind(this); } - Discover( - request: DeepPartial, + DiscoverPrivate( + request: DeepPartial, metadata?: grpc.Metadata, - ): Promise { - return this.rpc.unary(ReferrerServiceDiscoverDesc, ReferrerServiceDiscoverRequest.fromPartial(request), metadata); + ): Promise { + return this.rpc.unary( + ReferrerServiceDiscoverPrivateDesc, + ReferrerServiceDiscoverPrivateRequest.fromPartial(request), + metadata, + ); + } + + DiscoverPublicShared( + request: DeepPartial, + metadata?: grpc.Metadata, + ): Promise { + return this.rpc.unary( + ReferrerServiceDiscoverPublicSharedDesc, + DiscoverPublicSharedRequest.fromPartial(request), + metadata, + ); } } export const ReferrerServiceDesc = { serviceName: "controlplane.v1.ReferrerService" }; -export const ReferrerServiceDiscoverDesc: UnaryMethodDefinitionish = { - methodName: "Discover", +export const ReferrerServiceDiscoverPrivateDesc: UnaryMethodDefinitionish = { + methodName: "DiscoverPrivate", + service: ReferrerServiceDesc, + requestStream: false, + responseStream: false, + requestType: { + serializeBinary() { + return ReferrerServiceDiscoverPrivateRequest.encode(this).finish(); + }, + } as any, + responseType: { + deserializeBinary(data: Uint8Array) { + const value = ReferrerServiceDiscoverPrivateResponse.decode(data); + return { + ...value, + toObject() { + return value; + }, + }; + }, + } as any, +}; + +export const ReferrerServiceDiscoverPublicSharedDesc: UnaryMethodDefinitionish = { + methodName: "DiscoverPublicShared", service: ReferrerServiceDesc, requestStream: false, responseStream: false, requestType: { serializeBinary() { - return ReferrerServiceDiscoverRequest.encode(this).finish(); + return DiscoverPublicSharedRequest.encode(this).finish(); }, } as any, responseType: { deserializeBinary(data: Uint8Array) { - const value = ReferrerServiceDiscoverResponse.decode(data); + const value = DiscoverPublicSharedResponse.decode(data); return { ...value, toObject() { diff --git a/app/controlplane/configs/config.devel.yaml b/app/controlplane/configs/config.devel.yaml index 0c81706f2..b1335f3f9 100644 --- a/app/controlplane/configs/config.devel.yaml +++ b/app/controlplane/configs/config.devel.yaml @@ -49,6 +49,6 @@ auth: cas_robot_account_private_key_path: "../../devel/devkeys/cas.pem" referrer_shared_index: - enabled: false + enabled: true allowed_orgs: - - deadbeef + - 7ae5a35a-9f01-4711-b293-bd1d161c01a9 # practical_mayer diff --git a/app/controlplane/internal/biz/referrer.go b/app/controlplane/internal/biz/referrer.go index 7013d574a..172796b5c 100644 --- a/app/controlplane/internal/biz/referrer.go +++ b/app/controlplane/internal/biz/referrer.go @@ -190,6 +190,7 @@ func (s *ReferrerUseCase) GetFromRoot(ctx context.Context, digest, rootKind, use } // Get the list of public referrers from organizations that have been allowed to be shown in a shared index +// NOTE: This is a public endpoint func (s *ReferrerUseCase) GetFromRootInPublicSharedIndex(ctx context.Context, digest, rootKind string) (*StoredReferrer, error) { if s.indexConfig == nil || !s.indexConfig.Enabled { return nil, NewErrUnauthorizedStr("shared referrer index functionality is not enabled") diff --git a/app/controlplane/internal/conf/conf.go b/app/controlplane/internal/conf/conf.go index 1d3b0d056..8bdf8f416 100644 --- a/app/controlplane/internal/conf/conf.go +++ b/app/controlplane/internal/conf/conf.go @@ -23,7 +23,7 @@ import ( ) func (c *ReferrerSharedIndex) ValidateOrgs() error { - if c == nil { + if c == nil || !c.Enabled { return nil } diff --git a/app/controlplane/internal/conf/conf_test.go b/app/controlplane/internal/conf/conf_test.go index 878d57788..3f6d14478 100644 --- a/app/controlplane/internal/conf/conf_test.go +++ b/app/controlplane/internal/conf/conf_test.go @@ -46,6 +46,13 @@ func TestValidateOrgs(t *testing.T) { }, wantErrMsg: "invalid org id: invalid", }, + { + name: "with invalid orgs but disabled", + index: &ReferrerSharedIndex{ + Enabled: false, + AllowedOrgs: []string{"invalid"}, + }, + }, { name: "enabled with valid orgs", index: &ReferrerSharedIndex{ @@ -65,5 +72,4 @@ func TestValidateOrgs(t *testing.T) { } }) } - } diff --git a/app/controlplane/internal/data/referrer.go b/app/controlplane/internal/data/referrer.go index ae4a17ffe..d6302ef26 100644 --- a/app/controlplane/internal/data/referrer.go +++ b/app/controlplane/internal/data/referrer.go @@ -128,8 +128,11 @@ func (r *ReferrerRepo) GetFromRoot(ctx context.Context, digest string, orgIDs [] // Find the referrer from its digest + artifactType // if there is more than 1 item we return ReferrerAmbiguous error query := r.data.db.Referrer.Query(). - Where(referrer.Digest(digest)). - Where(referrer.HasOrganizationsWith(organization.IDIn(orgIDs...))) + Where( + referrer.Digest(digest), + referrer.HasOrganizationsWith(organization.IDIn(orgIDs...)), + referrer.HasWorkflowsWith(workflow.DeletedAtIsNil()), + ) // We might be filtering by the rootKind, this will prevent ambiguity if opts.RootKind != nil { @@ -212,7 +215,12 @@ func (r *ReferrerRepo) doGet(ctx context.Context, root *ent.Referrer, allowedOrg // Find the references and call recursively filtered out by the allowed organizations // and by the visibility if needed - query := root.QueryReferences().Where(referrer.HasOrganizationsWith(organization.IDIn(allowedOrgs...))) + query := root.QueryReferences(). + Where( + referrer.HasOrganizationsWith(organization.IDIn(allowedOrgs...)), + referrer.HasWorkflowsWith(workflow.DeletedAtIsNil()), + ) + if public != nil { query = query.Where(referrer.HasWorkflowsWith(workflow.Public(*public))) } diff --git a/app/controlplane/internal/server/grpc.go b/app/controlplane/internal/server/grpc.go index 2939b3775..dd149021b 100644 --- a/app/controlplane/internal/server/grpc.go +++ b/app/controlplane/internal/server/grpc.go @@ -193,7 +193,7 @@ func craftMiddleware(opts *Opts) []middleware.Middleware { // If we should load the user func requireCurrentUserMatcher() selector.MatchFunc { // Skip authentication on the status grpc service - const skipRegexp = "(controlplane.v1.AttestationService/.*|controlplane.v1.StatusService/.*)" + const skipRegexp = "(controlplane.v1.AttestationService/.*|controlplane.v1.StatusService/.*|controlplane.v1.ReferrerService/DiscoverPublicShared)" return func(ctx context.Context, operation string) bool { r := regexp.MustCompile(skipRegexp) diff --git a/app/controlplane/internal/service/referrer.go b/app/controlplane/internal/service/referrer.go index cbbdc75b3..0edac4c32 100644 --- a/app/controlplane/internal/service/referrer.go +++ b/app/controlplane/internal/service/referrer.go @@ -37,7 +37,7 @@ func NewReferrerService(uc *biz.ReferrerUseCase, opts ...NewOpt) *ReferrerServic } } -func (s *ReferrerService) Discover(ctx context.Context, req *pb.ReferrerServiceDiscoverRequest) (*pb.ReferrerServiceDiscoverResponse, error) { +func (s *ReferrerService) DiscoverPrivate(ctx context.Context, req *pb.ReferrerServiceDiscoverPrivateRequest) (*pb.ReferrerServiceDiscoverPrivateResponse, error) { currentUser, _, err := loadCurrentUserAndOrg(ctx) if err != nil { return nil, err @@ -48,7 +48,18 @@ func (s *ReferrerService) Discover(ctx context.Context, req *pb.ReferrerServiceD return nil, handleUseCaseErr("referrer discovery", err, s.log) } - return &pb.ReferrerServiceDiscoverResponse{ + return &pb.ReferrerServiceDiscoverPrivateResponse{ + Result: bizReferrerToPb(res), + }, nil +} + +func (s *ReferrerService) DiscoverPublicShared(ctx context.Context, req *pb.DiscoverPublicSharedRequest) (*pb.DiscoverPublicSharedResponse, error) { + res, err := s.referrerUC.GetFromRootInPublicSharedIndex(ctx, req.GetDigest(), req.GetKind()) + if err != nil { + return nil, handleUseCaseErr("referrer discovery", err, s.log) + } + + return &pb.DiscoverPublicSharedResponse{ Result: bizReferrerToPb(res), }, nil } From acc220f73e35860c9042b46054be149f8aa60949 Mon Sep 17 00:00:00 2001 From: Miguel Martinez Trivino Date: Thu, 16 Nov 2023 16:54:17 +0100 Subject: [PATCH 3/7] expose index Signed-off-by: Miguel Martinez Trivino --- app/controlplane/internal/biz/referrer.go | 5 +- .../internal/biz/referrer_integration_test.go | 88 +++++++++++++++++++ app/controlplane/internal/data/referrer.go | 33 ++++--- 3 files changed, 112 insertions(+), 14 deletions(-) diff --git a/app/controlplane/internal/biz/referrer.go b/app/controlplane/internal/biz/referrer.go index 172796b5c..e3e17239c 100644 --- a/app/controlplane/internal/biz/referrer.go +++ b/app/controlplane/internal/biz/referrer.go @@ -189,8 +189,9 @@ func (s *ReferrerUseCase) GetFromRoot(ctx context.Context, digest, rootKind, use return ref, nil } -// Get the list of public referrers from organizations that have been allowed to be shown in a shared index -// NOTE: This is a public endpoint +// Get the list of public referrers from organizations +// that have been allowed to be shown in a shared index +// NOTE: This is a public endpoint under /discover/[sha256:deadbeef] func (s *ReferrerUseCase) GetFromRootInPublicSharedIndex(ctx context.Context, digest, rootKind string) (*StoredReferrer, error) { if s.indexConfig == nil || !s.indexConfig.Enabled { return nil, NewErrUnauthorizedStr("shared referrer index functionality is not enabled") diff --git a/app/controlplane/internal/biz/referrer_integration_test.go b/app/controlplane/internal/biz/referrer_integration_test.go index 57207864b..bfe381221 100644 --- a/app/controlplane/internal/biz/referrer_integration_test.go +++ b/app/controlplane/internal/biz/referrer_integration_test.go @@ -23,12 +23,91 @@ import ( "github.com/chainloop-dev/chainloop/app/controlplane/internal/biz" "github.com/chainloop-dev/chainloop/app/controlplane/internal/biz/testhelpers" + "github.com/chainloop-dev/chainloop/app/controlplane/internal/conf" "github.com/google/uuid" "github.com/secure-systems-lab/go-securesystemslib/dsse" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" ) +func (s *referrerIntegrationTestSuite) TestGetFromRootInPublicSharedIndex() { + // Load attestation + attJSON, err := os.ReadFile("testdata/attestations/with-git-subject.json") + require.NoError(s.T(), err) + var envelope *dsse.Envelope + require.NoError(s.T(), json.Unmarshal(attJSON, &envelope)) + + wantReferrerAtt := &biz.Referrer{ + Digest: "sha256:ad704d286bcad6e155e71c33d48247931231338396acbcd9769087530085b2a2", + Kind: "ATTESTATION", + Downloadable: true, + } + + // We'll store the attestation in the private only index + ctx := context.Background() + s.T().Run("public endpoint fails if feature not enabled", func(t *testing.T) { + _, err := s.Referrer.GetFromRootInPublicSharedIndex(ctx, wantReferrerAtt.Digest, "") + s.ErrorContains(err, "not enabled") + }) + + s.T().Run("storing it associated with a private workflow keeps it private and not in the index", func(t *testing.T) { + err = s.sharedEnabledUC.ExtractAndPersist(ctx, envelope, s.workflow1.ID.String()) + require.NoError(s.T(), err) + ref, err := s.Referrer.GetFromRoot(ctx, wantReferrerAtt.Digest, "", s.user.ID) + s.NoError(err) + s.False(ref.InPublicWorkflow) + res, err := s.sharedEnabledUC.GetFromRootInPublicSharedIndex(ctx, wantReferrerAtt.Digest, "") + s.True(biz.IsNotFound(err)) + s.Nil(res) + }) + + s.T().Run("storing it associated with a public workflow but not allowed org keeps it out of the index", func(t *testing.T) { + // Make workflow2 public + _, err := s.Workflow.Update(ctx, s.org2.ID, s.workflow2.ID.String(), &biz.WorkflowUpdateOpts{Public: toPtrBool(true)}) + require.NoError(t, err) + + err = s.sharedEnabledUC.ExtractAndPersist(ctx, envelope, s.workflow2.ID.String()) + require.NoError(s.T(), err) + // It's marked as public in the internal index + ref, err := s.sharedEnabledUC.GetFromRoot(ctx, wantReferrerAtt.Digest, "", s.user.ID) + s.NoError(err) + s.True(ref.InPublicWorkflow) + + // But it's not in the public shared index because the org 2 is not whitelisted + res, err := s.sharedEnabledUC.GetFromRootInPublicSharedIndex(ctx, wantReferrerAtt.Digest, "") + s.True(biz.IsNotFound(err)) + s.Nil(res) + }) + + s.T().Run("it should appear if we whitelist org2", func(t *testing.T) { + uc, err := biz.NewReferrerUseCase(s.Repos.Referrer, s.Repos.Workflow, s.Repos.Membership, + &conf.ReferrerSharedIndex{ + Enabled: true, + AllowedOrgs: []string{s.org2.ID}, + }, nil) + require.NoError(t, err) + // Now it's public since org2 is whitelisted + res, err := uc.GetFromRootInPublicSharedIndex(ctx, wantReferrerAtt.Digest, "") + s.NoError(err) + s.Equal(wantReferrerAtt.Digest, res.Digest) + }) + + s.T().Run("or we can make the workflow 1 public", func(t *testing.T) { + // reset workflow2 to private + _, err := s.Workflow.Update(ctx, s.org2.ID, s.workflow2.ID.String(), &biz.WorkflowUpdateOpts{Public: toPtrBool(false)}) + require.NoError(t, err) + // Make workflow1 public + _, err = s.Workflow.Update(ctx, s.org1.ID, s.workflow1.ID.String(), &biz.WorkflowUpdateOpts{Public: toPtrBool(true)}) + require.NoError(t, err) + err = s.sharedEnabledUC.ExtractAndPersist(ctx, envelope, s.workflow2.ID.String()) + require.NoError(s.T(), err) + // Now it's public since org1 is whitelisted + res, err := s.sharedEnabledUC.GetFromRootInPublicSharedIndex(ctx, wantReferrerAtt.Digest, "") + s.NoError(err) + s.Equal(wantReferrerAtt.Digest, res.Digest) + }) +} + func (s *referrerIntegrationTestSuite) TestExtractAndPersists() { // Load attestation attJSON, err := os.ReadFile("testdata/attestations/with-git-subject.json") @@ -271,6 +350,7 @@ type referrerIntegrationTestSuite struct { workflow1, workflow2 *biz.Workflow org1UUID, org2UUID uuid.UUID user, user2 *biz.User + sharedEnabledUC *biz.ReferrerUseCase } func (s *referrerIntegrationTestSuite) SetupTest() { @@ -306,6 +386,14 @@ func (s *referrerIntegrationTestSuite) SetupTest() { require.NoError(s.T(), err) _, err = s.Membership.Create(ctx, s.org2.ID, s.user2.ID, true) require.NoError(s.T(), err) + + s.sharedEnabledUC, err = biz.NewReferrerUseCase(s.Repos.Referrer, s.Repos.Workflow, s.Repos.Membership, + &conf.ReferrerSharedIndex{ + Enabled: true, + AllowedOrgs: []string{s.org1.ID}, + }, nil) + require.NoError(s.T(), err) + } func TestReferrerIntegration(t *testing.T) { diff --git a/app/controlplane/internal/data/referrer.go b/app/controlplane/internal/data/referrer.go index d6302ef26..3c781570e 100644 --- a/app/controlplane/internal/data/referrer.go +++ b/app/controlplane/internal/data/referrer.go @@ -22,6 +22,7 @@ import ( "github.com/chainloop-dev/chainloop/app/controlplane/internal/biz" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/organization" + "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/predicate" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/referrer" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/workflow" "github.com/go-kratos/kratos/v2/log" @@ -125,26 +126,34 @@ func (r *ReferrerRepo) GetFromRoot(ctx context.Context, digest string, orgIDs [] f(opts) } - // Find the referrer from its digest + artifactType + // Find the referrer from its digest + artifactType (optional) // if there is more than 1 item we return ReferrerAmbiguous error - query := r.data.db.Referrer.Query(). - Where( - referrer.Digest(digest), - referrer.HasOrganizationsWith(organization.IDIn(orgIDs...)), - referrer.HasWorkflowsWith(workflow.DeletedAtIsNil()), - ) + // filter by the allowed organizations and by the visibility of the attached workflows if needed + predicateReferrer := []predicate.Referrer{ + referrer.Digest(digest), + referrer.HasOrganizationsWith(organization.IDIn(orgIDs...)), + referrer.HasWorkflowsWith(workflow.DeletedAtIsNil(), workflow.HasOrganizationWith(organization.IDIn(orgIDs...))), + } // We might be filtering by the rootKind, this will prevent ambiguity if opts.RootKind != nil { - query = query.Where(referrer.Kind(*opts.RootKind)) + predicateReferrer = append(predicateReferrer, referrer.Kind(*opts.RootKind)) } - // And by visibility + // Prepare the workflow query predicate + predicateWF := []predicate.Workflow{ + workflow.DeletedAtIsNil(), workflow.HasOrganizationWith(organization.IDIn(orgIDs...)), + } + + // optionally attaching its visibility if opts.Public != nil { - query = query.Where(referrer.HasWorkflowsWith(workflow.Public(*opts.Public))) + predicateWF = append(predicateWF, workflow.Public(*opts.Public)) } - refs, err := query.WithWorkflows().WithOrganizations().All(ctx) + // Attach the workflow predicate + predicateReferrer = append(predicateReferrer, referrer.HasWorkflowsWith(predicateWF...)) + + refs, err := r.data.db.Referrer.Query().Where(predicateReferrer...).WithWorkflows().WithOrganizations().All(ctx) if err != nil { return nil, fmt.Errorf("failed to query referrer: %w", err) } @@ -218,7 +227,7 @@ func (r *ReferrerRepo) doGet(ctx context.Context, root *ent.Referrer, allowedOrg query := root.QueryReferences(). Where( referrer.HasOrganizationsWith(organization.IDIn(allowedOrgs...)), - referrer.HasWorkflowsWith(workflow.DeletedAtIsNil()), + referrer.HasWorkflowsWith(workflow.DeletedAtIsNil(), workflow.HasOrganizationWith(organization.IDIn(allowedOrgs...))), ) if public != nil { From 6846777c4c81f45474280c4f5234240242ab924f Mon Sep 17 00:00:00 2001 From: Miguel Martinez Trivino Date: Thu, 16 Nov 2023 17:07:00 +0100 Subject: [PATCH 4/7] expose index Signed-off-by: Miguel Martinez Trivino --- app/controlplane/configs/config.devel.yaml | 8 ++++---- .../internal/biz/referrer_integration_test.go | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controlplane/configs/config.devel.yaml b/app/controlplane/configs/config.devel.yaml index b1335f3f9..9e72e1a88 100644 --- a/app/controlplane/configs/config.devel.yaml +++ b/app/controlplane/configs/config.devel.yaml @@ -48,7 +48,7 @@ auth: # Private key used to sign the JWTs meant to be consumed by the CAS cas_robot_account_private_key_path: "../../devel/devkeys/cas.pem" -referrer_shared_index: - enabled: true - allowed_orgs: - - 7ae5a35a-9f01-4711-b293-bd1d161c01a9 # practical_mayer +# referrer_shared_index: +# enabled: true +# allowed_orgs: +# - deadbeef diff --git a/app/controlplane/internal/biz/referrer_integration_test.go b/app/controlplane/internal/biz/referrer_integration_test.go index bfe381221..f7ef3008b 100644 --- a/app/controlplane/internal/biz/referrer_integration_test.go +++ b/app/controlplane/internal/biz/referrer_integration_test.go @@ -393,7 +393,6 @@ func (s *referrerIntegrationTestSuite) SetupTest() { AllowedOrgs: []string{s.org1.ID}, }, nil) require.NoError(s.T(), err) - } func TestReferrerIntegration(t *testing.T) { From 7485c9b4ad1c9a4183aeef493382ee35f05d0bdd Mon Sep 17 00:00:00 2001 From: Miguel Martinez Trivino Date: Thu, 16 Nov 2023 17:22:50 +0100 Subject: [PATCH 5/7] expose index Signed-off-by: Miguel Martinez Trivino --- app/controlplane/internal/data/referrer.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/controlplane/internal/data/referrer.go b/app/controlplane/internal/data/referrer.go index 3c781570e..c7784f584 100644 --- a/app/controlplane/internal/data/referrer.go +++ b/app/controlplane/internal/data/referrer.go @@ -132,7 +132,6 @@ func (r *ReferrerRepo) GetFromRoot(ctx context.Context, digest string, orgIDs [] predicateReferrer := []predicate.Referrer{ referrer.Digest(digest), referrer.HasOrganizationsWith(organization.IDIn(orgIDs...)), - referrer.HasWorkflowsWith(workflow.DeletedAtIsNil(), workflow.HasOrganizationWith(organization.IDIn(orgIDs...))), } // We might be filtering by the rootKind, this will prevent ambiguity @@ -224,17 +223,23 @@ func (r *ReferrerRepo) doGet(ctx context.Context, root *ent.Referrer, allowedOrg // Find the references and call recursively filtered out by the allowed organizations // and by the visibility if needed - query := root.QueryReferences(). - Where( - referrer.HasOrganizationsWith(organization.IDIn(allowedOrgs...)), - referrer.HasWorkflowsWith(workflow.DeletedAtIsNil(), workflow.HasOrganizationWith(organization.IDIn(allowedOrgs...))), - ) + predicateReferrer := []predicate.Referrer{ + referrer.HasOrganizationsWith(organization.IDIn(allowedOrgs...)), + } + + predicateWF := []predicate.Workflow{ + workflow.DeletedAtIsNil(), workflow.HasOrganizationWith(organization.IDIn(allowedOrgs...)), + } + // optionally attaching its visibility if public != nil { - query = query.Where(referrer.HasWorkflowsWith(workflow.Public(*public))) + predicateWF = append(predicateWF, workflow.Public(*public)) } - refs, err := query.WithWorkflows().WithOrganizations().Order(referrer.ByDigest()).All(ctx) + // Attach the workflow predicate + predicateReferrer = append(predicateReferrer, referrer.HasWorkflowsWith(predicateWF...)) + + refs, err := root.QueryReferences().Where(predicateReferrer...).WithWorkflows().WithOrganizations().Order(referrer.ByDigest()).All(ctx) if err != nil { return nil, fmt.Errorf("failed to query references: %w", err) } From a5d0a0d40c7d6ff1e7df84c256fc507d4b25a7b9 Mon Sep 17 00:00:00 2001 From: Miguel Martinez Trivino Date: Thu, 16 Nov 2023 22:39:53 +0100 Subject: [PATCH 6/7] remove organization table Signed-off-by: Miguel Martinez Trivino --- app/controlplane/configs/config.devel.yaml | 8 +- app/controlplane/internal/data/ent/client.go | 32 -- .../ent/migrate/migrations/20231116212408.sql | 2 + .../data/ent/migrate/migrations/atlas.sum | 3 +- .../internal/data/ent/migrate/schema.go | 28 -- .../internal/data/ent/mutation.go | 286 +++++------------- .../internal/data/ent/organization.go | 18 +- .../data/ent/organization/organization.go | 34 --- .../internal/data/ent/organization/where.go | 23 -- .../internal/data/ent/organization_create.go | 32 -- .../internal/data/ent/organization_query.go | 119 +------- .../internal/data/ent/organization_update.go | 163 ---------- .../internal/data/ent/referrer.go | 20 +- .../internal/data/ent/referrer/referrer.go | 31 -- .../internal/data/ent/referrer/where.go | 23 -- .../internal/data/ent/referrer_create.go | 32 -- .../internal/data/ent/referrer_query.go | 137 +-------- .../internal/data/ent/referrer_update.go | 163 ---------- .../internal/data/ent/schema-viz.html | 2 +- .../internal/data/ent/schema/organization.go | 3 +- .../internal/data/ent/schema/referrer.go | 2 - .../internal/data/ent/schema/workflow.go | 3 +- .../internal/data/ent/workflow.go | 23 +- .../internal/data/ent/workflow/where.go | 25 ++ .../internal/data/ent/workflow/workflow.go | 9 +- .../internal/data/ent/workflow_create.go | 17 +- .../internal/data/ent/workflow_query.go | 10 +- .../internal/data/ent/workflow_update.go | 24 +- app/controlplane/internal/data/referrer.go | 74 +++-- 29 files changed, 226 insertions(+), 1120 deletions(-) create mode 100644 app/controlplane/internal/data/ent/migrate/migrations/20231116212408.sql diff --git a/app/controlplane/configs/config.devel.yaml b/app/controlplane/configs/config.devel.yaml index 9e72e1a88..b1335f3f9 100644 --- a/app/controlplane/configs/config.devel.yaml +++ b/app/controlplane/configs/config.devel.yaml @@ -48,7 +48,7 @@ auth: # Private key used to sign the JWTs meant to be consumed by the CAS cas_robot_account_private_key_path: "../../devel/devkeys/cas.pem" -# referrer_shared_index: -# enabled: true -# allowed_orgs: -# - deadbeef +referrer_shared_index: + enabled: true + allowed_orgs: + - 7ae5a35a-9f01-4711-b293-bd1d161c01a9 # practical_mayer diff --git a/app/controlplane/internal/data/ent/client.go b/app/controlplane/internal/data/ent/client.go index 45dd4225d..3f8dfe147 100644 --- a/app/controlplane/internal/data/ent/client.go +++ b/app/controlplane/internal/data/ent/client.go @@ -1396,22 +1396,6 @@ func (c *OrganizationClient) QueryIntegrations(o *Organization) *IntegrationQuer return query } -// QueryReferrers queries the referrers edge of a Organization. -func (c *OrganizationClient) QueryReferrers(o *Organization) *ReferrerQuery { - query := (&ReferrerClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := o.ID - step := sqlgraph.NewStep( - sqlgraph.From(organization.Table, organization.FieldID, id), - sqlgraph.To(referrer.Table, referrer.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, organization.ReferrersTable, organization.ReferrersPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(o.driver.Dialect(), step) - return fromV, nil - } - return query -} - // Hooks returns the client hooks. func (c *OrganizationClient) Hooks() []Hook { return c.hooks.Organization @@ -1562,22 +1546,6 @@ func (c *ReferrerClient) QueryReferences(r *Referrer) *ReferrerQuery { return query } -// QueryOrganizations queries the organizations edge of a Referrer. -func (c *ReferrerClient) QueryOrganizations(r *Referrer) *OrganizationQuery { - query := (&OrganizationClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := r.ID - step := sqlgraph.NewStep( - sqlgraph.From(referrer.Table, referrer.FieldID, id), - sqlgraph.To(organization.Table, organization.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, referrer.OrganizationsTable, referrer.OrganizationsPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(r.driver.Dialect(), step) - return fromV, nil - } - return query -} - // QueryWorkflows queries the workflows edge of a Referrer. func (c *ReferrerClient) QueryWorkflows(r *Referrer) *WorkflowQuery { query := (&WorkflowClient{config: c.config}).Query() diff --git a/app/controlplane/internal/data/ent/migrate/migrations/20231116212408.sql b/app/controlplane/internal/data/ent/migrate/migrations/20231116212408.sql new file mode 100644 index 000000000..cce6ff77d --- /dev/null +++ b/app/controlplane/internal/data/ent/migrate/migrations/20231116212408.sql @@ -0,0 +1,2 @@ +-- Drop "referrer_organizations" table +DROP TABLE "referrer_organizations"; diff --git a/app/controlplane/internal/data/ent/migrate/migrations/atlas.sum b/app/controlplane/internal/data/ent/migrate/migrations/atlas.sum index d4a1be410..8ac6ff6e2 100644 --- a/app/controlplane/internal/data/ent/migrate/migrations/atlas.sum +++ b/app/controlplane/internal/data/ent/migrate/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:3NTOF1/OGPWxCCBP9WFNUhXL1nFJqAlfAqZTDZgR5Yo= +h1:MLJVZIiHXqeAWEvFgQZmST/oiRh1Cd8pCi5pTpuizmY= 20230706165452_init-schema.sql h1:VvqbNFEQnCvUVyj2iDYVQQxDM0+sSXqocpt/5H64k8M= 20230710111950-cas-backend.sql h1:A8iBuSzZIEbdsv9ipBtscZQuaBp3V5/VMw7eZH6GX+g= 20230712094107-cas-backends-workflow-runs.sql h1:a5rzxpVGyd56nLRSsKrmCFc9sebg65RWzLghKHh5xvI= @@ -14,3 +14,4 @@ h1:3NTOF1/OGPWxCCBP9WFNUhXL1nFJqAlfAqZTDZgR5Yo= 20231108214833.sql h1:qojrntcFArOidQQLDo2qns+zr3Y5BoJpfr2BvjCpRD0= 20231109101843.sql h1:lSRWGmd08/RoQSBWVUNb01f9tLDDS8YwFLcXq8WjDHs= 20231114215539.sql h1:eh74G4oPOP2sEDMgEk8DcDNgZFDyvI2SXYJM75F9mQM= +20231116212408.sql h1:c3gFbTtY86D5/0AlSh4T/NkLfMWBzWi3E+McX8rS0As= diff --git a/app/controlplane/internal/data/ent/migrate/schema.go b/app/controlplane/internal/data/ent/migrate/schema.go index 88ac94fd9..51e062ae7 100644 --- a/app/controlplane/internal/data/ent/migrate/schema.go +++ b/app/controlplane/internal/data/ent/migrate/schema.go @@ -426,31 +426,6 @@ var ( }, }, } - // ReferrerOrganizationsColumns holds the columns for the "referrer_organizations" table. - ReferrerOrganizationsColumns = []*schema.Column{ - {Name: "referrer_id", Type: field.TypeUUID}, - {Name: "organization_id", Type: field.TypeUUID}, - } - // ReferrerOrganizationsTable holds the schema information for the "referrer_organizations" table. - ReferrerOrganizationsTable = &schema.Table{ - Name: "referrer_organizations", - Columns: ReferrerOrganizationsColumns, - PrimaryKey: []*schema.Column{ReferrerOrganizationsColumns[0], ReferrerOrganizationsColumns[1]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "referrer_organizations_referrer_id", - Columns: []*schema.Column{ReferrerOrganizationsColumns[0]}, - RefColumns: []*schema.Column{ReferrersColumns[0]}, - OnDelete: schema.Cascade, - }, - { - Symbol: "referrer_organizations_organization_id", - Columns: []*schema.Column{ReferrerOrganizationsColumns[1]}, - RefColumns: []*schema.Column{OrganizationsColumns[0]}, - OnDelete: schema.Cascade, - }, - }, - } // ReferrerWorkflowsColumns holds the columns for the "referrer_workflows" table. ReferrerWorkflowsColumns = []*schema.Column{ {Name: "referrer_id", Type: field.TypeUUID}, @@ -518,7 +493,6 @@ var ( WorkflowContractVersionsTable, WorkflowRunsTable, ReferrerReferencesTable, - ReferrerOrganizationsTable, ReferrerWorkflowsTable, WorkflowRunCasBackendsTable, } @@ -546,8 +520,6 @@ func init() { WorkflowRunsTable.ForeignKeys[2].RefTable = WorkflowContractVersionsTable ReferrerReferencesTable.ForeignKeys[0].RefTable = ReferrersTable ReferrerReferencesTable.ForeignKeys[1].RefTable = ReferrersTable - ReferrerOrganizationsTable.ForeignKeys[0].RefTable = ReferrersTable - ReferrerOrganizationsTable.ForeignKeys[1].RefTable = OrganizationsTable ReferrerWorkflowsTable.ForeignKeys[0].RefTable = ReferrersTable ReferrerWorkflowsTable.ForeignKeys[1].RefTable = WorkflowsTable WorkflowRunCasBackendsTable.ForeignKeys[0].RefTable = WorkflowRunsTable diff --git a/app/controlplane/internal/data/ent/mutation.go b/app/controlplane/internal/data/ent/mutation.go index a6499d27f..6efa89f28 100644 --- a/app/controlplane/internal/data/ent/mutation.go +++ b/app/controlplane/internal/data/ent/mutation.go @@ -4371,9 +4371,6 @@ type OrganizationMutation struct { integrations map[uuid.UUID]struct{} removedintegrations map[uuid.UUID]struct{} clearedintegrations bool - referrers map[uuid.UUID]struct{} - removedreferrers map[uuid.UUID]struct{} - clearedreferrers bool done bool oldValue func(context.Context) (*Organization, error) predicates []predicate.Organization @@ -4825,60 +4822,6 @@ func (m *OrganizationMutation) ResetIntegrations() { m.removedintegrations = nil } -// AddReferrerIDs adds the "referrers" edge to the Referrer entity by ids. -func (m *OrganizationMutation) AddReferrerIDs(ids ...uuid.UUID) { - if m.referrers == nil { - m.referrers = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.referrers[ids[i]] = struct{}{} - } -} - -// ClearReferrers clears the "referrers" edge to the Referrer entity. -func (m *OrganizationMutation) ClearReferrers() { - m.clearedreferrers = true -} - -// ReferrersCleared reports if the "referrers" edge to the Referrer entity was cleared. -func (m *OrganizationMutation) ReferrersCleared() bool { - return m.clearedreferrers -} - -// RemoveReferrerIDs removes the "referrers" edge to the Referrer entity by IDs. -func (m *OrganizationMutation) RemoveReferrerIDs(ids ...uuid.UUID) { - if m.removedreferrers == nil { - m.removedreferrers = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.referrers, ids[i]) - m.removedreferrers[ids[i]] = struct{}{} - } -} - -// RemovedReferrers returns the removed IDs of the "referrers" edge to the Referrer entity. -func (m *OrganizationMutation) RemovedReferrersIDs() (ids []uuid.UUID) { - for id := range m.removedreferrers { - ids = append(ids, id) - } - return -} - -// ReferrersIDs returns the "referrers" edge IDs in the mutation. -func (m *OrganizationMutation) ReferrersIDs() (ids []uuid.UUID) { - for id := range m.referrers { - ids = append(ids, id) - } - return -} - -// ResetReferrers resets all changes to the "referrers" edge. -func (m *OrganizationMutation) ResetReferrers() { - m.referrers = nil - m.clearedreferrers = false - m.removedreferrers = nil -} - // Where appends a list predicates to the OrganizationMutation builder. func (m *OrganizationMutation) Where(ps ...predicate.Organization) { m.predicates = append(m.predicates, ps...) @@ -5029,7 +4972,7 @@ func (m *OrganizationMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *OrganizationMutation) AddedEdges() []string { - edges := make([]string, 0, 6) + edges := make([]string, 0, 5) if m.memberships != nil { edges = append(edges, organization.EdgeMemberships) } @@ -5045,9 +4988,6 @@ func (m *OrganizationMutation) AddedEdges() []string { if m.integrations != nil { edges = append(edges, organization.EdgeIntegrations) } - if m.referrers != nil { - edges = append(edges, organization.EdgeReferrers) - } return edges } @@ -5085,19 +5025,13 @@ func (m *OrganizationMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case organization.EdgeReferrers: - ids := make([]ent.Value, 0, len(m.referrers)) - for id := range m.referrers { - ids = append(ids, id) - } - return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *OrganizationMutation) RemovedEdges() []string { - edges := make([]string, 0, 6) + edges := make([]string, 0, 5) if m.removedmemberships != nil { edges = append(edges, organization.EdgeMemberships) } @@ -5113,9 +5047,6 @@ func (m *OrganizationMutation) RemovedEdges() []string { if m.removedintegrations != nil { edges = append(edges, organization.EdgeIntegrations) } - if m.removedreferrers != nil { - edges = append(edges, organization.EdgeReferrers) - } return edges } @@ -5153,19 +5084,13 @@ func (m *OrganizationMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case organization.EdgeReferrers: - ids := make([]ent.Value, 0, len(m.removedreferrers)) - for id := range m.removedreferrers { - ids = append(ids, id) - } - return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *OrganizationMutation) ClearedEdges() []string { - edges := make([]string, 0, 6) + edges := make([]string, 0, 5) if m.clearedmemberships { edges = append(edges, organization.EdgeMemberships) } @@ -5181,9 +5106,6 @@ func (m *OrganizationMutation) ClearedEdges() []string { if m.clearedintegrations { edges = append(edges, organization.EdgeIntegrations) } - if m.clearedreferrers { - edges = append(edges, organization.EdgeReferrers) - } return edges } @@ -5201,8 +5123,6 @@ func (m *OrganizationMutation) EdgeCleared(name string) bool { return m.clearedcas_backends case organization.EdgeIntegrations: return m.clearedintegrations - case organization.EdgeReferrers: - return m.clearedreferrers } return false } @@ -5234,9 +5154,6 @@ func (m *OrganizationMutation) ResetEdge(name string) error { case organization.EdgeIntegrations: m.ResetIntegrations() return nil - case organization.EdgeReferrers: - m.ResetReferrers() - return nil } return fmt.Errorf("unknown Organization edge %s", name) } @@ -5244,29 +5161,26 @@ func (m *OrganizationMutation) ResetEdge(name string) error { // ReferrerMutation represents an operation that mutates the Referrer nodes in the graph. type ReferrerMutation struct { config - op Op - typ string - id *uuid.UUID - digest *string - kind *string - downloadable *bool - created_at *time.Time - clearedFields map[string]struct{} - referred_by map[uuid.UUID]struct{} - removedreferred_by map[uuid.UUID]struct{} - clearedreferred_by bool - references map[uuid.UUID]struct{} - removedreferences map[uuid.UUID]struct{} - clearedreferences bool - organizations map[uuid.UUID]struct{} - removedorganizations map[uuid.UUID]struct{} - clearedorganizations bool - workflows map[uuid.UUID]struct{} - removedworkflows map[uuid.UUID]struct{} - clearedworkflows bool - done bool - oldValue func(context.Context) (*Referrer, error) - predicates []predicate.Referrer + op Op + typ string + id *uuid.UUID + digest *string + kind *string + downloadable *bool + created_at *time.Time + clearedFields map[string]struct{} + referred_by map[uuid.UUID]struct{} + removedreferred_by map[uuid.UUID]struct{} + clearedreferred_by bool + references map[uuid.UUID]struct{} + removedreferences map[uuid.UUID]struct{} + clearedreferences bool + workflows map[uuid.UUID]struct{} + removedworkflows map[uuid.UUID]struct{} + clearedworkflows bool + done bool + oldValue func(context.Context) (*Referrer, error) + predicates []predicate.Referrer } var _ ent.Mutation = (*ReferrerMutation)(nil) @@ -5625,60 +5539,6 @@ func (m *ReferrerMutation) ResetReferences() { m.removedreferences = nil } -// AddOrganizationIDs adds the "organizations" edge to the Organization entity by ids. -func (m *ReferrerMutation) AddOrganizationIDs(ids ...uuid.UUID) { - if m.organizations == nil { - m.organizations = make(map[uuid.UUID]struct{}) - } - for i := range ids { - m.organizations[ids[i]] = struct{}{} - } -} - -// ClearOrganizations clears the "organizations" edge to the Organization entity. -func (m *ReferrerMutation) ClearOrganizations() { - m.clearedorganizations = true -} - -// OrganizationsCleared reports if the "organizations" edge to the Organization entity was cleared. -func (m *ReferrerMutation) OrganizationsCleared() bool { - return m.clearedorganizations -} - -// RemoveOrganizationIDs removes the "organizations" edge to the Organization entity by IDs. -func (m *ReferrerMutation) RemoveOrganizationIDs(ids ...uuid.UUID) { - if m.removedorganizations == nil { - m.removedorganizations = make(map[uuid.UUID]struct{}) - } - for i := range ids { - delete(m.organizations, ids[i]) - m.removedorganizations[ids[i]] = struct{}{} - } -} - -// RemovedOrganizations returns the removed IDs of the "organizations" edge to the Organization entity. -func (m *ReferrerMutation) RemovedOrganizationsIDs() (ids []uuid.UUID) { - for id := range m.removedorganizations { - ids = append(ids, id) - } - return -} - -// OrganizationsIDs returns the "organizations" edge IDs in the mutation. -func (m *ReferrerMutation) OrganizationsIDs() (ids []uuid.UUID) { - for id := range m.organizations { - ids = append(ids, id) - } - return -} - -// ResetOrganizations resets all changes to the "organizations" edge. -func (m *ReferrerMutation) ResetOrganizations() { - m.organizations = nil - m.clearedorganizations = false - m.removedorganizations = nil -} - // AddWorkflowIDs adds the "workflows" edge to the Workflow entity by ids. func (m *ReferrerMutation) AddWorkflowIDs(ids ...uuid.UUID) { if m.workflows == nil { @@ -5917,16 +5777,13 @@ func (m *ReferrerMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *ReferrerMutation) AddedEdges() []string { - edges := make([]string, 0, 4) + edges := make([]string, 0, 3) if m.referred_by != nil { edges = append(edges, referrer.EdgeReferredBy) } if m.references != nil { edges = append(edges, referrer.EdgeReferences) } - if m.organizations != nil { - edges = append(edges, referrer.EdgeOrganizations) - } if m.workflows != nil { edges = append(edges, referrer.EdgeWorkflows) } @@ -5949,12 +5806,6 @@ func (m *ReferrerMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case referrer.EdgeOrganizations: - ids := make([]ent.Value, 0, len(m.organizations)) - for id := range m.organizations { - ids = append(ids, id) - } - return ids case referrer.EdgeWorkflows: ids := make([]ent.Value, 0, len(m.workflows)) for id := range m.workflows { @@ -5967,16 +5818,13 @@ func (m *ReferrerMutation) AddedIDs(name string) []ent.Value { // RemovedEdges returns all edge names that were removed in this mutation. func (m *ReferrerMutation) RemovedEdges() []string { - edges := make([]string, 0, 4) + edges := make([]string, 0, 3) if m.removedreferred_by != nil { edges = append(edges, referrer.EdgeReferredBy) } if m.removedreferences != nil { edges = append(edges, referrer.EdgeReferences) } - if m.removedorganizations != nil { - edges = append(edges, referrer.EdgeOrganizations) - } if m.removedworkflows != nil { edges = append(edges, referrer.EdgeWorkflows) } @@ -5999,12 +5847,6 @@ func (m *ReferrerMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids - case referrer.EdgeOrganizations: - ids := make([]ent.Value, 0, len(m.removedorganizations)) - for id := range m.removedorganizations { - ids = append(ids, id) - } - return ids case referrer.EdgeWorkflows: ids := make([]ent.Value, 0, len(m.removedworkflows)) for id := range m.removedworkflows { @@ -6017,16 +5859,13 @@ func (m *ReferrerMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *ReferrerMutation) ClearedEdges() []string { - edges := make([]string, 0, 4) + edges := make([]string, 0, 3) if m.clearedreferred_by { edges = append(edges, referrer.EdgeReferredBy) } if m.clearedreferences { edges = append(edges, referrer.EdgeReferences) } - if m.clearedorganizations { - edges = append(edges, referrer.EdgeOrganizations) - } if m.clearedworkflows { edges = append(edges, referrer.EdgeWorkflows) } @@ -6041,8 +5880,6 @@ func (m *ReferrerMutation) EdgeCleared(name string) bool { return m.clearedreferred_by case referrer.EdgeReferences: return m.clearedreferences - case referrer.EdgeOrganizations: - return m.clearedorganizations case referrer.EdgeWorkflows: return m.clearedworkflows } @@ -6067,9 +5904,6 @@ func (m *ReferrerMutation) ResetEdge(name string) error { case referrer.EdgeReferences: m.ResetReferences() return nil - case referrer.EdgeOrganizations: - m.ResetOrganizations() - return nil case referrer.EdgeWorkflows: m.ResetWorkflows() return nil @@ -7621,6 +7455,42 @@ func (m *WorkflowMutation) ResetPublic() { m.public = nil } +// SetOrganizationID sets the "organization_id" field. +func (m *WorkflowMutation) SetOrganizationID(u uuid.UUID) { + m.organization = &u +} + +// OrganizationID returns the value of the "organization_id" field in the mutation. +func (m *WorkflowMutation) OrganizationID() (r uuid.UUID, exists bool) { + v := m.organization + if v == nil { + return + } + return *v, true +} + +// OldOrganizationID returns the old "organization_id" field's value of the Workflow entity. +// If the Workflow object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WorkflowMutation) OldOrganizationID(ctx context.Context) (v uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOrganizationID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err) + } + return oldValue.OrganizationID, nil +} + +// ResetOrganizationID resets all changes to the "organization_id" field. +func (m *WorkflowMutation) ResetOrganizationID() { + m.organization = nil +} + // AddRobotaccountIDs adds the "robotaccounts" edge to the RobotAccount entity by ids. func (m *WorkflowMutation) AddRobotaccountIDs(ids ...uuid.UUID) { if m.robotaccounts == nil { @@ -7729,11 +7599,6 @@ func (m *WorkflowMutation) ResetWorkflowruns() { m.removedworkflowruns = nil } -// SetOrganizationID sets the "organization" edge to the Organization entity by id. -func (m *WorkflowMutation) SetOrganizationID(id uuid.UUID) { - m.organization = &id -} - // ClearOrganization clears the "organization" edge to the Organization entity. func (m *WorkflowMutation) ClearOrganization() { m.clearedorganization = true @@ -7744,14 +7609,6 @@ func (m *WorkflowMutation) OrganizationCleared() bool { return m.clearedorganization } -// OrganizationID returns the "organization" edge ID in the mutation. -func (m *WorkflowMutation) OrganizationID() (id uuid.UUID, exists bool) { - if m.organization != nil { - return *m.organization, true - } - return -} - // OrganizationIDs returns the "organization" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // OrganizationID instead. It exists only for internal usage by the builders. @@ -7949,7 +7806,7 @@ func (m *WorkflowMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *WorkflowMutation) Fields() []string { - fields := make([]string, 0, 7) + fields := make([]string, 0, 8) if m.name != nil { fields = append(fields, workflow.FieldName) } @@ -7971,6 +7828,9 @@ func (m *WorkflowMutation) Fields() []string { if m.public != nil { fields = append(fields, workflow.FieldPublic) } + if m.organization != nil { + fields = append(fields, workflow.FieldOrganizationID) + } return fields } @@ -7993,6 +7853,8 @@ func (m *WorkflowMutation) Field(name string) (ent.Value, bool) { return m.DeletedAt() case workflow.FieldPublic: return m.Public() + case workflow.FieldOrganizationID: + return m.OrganizationID() } return nil, false } @@ -8016,6 +7878,8 @@ func (m *WorkflowMutation) OldField(ctx context.Context, name string) (ent.Value return m.OldDeletedAt(ctx) case workflow.FieldPublic: return m.OldPublic(ctx) + case workflow.FieldOrganizationID: + return m.OldOrganizationID(ctx) } return nil, fmt.Errorf("unknown Workflow field %s", name) } @@ -8074,6 +7938,13 @@ func (m *WorkflowMutation) SetField(name string, value ent.Value) error { } m.SetPublic(v) return nil + case workflow.FieldOrganizationID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOrganizationID(v) + return nil } return fmt.Errorf("unknown Workflow field %s", name) } @@ -8180,6 +8051,9 @@ func (m *WorkflowMutation) ResetField(name string) error { case workflow.FieldPublic: m.ResetPublic() return nil + case workflow.FieldOrganizationID: + m.ResetOrganizationID() + return nil } return fmt.Errorf("unknown Workflow field %s", name) } diff --git a/app/controlplane/internal/data/ent/organization.go b/app/controlplane/internal/data/ent/organization.go index 3c2442b19..7930ab825 100644 --- a/app/controlplane/internal/data/ent/organization.go +++ b/app/controlplane/internal/data/ent/organization.go @@ -40,11 +40,9 @@ type OrganizationEdges struct { CasBackends []*CASBackend `json:"cas_backends,omitempty"` // Integrations holds the value of the integrations edge. Integrations []*Integration `json:"integrations,omitempty"` - // Referrers holds the value of the referrers edge. - Referrers []*Referrer `json:"referrers,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [6]bool + loadedTypes [5]bool } // MembershipsOrErr returns the Memberships value or an error if the edge @@ -92,15 +90,6 @@ func (e OrganizationEdges) IntegrationsOrErr() ([]*Integration, error) { return nil, &NotLoadedError{edge: "integrations"} } -// ReferrersOrErr returns the Referrers value or an error if the edge -// was not loaded in eager-loading. -func (e OrganizationEdges) ReferrersOrErr() ([]*Referrer, error) { - if e.loadedTypes[5] { - return e.Referrers, nil - } - return nil, &NotLoadedError{edge: "referrers"} -} - // scanValues returns the types for scanning values from sql.Rows. func (*Organization) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -183,11 +172,6 @@ func (o *Organization) QueryIntegrations() *IntegrationQuery { return NewOrganizationClient(o.config).QueryIntegrations(o) } -// QueryReferrers queries the "referrers" edge of the Organization entity. -func (o *Organization) QueryReferrers() *ReferrerQuery { - return NewOrganizationClient(o.config).QueryReferrers(o) -} - // Update returns a builder for updating this Organization. // Note that you need to call Organization.Unwrap() before calling this method if this Organization // was returned from a transaction, and the transaction was committed or rolled back. diff --git a/app/controlplane/internal/data/ent/organization/organization.go b/app/controlplane/internal/data/ent/organization/organization.go index 08b8c1955..5c1ccaf97 100644 --- a/app/controlplane/internal/data/ent/organization/organization.go +++ b/app/controlplane/internal/data/ent/organization/organization.go @@ -29,8 +29,6 @@ const ( EdgeCasBackends = "cas_backends" // EdgeIntegrations holds the string denoting the integrations edge name in mutations. EdgeIntegrations = "integrations" - // EdgeReferrers holds the string denoting the referrers edge name in mutations. - EdgeReferrers = "referrers" // Table holds the table name of the organization in the database. Table = "organizations" // MembershipsTable is the table that holds the memberships relation/edge. @@ -68,11 +66,6 @@ const ( IntegrationsInverseTable = "integrations" // IntegrationsColumn is the table column denoting the integrations relation/edge. IntegrationsColumn = "organization_integrations" - // ReferrersTable is the table that holds the referrers relation/edge. The primary key declared below. - ReferrersTable = "referrer_organizations" - // ReferrersInverseTable is the table name for the Referrer entity. - // It exists in this package in order to avoid circular dependency with the "referrer" package. - ReferrersInverseTable = "referrers" ) // Columns holds all SQL columns for organization fields. @@ -82,12 +75,6 @@ var Columns = []string{ FieldCreatedAt, } -var ( - // ReferrersPrimaryKey and ReferrersColumn2 are the table columns denoting the - // primary key for the referrers relation (M2M). - ReferrersPrimaryKey = []string{"referrer_id", "organization_id"} -) - // ValidColumn reports if the column name is valid (part of the table columns). func ValidColumn(column string) bool { for i := range Columns { @@ -194,20 +181,6 @@ func ByIntegrations(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { sqlgraph.OrderByNeighborTerms(s, newIntegrationsStep(), append([]sql.OrderTerm{term}, terms...)...) } } - -// ByReferrersCount orders the results by referrers count. -func ByReferrersCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newReferrersStep(), opts...) - } -} - -// ByReferrers orders the results by referrers terms. -func ByReferrers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newReferrersStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} func newMembershipsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -243,10 +216,3 @@ func newIntegrationsStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, false, IntegrationsTable, IntegrationsColumn), ) } -func newReferrersStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(ReferrersInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, ReferrersTable, ReferrersPrimaryKey...), - ) -} diff --git a/app/controlplane/internal/data/ent/organization/where.go b/app/controlplane/internal/data/ent/organization/where.go index c3e3060a4..292eb826b 100644 --- a/app/controlplane/internal/data/ent/organization/where.go +++ b/app/controlplane/internal/data/ent/organization/where.go @@ -286,29 +286,6 @@ func HasIntegrationsWith(preds ...predicate.Integration) predicate.Organization }) } -// HasReferrers applies the HasEdge predicate on the "referrers" edge. -func HasReferrers() predicate.Organization { - return predicate.Organization(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, ReferrersTable, ReferrersPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasReferrersWith applies the HasEdge predicate on the "referrers" edge with a given conditions (other predicates). -func HasReferrersWith(preds ...predicate.Referrer) predicate.Organization { - return predicate.Organization(func(s *sql.Selector) { - step := newReferrersStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - // And groups predicates with the AND operator between them. func And(predicates ...predicate.Organization) predicate.Organization { return predicate.Organization(func(s *sql.Selector) { diff --git a/app/controlplane/internal/data/ent/organization_create.go b/app/controlplane/internal/data/ent/organization_create.go index 2970a8208..74c3634c3 100644 --- a/app/controlplane/internal/data/ent/organization_create.go +++ b/app/controlplane/internal/data/ent/organization_create.go @@ -14,7 +14,6 @@ import ( "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/integration" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/membership" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/organization" - "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/referrer" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/workflow" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/workflowcontract" "github.com/google/uuid" @@ -144,21 +143,6 @@ func (oc *OrganizationCreate) AddIntegrations(i ...*Integration) *OrganizationCr return oc.AddIntegrationIDs(ids...) } -// AddReferrerIDs adds the "referrers" edge to the Referrer entity by IDs. -func (oc *OrganizationCreate) AddReferrerIDs(ids ...uuid.UUID) *OrganizationCreate { - oc.mutation.AddReferrerIDs(ids...) - return oc -} - -// AddReferrers adds the "referrers" edges to the Referrer entity. -func (oc *OrganizationCreate) AddReferrers(r ...*Referrer) *OrganizationCreate { - ids := make([]uuid.UUID, len(r)) - for i := range r { - ids[i] = r[i].ID - } - return oc.AddReferrerIDs(ids...) -} - // Mutation returns the OrganizationMutation object of the builder. func (oc *OrganizationCreate) Mutation() *OrganizationMutation { return oc.mutation @@ -339,22 +323,6 @@ func (oc *OrganizationCreate) createSpec() (*Organization, *sqlgraph.CreateSpec) } _spec.Edges = append(_spec.Edges, edge) } - if nodes := oc.mutation.ReferrersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: organization.ReferrersTable, - Columns: organization.ReferrersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(referrer.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } return _node, _spec } diff --git a/app/controlplane/internal/data/ent/organization_query.go b/app/controlplane/internal/data/ent/organization_query.go index af1f515c2..ebdf5a4c7 100644 --- a/app/controlplane/internal/data/ent/organization_query.go +++ b/app/controlplane/internal/data/ent/organization_query.go @@ -16,7 +16,6 @@ import ( "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/membership" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/organization" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/predicate" - "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/referrer" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/workflow" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/workflowcontract" "github.com/google/uuid" @@ -34,7 +33,6 @@ type OrganizationQuery struct { withWorkflows *WorkflowQuery withCasBackends *CASBackendQuery withIntegrations *IntegrationQuery - withReferrers *ReferrerQuery // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -181,28 +179,6 @@ func (oq *OrganizationQuery) QueryIntegrations() *IntegrationQuery { return query } -// QueryReferrers chains the current query on the "referrers" edge. -func (oq *OrganizationQuery) QueryReferrers() *ReferrerQuery { - query := (&ReferrerClient{config: oq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := oq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := oq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(organization.Table, organization.FieldID, selector), - sqlgraph.To(referrer.Table, referrer.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, organization.ReferrersTable, organization.ReferrersPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(oq.driver.Dialect(), step) - return fromU, nil - } - return query -} - // First returns the first Organization entity from the query. // Returns a *NotFoundError when no Organization was found. func (oq *OrganizationQuery) First(ctx context.Context) (*Organization, error) { @@ -400,7 +376,6 @@ func (oq *OrganizationQuery) Clone() *OrganizationQuery { withWorkflows: oq.withWorkflows.Clone(), withCasBackends: oq.withCasBackends.Clone(), withIntegrations: oq.withIntegrations.Clone(), - withReferrers: oq.withReferrers.Clone(), // clone intermediate query. sql: oq.sql.Clone(), path: oq.path, @@ -462,17 +437,6 @@ func (oq *OrganizationQuery) WithIntegrations(opts ...func(*IntegrationQuery)) * return oq } -// WithReferrers tells the query-builder to eager-load the nodes that are connected to -// the "referrers" edge. The optional arguments are used to configure the query builder of the edge. -func (oq *OrganizationQuery) WithReferrers(opts ...func(*ReferrerQuery)) *OrganizationQuery { - query := (&ReferrerClient{config: oq.config}).Query() - for _, opt := range opts { - opt(query) - } - oq.withReferrers = query - return oq -} - // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -551,13 +515,12 @@ func (oq *OrganizationQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([] var ( nodes = []*Organization{} _spec = oq.querySpec() - loadedTypes = [6]bool{ + loadedTypes = [5]bool{ oq.withMemberships != nil, oq.withWorkflowContracts != nil, oq.withWorkflows != nil, oq.withCasBackends != nil, oq.withIntegrations != nil, - oq.withReferrers != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { @@ -615,13 +578,6 @@ func (oq *OrganizationQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([] return nil, err } } - if query := oq.withReferrers; query != nil { - if err := oq.loadReferrers(ctx, query, nodes, - func(n *Organization) { n.Edges.Referrers = []*Referrer{} }, - func(n *Organization, e *Referrer) { n.Edges.Referrers = append(n.Edges.Referrers, e) }); err != nil { - return nil, err - } - } return nodes, nil } @@ -698,6 +654,9 @@ func (oq *OrganizationQuery) loadWorkflows(ctx context.Context, query *WorkflowQ } } query.withFKs = true + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(workflow.FieldOrganizationID) + } query.Where(predicate.Workflow(func(s *sql.Selector) { s.Where(sql.InValues(s.C(organization.WorkflowsColumn), fks...)) })) @@ -706,13 +665,10 @@ func (oq *OrganizationQuery) loadWorkflows(ctx context.Context, query *WorkflowQ return err } for _, n := range neighbors { - fk := n.organization_id - if fk == nil { - return fmt.Errorf(`foreign-key "organization_id" is nil for node %v`, n.ID) - } - node, ok := nodeids[*fk] + fk := n.OrganizationID + node, ok := nodeids[fk] if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "organization_id" returned %v for node %v`, *fk, n.ID) + return fmt.Errorf(`unexpected referenced foreign-key "organization_id" returned %v for node %v`, fk, n.ID) } assign(node, n) } @@ -780,67 +736,6 @@ func (oq *OrganizationQuery) loadIntegrations(ctx context.Context, query *Integr } return nil } -func (oq *OrganizationQuery) loadReferrers(ctx context.Context, query *ReferrerQuery, nodes []*Organization, init func(*Organization), assign func(*Organization, *Referrer)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[uuid.UUID]*Organization) - nids := make(map[uuid.UUID]map[*Organization]struct{}) - for i, node := range nodes { - edgeIDs[i] = node.ID - byID[node.ID] = node - if init != nil { - init(node) - } - } - query.Where(func(s *sql.Selector) { - joinT := sql.Table(organization.ReferrersTable) - s.Join(joinT).On(s.C(referrer.FieldID), joinT.C(organization.ReferrersPrimaryKey[0])) - s.Where(sql.InValues(joinT.C(organization.ReferrersPrimaryKey[1]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(organization.ReferrersPrimaryKey[1])) - s.AppendSelect(columns...) - s.SetDistinct(false) - }) - if err := query.prepareQuery(ctx); err != nil { - return err - } - qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { - return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { - assign := spec.Assign - values := spec.ScanValues - spec.ScanValues = func(columns []string) ([]any, error) { - values, err := values(columns[1:]) - if err != nil { - return nil, err - } - return append([]any{new(uuid.UUID)}, values...), nil - } - spec.Assign = func(columns []string, values []any) error { - outValue := *values[0].(*uuid.UUID) - inValue := *values[1].(*uuid.UUID) - if nids[inValue] == nil { - nids[inValue] = map[*Organization]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*Referrer](ctx, query, qr, query.inters) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nids[n.ID] - if !ok { - return fmt.Errorf(`unexpected "referrers" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} func (oq *OrganizationQuery) sqlCount(ctx context.Context) (int, error) { _spec := oq.querySpec() diff --git a/app/controlplane/internal/data/ent/organization_update.go b/app/controlplane/internal/data/ent/organization_update.go index 750242de6..a2ab8e2e3 100644 --- a/app/controlplane/internal/data/ent/organization_update.go +++ b/app/controlplane/internal/data/ent/organization_update.go @@ -15,7 +15,6 @@ import ( "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/membership" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/organization" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/predicate" - "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/referrer" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/workflow" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/workflowcontract" "github.com/google/uuid" @@ -123,21 +122,6 @@ func (ou *OrganizationUpdate) AddIntegrations(i ...*Integration) *OrganizationUp return ou.AddIntegrationIDs(ids...) } -// AddReferrerIDs adds the "referrers" edge to the Referrer entity by IDs. -func (ou *OrganizationUpdate) AddReferrerIDs(ids ...uuid.UUID) *OrganizationUpdate { - ou.mutation.AddReferrerIDs(ids...) - return ou -} - -// AddReferrers adds the "referrers" edges to the Referrer entity. -func (ou *OrganizationUpdate) AddReferrers(r ...*Referrer) *OrganizationUpdate { - ids := make([]uuid.UUID, len(r)) - for i := range r { - ids[i] = r[i].ID - } - return ou.AddReferrerIDs(ids...) -} - // Mutation returns the OrganizationMutation object of the builder. func (ou *OrganizationUpdate) Mutation() *OrganizationMutation { return ou.mutation @@ -248,27 +232,6 @@ func (ou *OrganizationUpdate) RemoveIntegrations(i ...*Integration) *Organizatio return ou.RemoveIntegrationIDs(ids...) } -// ClearReferrers clears all "referrers" edges to the Referrer entity. -func (ou *OrganizationUpdate) ClearReferrers() *OrganizationUpdate { - ou.mutation.ClearReferrers() - return ou -} - -// RemoveReferrerIDs removes the "referrers" edge to Referrer entities by IDs. -func (ou *OrganizationUpdate) RemoveReferrerIDs(ids ...uuid.UUID) *OrganizationUpdate { - ou.mutation.RemoveReferrerIDs(ids...) - return ou -} - -// RemoveReferrers removes "referrers" edges to Referrer entities. -func (ou *OrganizationUpdate) RemoveReferrers(r ...*Referrer) *OrganizationUpdate { - ids := make([]uuid.UUID, len(r)) - for i := range r { - ids[i] = r[i].ID - } - return ou.RemoveReferrerIDs(ids...) -} - // Save executes the query and returns the number of nodes affected by the update operation. func (ou *OrganizationUpdate) Save(ctx context.Context) (int, error) { return withHooks(ctx, ou.sqlSave, ou.mutation, ou.hooks) @@ -533,51 +496,6 @@ func (ou *OrganizationUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ou.mutation.ReferrersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: organization.ReferrersTable, - Columns: organization.ReferrersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(referrer.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := ou.mutation.RemovedReferrersIDs(); len(nodes) > 0 && !ou.mutation.ReferrersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: organization.ReferrersTable, - Columns: organization.ReferrersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(referrer.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := ou.mutation.ReferrersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: organization.ReferrersTable, - Columns: organization.ReferrersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(referrer.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } if n, err = sqlgraph.UpdateNodes(ctx, ou.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{organization.Label} @@ -687,21 +605,6 @@ func (ouo *OrganizationUpdateOne) AddIntegrations(i ...*Integration) *Organizati return ouo.AddIntegrationIDs(ids...) } -// AddReferrerIDs adds the "referrers" edge to the Referrer entity by IDs. -func (ouo *OrganizationUpdateOne) AddReferrerIDs(ids ...uuid.UUID) *OrganizationUpdateOne { - ouo.mutation.AddReferrerIDs(ids...) - return ouo -} - -// AddReferrers adds the "referrers" edges to the Referrer entity. -func (ouo *OrganizationUpdateOne) AddReferrers(r ...*Referrer) *OrganizationUpdateOne { - ids := make([]uuid.UUID, len(r)) - for i := range r { - ids[i] = r[i].ID - } - return ouo.AddReferrerIDs(ids...) -} - // Mutation returns the OrganizationMutation object of the builder. func (ouo *OrganizationUpdateOne) Mutation() *OrganizationMutation { return ouo.mutation @@ -812,27 +715,6 @@ func (ouo *OrganizationUpdateOne) RemoveIntegrations(i ...*Integration) *Organiz return ouo.RemoveIntegrationIDs(ids...) } -// ClearReferrers clears all "referrers" edges to the Referrer entity. -func (ouo *OrganizationUpdateOne) ClearReferrers() *OrganizationUpdateOne { - ouo.mutation.ClearReferrers() - return ouo -} - -// RemoveReferrerIDs removes the "referrers" edge to Referrer entities by IDs. -func (ouo *OrganizationUpdateOne) RemoveReferrerIDs(ids ...uuid.UUID) *OrganizationUpdateOne { - ouo.mutation.RemoveReferrerIDs(ids...) - return ouo -} - -// RemoveReferrers removes "referrers" edges to Referrer entities. -func (ouo *OrganizationUpdateOne) RemoveReferrers(r ...*Referrer) *OrganizationUpdateOne { - ids := make([]uuid.UUID, len(r)) - for i := range r { - ids[i] = r[i].ID - } - return ouo.RemoveReferrerIDs(ids...) -} - // Where appends a list predicates to the OrganizationUpdate builder. func (ouo *OrganizationUpdateOne) Where(ps ...predicate.Organization) *OrganizationUpdateOne { ouo.mutation.Where(ps...) @@ -1127,51 +1009,6 @@ func (ouo *OrganizationUpdateOne) sqlSave(ctx context.Context) (_node *Organizat } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ouo.mutation.ReferrersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: organization.ReferrersTable, - Columns: organization.ReferrersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(referrer.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := ouo.mutation.RemovedReferrersIDs(); len(nodes) > 0 && !ouo.mutation.ReferrersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: organization.ReferrersTable, - Columns: organization.ReferrersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(referrer.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := ouo.mutation.ReferrersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: organization.ReferrersTable, - Columns: organization.ReferrersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(referrer.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } _node = &Organization{config: ouo.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues diff --git a/app/controlplane/internal/data/ent/referrer.go b/app/controlplane/internal/data/ent/referrer.go index 1540e6952..833b56375 100644 --- a/app/controlplane/internal/data/ent/referrer.go +++ b/app/controlplane/internal/data/ent/referrer.go @@ -38,13 +38,11 @@ type ReferrerEdges struct { ReferredBy []*Referrer `json:"referred_by,omitempty"` // References holds the value of the references edge. References []*Referrer `json:"references,omitempty"` - // Organizations holds the value of the organizations edge. - Organizations []*Organization `json:"organizations,omitempty"` // Workflows holds the value of the workflows edge. Workflows []*Workflow `json:"workflows,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [4]bool + loadedTypes [3]bool } // ReferredByOrErr returns the ReferredBy value or an error if the edge @@ -65,19 +63,10 @@ func (e ReferrerEdges) ReferencesOrErr() ([]*Referrer, error) { return nil, &NotLoadedError{edge: "references"} } -// OrganizationsOrErr returns the Organizations value or an error if the edge -// was not loaded in eager-loading. -func (e ReferrerEdges) OrganizationsOrErr() ([]*Organization, error) { - if e.loadedTypes[2] { - return e.Organizations, nil - } - return nil, &NotLoadedError{edge: "organizations"} -} - // WorkflowsOrErr returns the Workflows value or an error if the edge // was not loaded in eager-loading. func (e ReferrerEdges) WorkflowsOrErr() ([]*Workflow, error) { - if e.loadedTypes[3] { + if e.loadedTypes[2] { return e.Workflows, nil } return nil, &NotLoadedError{edge: "workflows"} @@ -164,11 +153,6 @@ func (r *Referrer) QueryReferences() *ReferrerQuery { return NewReferrerClient(r.config).QueryReferences(r) } -// QueryOrganizations queries the "organizations" edge of the Referrer entity. -func (r *Referrer) QueryOrganizations() *OrganizationQuery { - return NewReferrerClient(r.config).QueryOrganizations(r) -} - // QueryWorkflows queries the "workflows" edge of the Referrer entity. func (r *Referrer) QueryWorkflows() *WorkflowQuery { return NewReferrerClient(r.config).QueryWorkflows(r) diff --git a/app/controlplane/internal/data/ent/referrer/referrer.go b/app/controlplane/internal/data/ent/referrer/referrer.go index 3991c090a..d63a8fae5 100644 --- a/app/controlplane/internal/data/ent/referrer/referrer.go +++ b/app/controlplane/internal/data/ent/referrer/referrer.go @@ -27,8 +27,6 @@ const ( EdgeReferredBy = "referred_by" // EdgeReferences holds the string denoting the references edge name in mutations. EdgeReferences = "references" - // EdgeOrganizations holds the string denoting the organizations edge name in mutations. - EdgeOrganizations = "organizations" // EdgeWorkflows holds the string denoting the workflows edge name in mutations. EdgeWorkflows = "workflows" // Table holds the table name of the referrer in the database. @@ -37,11 +35,6 @@ const ( ReferredByTable = "referrer_references" // ReferencesTable is the table that holds the references relation/edge. The primary key declared below. ReferencesTable = "referrer_references" - // OrganizationsTable is the table that holds the organizations relation/edge. The primary key declared below. - OrganizationsTable = "referrer_organizations" - // OrganizationsInverseTable is the table name for the Organization entity. - // It exists in this package in order to avoid circular dependency with the "organization" package. - OrganizationsInverseTable = "organizations" // WorkflowsTable is the table that holds the workflows relation/edge. The primary key declared below. WorkflowsTable = "referrer_workflows" // WorkflowsInverseTable is the table name for the Workflow entity. @@ -65,9 +58,6 @@ var ( // ReferencesPrimaryKey and ReferencesColumn2 are the table columns denoting the // primary key for the references relation (M2M). ReferencesPrimaryKey = []string{"referrer_id", "referred_by_id"} - // OrganizationsPrimaryKey and OrganizationsColumn2 are the table columns denoting the - // primary key for the organizations relation (M2M). - OrganizationsPrimaryKey = []string{"referrer_id", "organization_id"} // WorkflowsPrimaryKey and WorkflowsColumn2 are the table columns denoting the // primary key for the workflows relation (M2M). WorkflowsPrimaryKey = []string{"referrer_id", "workflow_id"} @@ -146,20 +136,6 @@ func ByReferences(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { } } -// ByOrganizationsCount orders the results by organizations count. -func ByOrganizationsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newOrganizationsStep(), opts...) - } -} - -// ByOrganizations orders the results by organizations terms. -func ByOrganizations(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newOrganizationsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - // ByWorkflowsCount orders the results by workflows count. func ByWorkflowsCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { @@ -187,13 +163,6 @@ func newReferencesStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.M2M, false, ReferencesTable, ReferencesPrimaryKey...), ) } -func newOrganizationsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(OrganizationsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, OrganizationsTable, OrganizationsPrimaryKey...), - ) -} func newWorkflowsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), diff --git a/app/controlplane/internal/data/ent/referrer/where.go b/app/controlplane/internal/data/ent/referrer/where.go index aeabce292..8d8474aca 100644 --- a/app/controlplane/internal/data/ent/referrer/where.go +++ b/app/controlplane/internal/data/ent/referrer/where.go @@ -302,29 +302,6 @@ func HasReferencesWith(preds ...predicate.Referrer) predicate.Referrer { }) } -// HasOrganizations applies the HasEdge predicate on the "organizations" edge. -func HasOrganizations() predicate.Referrer { - return predicate.Referrer(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, OrganizationsTable, OrganizationsPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasOrganizationsWith applies the HasEdge predicate on the "organizations" edge with a given conditions (other predicates). -func HasOrganizationsWith(preds ...predicate.Organization) predicate.Referrer { - return predicate.Referrer(func(s *sql.Selector) { - step := newOrganizationsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - // HasWorkflows applies the HasEdge predicate on the "workflows" edge. func HasWorkflows() predicate.Referrer { return predicate.Referrer(func(s *sql.Selector) { diff --git a/app/controlplane/internal/data/ent/referrer_create.go b/app/controlplane/internal/data/ent/referrer_create.go index fd52ff838..5cd8bd526 100644 --- a/app/controlplane/internal/data/ent/referrer_create.go +++ b/app/controlplane/internal/data/ent/referrer_create.go @@ -10,7 +10,6 @@ import ( "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/organization" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/referrer" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/workflow" "github.com/google/uuid" @@ -99,21 +98,6 @@ func (rc *ReferrerCreate) AddReferences(r ...*Referrer) *ReferrerCreate { return rc.AddReferenceIDs(ids...) } -// AddOrganizationIDs adds the "organizations" edge to the Organization entity by IDs. -func (rc *ReferrerCreate) AddOrganizationIDs(ids ...uuid.UUID) *ReferrerCreate { - rc.mutation.AddOrganizationIDs(ids...) - return rc -} - -// AddOrganizations adds the "organizations" edges to the Organization entity. -func (rc *ReferrerCreate) AddOrganizations(o ...*Organization) *ReferrerCreate { - ids := make([]uuid.UUID, len(o)) - for i := range o { - ids[i] = o[i].ID - } - return rc.AddOrganizationIDs(ids...) -} - // AddWorkflowIDs adds the "workflows" edge to the Workflow entity by IDs. func (rc *ReferrerCreate) AddWorkflowIDs(ids ...uuid.UUID) *ReferrerCreate { rc.mutation.AddWorkflowIDs(ids...) @@ -271,22 +255,6 @@ func (rc *ReferrerCreate) createSpec() (*Referrer, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := rc.mutation.OrganizationsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: referrer.OrganizationsTable, - Columns: referrer.OrganizationsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(organization.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } if nodes := rc.mutation.WorkflowsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, diff --git a/app/controlplane/internal/data/ent/referrer_query.go b/app/controlplane/internal/data/ent/referrer_query.go index 87fdde5f7..ef6bcf907 100644 --- a/app/controlplane/internal/data/ent/referrer_query.go +++ b/app/controlplane/internal/data/ent/referrer_query.go @@ -11,7 +11,6 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/organization" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/predicate" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/referrer" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/workflow" @@ -21,14 +20,13 @@ import ( // ReferrerQuery is the builder for querying Referrer entities. type ReferrerQuery struct { config - ctx *QueryContext - order []referrer.OrderOption - inters []Interceptor - predicates []predicate.Referrer - withReferredBy *ReferrerQuery - withReferences *ReferrerQuery - withOrganizations *OrganizationQuery - withWorkflows *WorkflowQuery + ctx *QueryContext + order []referrer.OrderOption + inters []Interceptor + predicates []predicate.Referrer + withReferredBy *ReferrerQuery + withReferences *ReferrerQuery + withWorkflows *WorkflowQuery // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -109,28 +107,6 @@ func (rq *ReferrerQuery) QueryReferences() *ReferrerQuery { return query } -// QueryOrganizations chains the current query on the "organizations" edge. -func (rq *ReferrerQuery) QueryOrganizations() *OrganizationQuery { - query := (&OrganizationClient{config: rq.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := rq.prepareQuery(ctx); err != nil { - return nil, err - } - selector := rq.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(referrer.Table, referrer.FieldID, selector), - sqlgraph.To(organization.Table, organization.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, referrer.OrganizationsTable, referrer.OrganizationsPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(rq.driver.Dialect(), step) - return fromU, nil - } - return query -} - // QueryWorkflows chains the current query on the "workflows" edge. func (rq *ReferrerQuery) QueryWorkflows() *WorkflowQuery { query := (&WorkflowClient{config: rq.config}).Query() @@ -340,15 +316,14 @@ func (rq *ReferrerQuery) Clone() *ReferrerQuery { return nil } return &ReferrerQuery{ - config: rq.config, - ctx: rq.ctx.Clone(), - order: append([]referrer.OrderOption{}, rq.order...), - inters: append([]Interceptor{}, rq.inters...), - predicates: append([]predicate.Referrer{}, rq.predicates...), - withReferredBy: rq.withReferredBy.Clone(), - withReferences: rq.withReferences.Clone(), - withOrganizations: rq.withOrganizations.Clone(), - withWorkflows: rq.withWorkflows.Clone(), + config: rq.config, + ctx: rq.ctx.Clone(), + order: append([]referrer.OrderOption{}, rq.order...), + inters: append([]Interceptor{}, rq.inters...), + predicates: append([]predicate.Referrer{}, rq.predicates...), + withReferredBy: rq.withReferredBy.Clone(), + withReferences: rq.withReferences.Clone(), + withWorkflows: rq.withWorkflows.Clone(), // clone intermediate query. sql: rq.sql.Clone(), path: rq.path, @@ -377,17 +352,6 @@ func (rq *ReferrerQuery) WithReferences(opts ...func(*ReferrerQuery)) *ReferrerQ return rq } -// WithOrganizations tells the query-builder to eager-load the nodes that are connected to -// the "organizations" edge. The optional arguments are used to configure the query builder of the edge. -func (rq *ReferrerQuery) WithOrganizations(opts ...func(*OrganizationQuery)) *ReferrerQuery { - query := (&OrganizationClient{config: rq.config}).Query() - for _, opt := range opts { - opt(query) - } - rq.withOrganizations = query - return rq -} - // WithWorkflows tells the query-builder to eager-load the nodes that are connected to // the "workflows" edge. The optional arguments are used to configure the query builder of the edge. func (rq *ReferrerQuery) WithWorkflows(opts ...func(*WorkflowQuery)) *ReferrerQuery { @@ -477,10 +441,9 @@ func (rq *ReferrerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Ref var ( nodes = []*Referrer{} _spec = rq.querySpec() - loadedTypes = [4]bool{ + loadedTypes = [3]bool{ rq.withReferredBy != nil, rq.withReferences != nil, - rq.withOrganizations != nil, rq.withWorkflows != nil, } ) @@ -516,13 +479,6 @@ func (rq *ReferrerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Ref return nil, err } } - if query := rq.withOrganizations; query != nil { - if err := rq.loadOrganizations(ctx, query, nodes, - func(n *Referrer) { n.Edges.Organizations = []*Organization{} }, - func(n *Referrer, e *Organization) { n.Edges.Organizations = append(n.Edges.Organizations, e) }); err != nil { - return nil, err - } - } if query := rq.withWorkflows; query != nil { if err := rq.loadWorkflows(ctx, query, nodes, func(n *Referrer) { n.Edges.Workflows = []*Workflow{} }, @@ -655,67 +611,6 @@ func (rq *ReferrerQuery) loadReferences(ctx context.Context, query *ReferrerQuer } return nil } -func (rq *ReferrerQuery) loadOrganizations(ctx context.Context, query *OrganizationQuery, nodes []*Referrer, init func(*Referrer), assign func(*Referrer, *Organization)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[uuid.UUID]*Referrer) - nids := make(map[uuid.UUID]map[*Referrer]struct{}) - for i, node := range nodes { - edgeIDs[i] = node.ID - byID[node.ID] = node - if init != nil { - init(node) - } - } - query.Where(func(s *sql.Selector) { - joinT := sql.Table(referrer.OrganizationsTable) - s.Join(joinT).On(s.C(organization.FieldID), joinT.C(referrer.OrganizationsPrimaryKey[1])) - s.Where(sql.InValues(joinT.C(referrer.OrganizationsPrimaryKey[0]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(referrer.OrganizationsPrimaryKey[0])) - s.AppendSelect(columns...) - s.SetDistinct(false) - }) - if err := query.prepareQuery(ctx); err != nil { - return err - } - qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { - return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { - assign := spec.Assign - values := spec.ScanValues - spec.ScanValues = func(columns []string) ([]any, error) { - values, err := values(columns[1:]) - if err != nil { - return nil, err - } - return append([]any{new(uuid.UUID)}, values...), nil - } - spec.Assign = func(columns []string, values []any) error { - outValue := *values[0].(*uuid.UUID) - inValue := *values[1].(*uuid.UUID) - if nids[inValue] == nil { - nids[inValue] = map[*Referrer]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*Organization](ctx, query, qr, query.inters) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nids[n.ID] - if !ok { - return fmt.Errorf(`unexpected "organizations" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} func (rq *ReferrerQuery) loadWorkflows(ctx context.Context, query *WorkflowQuery, nodes []*Referrer, init func(*Referrer), assign func(*Referrer, *Workflow)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[uuid.UUID]*Referrer) diff --git a/app/controlplane/internal/data/ent/referrer_update.go b/app/controlplane/internal/data/ent/referrer_update.go index 46f410fe8..91b5034a5 100644 --- a/app/controlplane/internal/data/ent/referrer_update.go +++ b/app/controlplane/internal/data/ent/referrer_update.go @@ -10,7 +10,6 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" - "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/organization" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/predicate" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/referrer" "github.com/chainloop-dev/chainloop/app/controlplane/internal/data/ent/workflow" @@ -45,21 +44,6 @@ func (ru *ReferrerUpdate) AddReferences(r ...*Referrer) *ReferrerUpdate { return ru.AddReferenceIDs(ids...) } -// AddOrganizationIDs adds the "organizations" edge to the Organization entity by IDs. -func (ru *ReferrerUpdate) AddOrganizationIDs(ids ...uuid.UUID) *ReferrerUpdate { - ru.mutation.AddOrganizationIDs(ids...) - return ru -} - -// AddOrganizations adds the "organizations" edges to the Organization entity. -func (ru *ReferrerUpdate) AddOrganizations(o ...*Organization) *ReferrerUpdate { - ids := make([]uuid.UUID, len(o)) - for i := range o { - ids[i] = o[i].ID - } - return ru.AddOrganizationIDs(ids...) -} - // AddWorkflowIDs adds the "workflows" edge to the Workflow entity by IDs. func (ru *ReferrerUpdate) AddWorkflowIDs(ids ...uuid.UUID) *ReferrerUpdate { ru.mutation.AddWorkflowIDs(ids...) @@ -101,27 +85,6 @@ func (ru *ReferrerUpdate) RemoveReferences(r ...*Referrer) *ReferrerUpdate { return ru.RemoveReferenceIDs(ids...) } -// ClearOrganizations clears all "organizations" edges to the Organization entity. -func (ru *ReferrerUpdate) ClearOrganizations() *ReferrerUpdate { - ru.mutation.ClearOrganizations() - return ru -} - -// RemoveOrganizationIDs removes the "organizations" edge to Organization entities by IDs. -func (ru *ReferrerUpdate) RemoveOrganizationIDs(ids ...uuid.UUID) *ReferrerUpdate { - ru.mutation.RemoveOrganizationIDs(ids...) - return ru -} - -// RemoveOrganizations removes "organizations" edges to Organization entities. -func (ru *ReferrerUpdate) RemoveOrganizations(o ...*Organization) *ReferrerUpdate { - ids := make([]uuid.UUID, len(o)) - for i := range o { - ids[i] = o[i].ID - } - return ru.RemoveOrganizationIDs(ids...) -} - // ClearWorkflows clears all "workflows" edges to the Workflow entity. func (ru *ReferrerUpdate) ClearWorkflows() *ReferrerUpdate { ru.mutation.ClearWorkflows() @@ -224,51 +187,6 @@ func (ru *ReferrerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ru.mutation.OrganizationsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: referrer.OrganizationsTable, - Columns: referrer.OrganizationsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(organization.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := ru.mutation.RemovedOrganizationsIDs(); len(nodes) > 0 && !ru.mutation.OrganizationsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: referrer.OrganizationsTable, - Columns: referrer.OrganizationsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(organization.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := ru.mutation.OrganizationsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: referrer.OrganizationsTable, - Columns: referrer.OrganizationsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(organization.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } if ru.mutation.WorkflowsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, @@ -349,21 +267,6 @@ func (ruo *ReferrerUpdateOne) AddReferences(r ...*Referrer) *ReferrerUpdateOne { return ruo.AddReferenceIDs(ids...) } -// AddOrganizationIDs adds the "organizations" edge to the Organization entity by IDs. -func (ruo *ReferrerUpdateOne) AddOrganizationIDs(ids ...uuid.UUID) *ReferrerUpdateOne { - ruo.mutation.AddOrganizationIDs(ids...) - return ruo -} - -// AddOrganizations adds the "organizations" edges to the Organization entity. -func (ruo *ReferrerUpdateOne) AddOrganizations(o ...*Organization) *ReferrerUpdateOne { - ids := make([]uuid.UUID, len(o)) - for i := range o { - ids[i] = o[i].ID - } - return ruo.AddOrganizationIDs(ids...) -} - // AddWorkflowIDs adds the "workflows" edge to the Workflow entity by IDs. func (ruo *ReferrerUpdateOne) AddWorkflowIDs(ids ...uuid.UUID) *ReferrerUpdateOne { ruo.mutation.AddWorkflowIDs(ids...) @@ -405,27 +308,6 @@ func (ruo *ReferrerUpdateOne) RemoveReferences(r ...*Referrer) *ReferrerUpdateOn return ruo.RemoveReferenceIDs(ids...) } -// ClearOrganizations clears all "organizations" edges to the Organization entity. -func (ruo *ReferrerUpdateOne) ClearOrganizations() *ReferrerUpdateOne { - ruo.mutation.ClearOrganizations() - return ruo -} - -// RemoveOrganizationIDs removes the "organizations" edge to Organization entities by IDs. -func (ruo *ReferrerUpdateOne) RemoveOrganizationIDs(ids ...uuid.UUID) *ReferrerUpdateOne { - ruo.mutation.RemoveOrganizationIDs(ids...) - return ruo -} - -// RemoveOrganizations removes "organizations" edges to Organization entities. -func (ruo *ReferrerUpdateOne) RemoveOrganizations(o ...*Organization) *ReferrerUpdateOne { - ids := make([]uuid.UUID, len(o)) - for i := range o { - ids[i] = o[i].ID - } - return ruo.RemoveOrganizationIDs(ids...) -} - // ClearWorkflows clears all "workflows" edges to the Workflow entity. func (ruo *ReferrerUpdateOne) ClearWorkflows() *ReferrerUpdateOne { ruo.mutation.ClearWorkflows() @@ -558,51 +440,6 @@ func (ruo *ReferrerUpdateOne) sqlSave(ctx context.Context) (_node *Referrer, err } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ruo.mutation.OrganizationsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: referrer.OrganizationsTable, - Columns: referrer.OrganizationsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(organization.FieldID, field.TypeUUID), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := ruo.mutation.RemovedOrganizationsIDs(); len(nodes) > 0 && !ruo.mutation.OrganizationsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: referrer.OrganizationsTable, - Columns: referrer.OrganizationsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(organization.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := ruo.mutation.OrganizationsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: referrer.OrganizationsTable, - Columns: referrer.OrganizationsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(organization.FieldID, field.TypeUUID), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } if ruo.mutation.WorkflowsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, diff --git a/app/controlplane/internal/data/ent/schema-viz.html b/app/controlplane/internal/data/ent/schema-viz.html index cb5ef545a..bac7bea19 100644 --- a/app/controlplane/internal/data/ent/schema-viz.html +++ b/app/controlplane/internal/data/ent/schema-viz.html @@ -70,7 +70,7 @@ } - const entGraph = JSON.parse("{\"nodes\":[{\"id\":\"CASBackend\",\"fields\":[{\"name\":\"location\",\"type\":\"string\"},{\"name\":\"provider\",\"type\":\"biz.CASBackendProvider\"},{\"name\":\"description\",\"type\":\"string\"},{\"name\":\"secret_name\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"validation_status\",\"type\":\"biz.CASBackendValidationStatus\"},{\"name\":\"validated_at\",\"type\":\"time.Time\"},{\"name\":\"default\",\"type\":\"bool\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"fallback\",\"type\":\"bool\"}]},{\"id\":\"CASMapping\",\"fields\":[{\"name\":\"digest\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"}]},{\"id\":\"Integration\",\"fields\":[{\"name\":\"kind\",\"type\":\"string\"},{\"name\":\"description\",\"type\":\"string\"},{\"name\":\"secret_name\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"configuration\",\"type\":\"[]byte\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"}]},{\"id\":\"IntegrationAttachment\",\"fields\":[{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"configuration\",\"type\":\"[]byte\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"}]},{\"id\":\"Membership\",\"fields\":[{\"name\":\"current\",\"type\":\"bool\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"updated_at\",\"type\":\"time.Time\"}]},{\"id\":\"OrgInvitation\",\"fields\":[{\"name\":\"receiver_email\",\"type\":\"string\"},{\"name\":\"status\",\"type\":\"biz.OrgInvitationStatus\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"organization_id\",\"type\":\"uuid.UUID\"},{\"name\":\"sender_id\",\"type\":\"uuid.UUID\"}]},{\"id\":\"Organization\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"}]},{\"id\":\"Referrer\",\"fields\":[{\"name\":\"digest\",\"type\":\"string\"},{\"name\":\"kind\",\"type\":\"string\"},{\"name\":\"downloadable\",\"type\":\"bool\"},{\"name\":\"created_at\",\"type\":\"time.Time\"}]},{\"id\":\"RobotAccount\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"revoked_at\",\"type\":\"time.Time\"}]},{\"id\":\"User\",\"fields\":[{\"name\":\"email\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"}]},{\"id\":\"Workflow\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"project\",\"type\":\"string\"},{\"name\":\"team\",\"type\":\"string\"},{\"name\":\"runs_count\",\"type\":\"int\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"public\",\"type\":\"bool\"}]},{\"id\":\"WorkflowContract\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"}]},{\"id\":\"WorkflowContractVersion\",\"fields\":[{\"name\":\"body\",\"type\":\"[]byte\"},{\"name\":\"revision\",\"type\":\"int\"},{\"name\":\"created_at\",\"type\":\"time.Time\"}]},{\"id\":\"WorkflowRun\",\"fields\":[{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"finished_at\",\"type\":\"time.Time\"},{\"name\":\"state\",\"type\":\"biz.WorkflowRunStatus\"},{\"name\":\"reason\",\"type\":\"string\"},{\"name\":\"run_url\",\"type\":\"string\"},{\"name\":\"runner_type\",\"type\":\"string\"},{\"name\":\"attestation\",\"type\":\"*dsse.Envelope\"},{\"name\":\"attestation_digest\",\"type\":\"string\"}]}],\"edges\":[{\"from\":\"CASMapping\",\"to\":\"CASBackend\",\"label\":\"cas_backend\"},{\"from\":\"CASMapping\",\"to\":\"WorkflowRun\",\"label\":\"workflow_run\"},{\"from\":\"CASMapping\",\"to\":\"Organization\",\"label\":\"organization\"},{\"from\":\"IntegrationAttachment\",\"to\":\"Integration\",\"label\":\"integration\"},{\"from\":\"IntegrationAttachment\",\"to\":\"Workflow\",\"label\":\"workflow\"},{\"from\":\"OrgInvitation\",\"to\":\"Organization\",\"label\":\"organization\"},{\"from\":\"OrgInvitation\",\"to\":\"User\",\"label\":\"sender\"},{\"from\":\"Organization\",\"to\":\"Membership\",\"label\":\"memberships\"},{\"from\":\"Organization\",\"to\":\"WorkflowContract\",\"label\":\"workflow_contracts\"},{\"from\":\"Organization\",\"to\":\"Workflow\",\"label\":\"workflows\"},{\"from\":\"Organization\",\"to\":\"CASBackend\",\"label\":\"cas_backends\"},{\"from\":\"Organization\",\"to\":\"Integration\",\"label\":\"integrations\"},{\"from\":\"Referrer\",\"to\":\"Referrer\",\"label\":\"references\"},{\"from\":\"Referrer\",\"to\":\"Organization\",\"label\":\"organizations\"},{\"from\":\"Referrer\",\"to\":\"Workflow\",\"label\":\"workflows\"},{\"from\":\"RobotAccount\",\"to\":\"WorkflowRun\",\"label\":\"workflowruns\"},{\"from\":\"User\",\"to\":\"Membership\",\"label\":\"memberships\"},{\"from\":\"Workflow\",\"to\":\"RobotAccount\",\"label\":\"robotaccounts\"},{\"from\":\"Workflow\",\"to\":\"WorkflowRun\",\"label\":\"workflowruns\"},{\"from\":\"Workflow\",\"to\":\"WorkflowContract\",\"label\":\"contract\"},{\"from\":\"WorkflowContract\",\"to\":\"WorkflowContractVersion\",\"label\":\"versions\"},{\"from\":\"WorkflowRun\",\"to\":\"WorkflowContractVersion\",\"label\":\"contract_version\"},{\"from\":\"WorkflowRun\",\"to\":\"CASBackend\",\"label\":\"cas_backends\"}]}"); + const entGraph = JSON.parse("{\"nodes\":[{\"id\":\"CASBackend\",\"fields\":[{\"name\":\"location\",\"type\":\"string\"},{\"name\":\"provider\",\"type\":\"biz.CASBackendProvider\"},{\"name\":\"description\",\"type\":\"string\"},{\"name\":\"secret_name\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"validation_status\",\"type\":\"biz.CASBackendValidationStatus\"},{\"name\":\"validated_at\",\"type\":\"time.Time\"},{\"name\":\"default\",\"type\":\"bool\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"fallback\",\"type\":\"bool\"}]},{\"id\":\"CASMapping\",\"fields\":[{\"name\":\"digest\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"}]},{\"id\":\"Integration\",\"fields\":[{\"name\":\"kind\",\"type\":\"string\"},{\"name\":\"description\",\"type\":\"string\"},{\"name\":\"secret_name\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"configuration\",\"type\":\"[]byte\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"}]},{\"id\":\"IntegrationAttachment\",\"fields\":[{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"configuration\",\"type\":\"[]byte\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"}]},{\"id\":\"Membership\",\"fields\":[{\"name\":\"current\",\"type\":\"bool\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"updated_at\",\"type\":\"time.Time\"}]},{\"id\":\"OrgInvitation\",\"fields\":[{\"name\":\"receiver_email\",\"type\":\"string\"},{\"name\":\"status\",\"type\":\"biz.OrgInvitationStatus\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"organization_id\",\"type\":\"uuid.UUID\"},{\"name\":\"sender_id\",\"type\":\"uuid.UUID\"}]},{\"id\":\"Organization\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"}]},{\"id\":\"Referrer\",\"fields\":[{\"name\":\"digest\",\"type\":\"string\"},{\"name\":\"kind\",\"type\":\"string\"},{\"name\":\"downloadable\",\"type\":\"bool\"},{\"name\":\"created_at\",\"type\":\"time.Time\"}]},{\"id\":\"RobotAccount\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"revoked_at\",\"type\":\"time.Time\"}]},{\"id\":\"User\",\"fields\":[{\"name\":\"email\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"}]},{\"id\":\"Workflow\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"project\",\"type\":\"string\"},{\"name\":\"team\",\"type\":\"string\"},{\"name\":\"runs_count\",\"type\":\"int\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"},{\"name\":\"public\",\"type\":\"bool\"},{\"name\":\"organization_id\",\"type\":\"uuid.UUID\"}]},{\"id\":\"WorkflowContract\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"deleted_at\",\"type\":\"time.Time\"}]},{\"id\":\"WorkflowContractVersion\",\"fields\":[{\"name\":\"body\",\"type\":\"[]byte\"},{\"name\":\"revision\",\"type\":\"int\"},{\"name\":\"created_at\",\"type\":\"time.Time\"}]},{\"id\":\"WorkflowRun\",\"fields\":[{\"name\":\"created_at\",\"type\":\"time.Time\"},{\"name\":\"finished_at\",\"type\":\"time.Time\"},{\"name\":\"state\",\"type\":\"biz.WorkflowRunStatus\"},{\"name\":\"reason\",\"type\":\"string\"},{\"name\":\"run_url\",\"type\":\"string\"},{\"name\":\"runner_type\",\"type\":\"string\"},{\"name\":\"attestation\",\"type\":\"*dsse.Envelope\"},{\"name\":\"attestation_digest\",\"type\":\"string\"}]}],\"edges\":[{\"from\":\"CASMapping\",\"to\":\"CASBackend\",\"label\":\"cas_backend\"},{\"from\":\"CASMapping\",\"to\":\"WorkflowRun\",\"label\":\"workflow_run\"},{\"from\":\"CASMapping\",\"to\":\"Organization\",\"label\":\"organization\"},{\"from\":\"IntegrationAttachment\",\"to\":\"Integration\",\"label\":\"integration\"},{\"from\":\"IntegrationAttachment\",\"to\":\"Workflow\",\"label\":\"workflow\"},{\"from\":\"OrgInvitation\",\"to\":\"Organization\",\"label\":\"organization\"},{\"from\":\"OrgInvitation\",\"to\":\"User\",\"label\":\"sender\"},{\"from\":\"Organization\",\"to\":\"Membership\",\"label\":\"memberships\"},{\"from\":\"Organization\",\"to\":\"WorkflowContract\",\"label\":\"workflow_contracts\"},{\"from\":\"Organization\",\"to\":\"Workflow\",\"label\":\"workflows\"},{\"from\":\"Organization\",\"to\":\"CASBackend\",\"label\":\"cas_backends\"},{\"from\":\"Organization\",\"to\":\"Integration\",\"label\":\"integrations\"},{\"from\":\"Referrer\",\"to\":\"Referrer\",\"label\":\"references\"},{\"from\":\"Referrer\",\"to\":\"Workflow\",\"label\":\"workflows\"},{\"from\":\"RobotAccount\",\"to\":\"WorkflowRun\",\"label\":\"workflowruns\"},{\"from\":\"User\",\"to\":\"Membership\",\"label\":\"memberships\"},{\"from\":\"Workflow\",\"to\":\"RobotAccount\",\"label\":\"robotaccounts\"},{\"from\":\"Workflow\",\"to\":\"WorkflowRun\",\"label\":\"workflowruns\"},{\"from\":\"Workflow\",\"to\":\"WorkflowContract\",\"label\":\"contract\"},{\"from\":\"WorkflowContract\",\"to\":\"WorkflowContractVersion\",\"label\":\"versions\"},{\"from\":\"WorkflowRun\",\"to\":\"WorkflowContractVersion\",\"label\":\"contract_version\"},{\"from\":\"WorkflowRun\",\"to\":\"CASBackend\",\"label\":\"cas_backends\"}]}"); const nodes = new vis.DataSet((entGraph.nodes || []).map(n => ({ id: n.id, diff --git a/app/controlplane/internal/data/ent/schema/organization.go b/app/controlplane/internal/data/ent/schema/organization.go index b76c0f22c..54cacebec 100644 --- a/app/controlplane/internal/data/ent/schema/organization.go +++ b/app/controlplane/internal/data/ent/schema/organization.go @@ -50,9 +50,8 @@ func (Organization) Edges() []ent.Edge { // an org can have and belong to many users edge.To("memberships", Membership.Type).Annotations(entsql.Annotation{OnDelete: entsql.Cascade}), edge.To("workflow_contracts", WorkflowContract.Type).Annotations(entsql.Annotation{OnDelete: entsql.Cascade}), - edge.To("workflows", Workflow.Type).StorageKey(edge.Column("organization_id")).Annotations(entsql.Annotation{OnDelete: entsql.Cascade}), + edge.To("workflows", Workflow.Type).Annotations(entsql.Annotation{OnDelete: entsql.Cascade}), edge.To("cas_backends", CASBackend.Type).Annotations(entsql.Annotation{OnDelete: entsql.Cascade}), edge.To("integrations", Integration.Type).Annotations(entsql.Annotation{OnDelete: entsql.Cascade}), - edge.From("referrers", Referrer.Type).Ref("organizations"), } } diff --git a/app/controlplane/internal/data/ent/schema/referrer.go b/app/controlplane/internal/data/ent/schema/referrer.go index 2e4267c85..cdb5cb3fb 100644 --- a/app/controlplane/internal/data/ent/schema/referrer.go +++ b/app/controlplane/internal/data/ent/schema/referrer.go @@ -49,8 +49,6 @@ func (Referrer) Edges() []ent.Edge { return []ent.Edge{ // M2M referrer can refer to itself via references edge.To("references", Referrer.Type).From("referred_by").Immutable(), - // M2M. referrer can be part of multiple organizations - edge.To("organizations", Organization.Type).Annotations(entsql.Annotation{OnDelete: entsql.Cascade}), // M2M. referrer can be part of multiple workflows edge.To("workflows", Workflow.Type).Annotations(entsql.Annotation{OnDelete: entsql.Cascade}), } diff --git a/app/controlplane/internal/data/ent/schema/workflow.go b/app/controlplane/internal/data/ent/schema/workflow.go index 17a03fbc0..359219e00 100644 --- a/app/controlplane/internal/data/ent/schema/workflow.go +++ b/app/controlplane/internal/data/ent/schema/workflow.go @@ -47,6 +47,7 @@ func (Workflow) Fields() []ent.Field { field.Time("deleted_at").Optional(), // public means that the workflow runs, attestations and materials are reachable field.Bool("public").Default(false), + field.UUID("organization_id", uuid.UUID{}), } } @@ -55,7 +56,7 @@ func (Workflow) Edges() []ent.Edge { return []ent.Edge{ edge.To("robotaccounts", RobotAccount.Type).Annotations(entsql.Annotation{OnDelete: entsql.Cascade}), edge.To("workflowruns", WorkflowRun.Type).Annotations(entsql.Annotation{OnDelete: entsql.Cascade}), - edge.From("organization", Organization.Type).Ref("workflows").Unique().Required(), + edge.From("organization", Organization.Type).Field("organization_id").Ref("workflows").Unique().Required(), edge.To("contract", WorkflowContract.Type).Unique().Required(), edge.From("integration_attachments", IntegrationAttachment.Type). Ref("workflow"), diff --git a/app/controlplane/internal/data/ent/workflow.go b/app/controlplane/internal/data/ent/workflow.go index 88c8e485f..ab5ea8383 100644 --- a/app/controlplane/internal/data/ent/workflow.go +++ b/app/controlplane/internal/data/ent/workflow.go @@ -34,10 +34,11 @@ type Workflow struct { DeletedAt time.Time `json:"deleted_at,omitempty"` // Public holds the value of the "public" field. Public bool `json:"public,omitempty"` + // OrganizationID holds the value of the "organization_id" field. + OrganizationID uuid.UUID `json:"organization_id,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the WorkflowQuery when eager-loading is set. Edges WorkflowEdges `json:"edges"` - organization_id *uuid.UUID workflow_contract *uuid.UUID selectValues sql.SelectValues } @@ -136,11 +137,9 @@ func (*Workflow) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullString) case workflow.FieldCreatedAt, workflow.FieldDeletedAt: values[i] = new(sql.NullTime) - case workflow.FieldID: + case workflow.FieldID, workflow.FieldOrganizationID: values[i] = new(uuid.UUID) - case workflow.ForeignKeys[0]: // organization_id - values[i] = &sql.NullScanner{S: new(uuid.UUID)} - case workflow.ForeignKeys[1]: // workflow_contract + case workflow.ForeignKeys[0]: // workflow_contract values[i] = &sql.NullScanner{S: new(uuid.UUID)} default: values[i] = new(sql.UnknownType) @@ -205,14 +204,13 @@ func (w *Workflow) assignValues(columns []string, values []any) error { } else if value.Valid { w.Public = value.Bool } - case workflow.ForeignKeys[0]: - if value, ok := values[i].(*sql.NullScanner); !ok { + case workflow.FieldOrganizationID: + if value, ok := values[i].(*uuid.UUID); !ok { return fmt.Errorf("unexpected type %T for field organization_id", values[i]) - } else if value.Valid { - w.organization_id = new(uuid.UUID) - *w.organization_id = *value.S.(*uuid.UUID) + } else if value != nil { + w.OrganizationID = *value } - case workflow.ForeignKeys[1]: + case workflow.ForeignKeys[0]: if value, ok := values[i].(*sql.NullScanner); !ok { return fmt.Errorf("unexpected type %T for field workflow_contract", values[i]) } else if value.Valid { @@ -305,6 +303,9 @@ func (w *Workflow) String() string { builder.WriteString(", ") builder.WriteString("public=") builder.WriteString(fmt.Sprintf("%v", w.Public)) + builder.WriteString(", ") + builder.WriteString("organization_id=") + builder.WriteString(fmt.Sprintf("%v", w.OrganizationID)) builder.WriteByte(')') return builder.String() } diff --git a/app/controlplane/internal/data/ent/workflow/where.go b/app/controlplane/internal/data/ent/workflow/where.go index 13e007d07..40ebe5761 100644 --- a/app/controlplane/internal/data/ent/workflow/where.go +++ b/app/controlplane/internal/data/ent/workflow/where.go @@ -91,6 +91,11 @@ func Public(v bool) predicate.Workflow { return predicate.Workflow(sql.FieldEQ(FieldPublic, v)) } +// OrganizationID applies equality check predicate on the "organization_id" field. It's identical to OrganizationIDEQ. +func OrganizationID(v uuid.UUID) predicate.Workflow { + return predicate.Workflow(sql.FieldEQ(FieldOrganizationID, v)) +} + // NameEQ applies the EQ predicate on the "name" field. func NameEQ(v string) predicate.Workflow { return predicate.Workflow(sql.FieldEQ(FieldName, v)) @@ -446,6 +451,26 @@ func PublicNEQ(v bool) predicate.Workflow { return predicate.Workflow(sql.FieldNEQ(FieldPublic, v)) } +// OrganizationIDEQ applies the EQ predicate on the "organization_id" field. +func OrganizationIDEQ(v uuid.UUID) predicate.Workflow { + return predicate.Workflow(sql.FieldEQ(FieldOrganizationID, v)) +} + +// OrganizationIDNEQ applies the NEQ predicate on the "organization_id" field. +func OrganizationIDNEQ(v uuid.UUID) predicate.Workflow { + return predicate.Workflow(sql.FieldNEQ(FieldOrganizationID, v)) +} + +// OrganizationIDIn applies the In predicate on the "organization_id" field. +func OrganizationIDIn(vs ...uuid.UUID) predicate.Workflow { + return predicate.Workflow(sql.FieldIn(FieldOrganizationID, vs...)) +} + +// OrganizationIDNotIn applies the NotIn predicate on the "organization_id" field. +func OrganizationIDNotIn(vs ...uuid.UUID) predicate.Workflow { + return predicate.Workflow(sql.FieldNotIn(FieldOrganizationID, vs...)) +} + // HasRobotaccounts applies the HasEdge predicate on the "robotaccounts" edge. func HasRobotaccounts() predicate.Workflow { return predicate.Workflow(func(s *sql.Selector) { diff --git a/app/controlplane/internal/data/ent/workflow/workflow.go b/app/controlplane/internal/data/ent/workflow/workflow.go index 4fd0aede9..2e11006d1 100644 --- a/app/controlplane/internal/data/ent/workflow/workflow.go +++ b/app/controlplane/internal/data/ent/workflow/workflow.go @@ -29,6 +29,8 @@ const ( FieldDeletedAt = "deleted_at" // FieldPublic holds the string denoting the public field in the database. FieldPublic = "public" + // FieldOrganizationID holds the string denoting the organization_id field in the database. + FieldOrganizationID = "organization_id" // EdgeRobotaccounts holds the string denoting the robotaccounts edge name in mutations. EdgeRobotaccounts = "robotaccounts" // EdgeWorkflowruns holds the string denoting the workflowruns edge name in mutations. @@ -95,12 +97,12 @@ var Columns = []string{ FieldCreatedAt, FieldDeletedAt, FieldPublic, + FieldOrganizationID, } // ForeignKeys holds the SQL foreign-keys that are owned by the "workflows" // table and are not defined as standalone fields in the schema. var ForeignKeys = []string{ - "organization_id", "workflow_contract", } @@ -179,6 +181,11 @@ func ByPublic(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldPublic, opts...).ToFunc() } +// ByOrganizationID orders the results by the organization_id field. +func ByOrganizationID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOrganizationID, opts...).ToFunc() +} + // ByRobotaccountsCount orders the results by robotaccounts count. func ByRobotaccountsCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { diff --git a/app/controlplane/internal/data/ent/workflow_create.go b/app/controlplane/internal/data/ent/workflow_create.go index ac6f76161..fe25f642d 100644 --- a/app/controlplane/internal/data/ent/workflow_create.go +++ b/app/controlplane/internal/data/ent/workflow_create.go @@ -117,6 +117,12 @@ func (wc *WorkflowCreate) SetNillablePublic(b *bool) *WorkflowCreate { return wc } +// SetOrganizationID sets the "organization_id" field. +func (wc *WorkflowCreate) SetOrganizationID(u uuid.UUID) *WorkflowCreate { + wc.mutation.SetOrganizationID(u) + return wc +} + // SetID sets the "id" field. func (wc *WorkflowCreate) SetID(u uuid.UUID) *WorkflowCreate { wc.mutation.SetID(u) @@ -161,12 +167,6 @@ func (wc *WorkflowCreate) AddWorkflowruns(w ...*WorkflowRun) *WorkflowCreate { return wc.AddWorkflowrunIDs(ids...) } -// SetOrganizationID sets the "organization" edge to the Organization entity by ID. -func (wc *WorkflowCreate) SetOrganizationID(id uuid.UUID) *WorkflowCreate { - wc.mutation.SetOrganizationID(id) - return wc -} - // SetOrganization sets the "organization" edge to the Organization entity. func (wc *WorkflowCreate) SetOrganization(o *Organization) *WorkflowCreate { return wc.SetOrganizationID(o.ID) @@ -280,6 +280,9 @@ func (wc *WorkflowCreate) check() error { if _, ok := wc.mutation.Public(); !ok { return &ValidationError{Name: "public", err: errors.New(`ent: missing required field "Workflow.public"`)} } + if _, ok := wc.mutation.OrganizationID(); !ok { + return &ValidationError{Name: "organization_id", err: errors.New(`ent: missing required field "Workflow.organization_id"`)} + } if _, ok := wc.mutation.OrganizationID(); !ok { return &ValidationError{Name: "organization", err: errors.New(`ent: missing required edge "Workflow.organization"`)} } @@ -395,7 +398,7 @@ func (wc *WorkflowCreate) createSpec() (*Workflow, *sqlgraph.CreateSpec) { for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } - _node.organization_id = &nodes[0] + _node.OrganizationID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } if nodes := wc.mutation.ContractIDs(); len(nodes) > 0 { diff --git a/app/controlplane/internal/data/ent/workflow_query.go b/app/controlplane/internal/data/ent/workflow_query.go index fa4cbf2be..a635db5b6 100644 --- a/app/controlplane/internal/data/ent/workflow_query.go +++ b/app/controlplane/internal/data/ent/workflow_query.go @@ -562,7 +562,7 @@ func (wq *WorkflowQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Wor wq.withReferrers != nil, } ) - if wq.withOrganization != nil || wq.withContract != nil { + if wq.withContract != nil { withFKs = true } if withFKs { @@ -697,10 +697,7 @@ func (wq *WorkflowQuery) loadOrganization(ctx context.Context, query *Organizati ids := make([]uuid.UUID, 0, len(nodes)) nodeids := make(map[uuid.UUID][]*Workflow) for i := range nodes { - if nodes[i].organization_id == nil { - continue - } - fk := *nodes[i].organization_id + fk := nodes[i].OrganizationID if _, ok := nodeids[fk]; !ok { ids = append(ids, fk) } @@ -875,6 +872,9 @@ func (wq *WorkflowQuery) querySpec() *sqlgraph.QuerySpec { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } + if wq.withOrganization != nil { + _spec.Node.AddColumnOnce(workflow.FieldOrganizationID) + } } if ps := wq.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { diff --git a/app/controlplane/internal/data/ent/workflow_update.go b/app/controlplane/internal/data/ent/workflow_update.go index 67f041bc5..28e6e2627 100644 --- a/app/controlplane/internal/data/ent/workflow_update.go +++ b/app/controlplane/internal/data/ent/workflow_update.go @@ -136,6 +136,12 @@ func (wu *WorkflowUpdate) SetNillablePublic(b *bool) *WorkflowUpdate { return wu } +// SetOrganizationID sets the "organization_id" field. +func (wu *WorkflowUpdate) SetOrganizationID(u uuid.UUID) *WorkflowUpdate { + wu.mutation.SetOrganizationID(u) + return wu +} + // AddRobotaccountIDs adds the "robotaccounts" edge to the RobotAccount entity by IDs. func (wu *WorkflowUpdate) AddRobotaccountIDs(ids ...uuid.UUID) *WorkflowUpdate { wu.mutation.AddRobotaccountIDs(ids...) @@ -166,12 +172,6 @@ func (wu *WorkflowUpdate) AddWorkflowruns(w ...*WorkflowRun) *WorkflowUpdate { return wu.AddWorkflowrunIDs(ids...) } -// SetOrganizationID sets the "organization" edge to the Organization entity by ID. -func (wu *WorkflowUpdate) SetOrganizationID(id uuid.UUID) *WorkflowUpdate { - wu.mutation.SetOrganizationID(id) - return wu -} - // SetOrganization sets the "organization" edge to the Organization entity. func (wu *WorkflowUpdate) SetOrganization(o *Organization) *WorkflowUpdate { return wu.SetOrganizationID(o.ID) @@ -758,6 +758,12 @@ func (wuo *WorkflowUpdateOne) SetNillablePublic(b *bool) *WorkflowUpdateOne { return wuo } +// SetOrganizationID sets the "organization_id" field. +func (wuo *WorkflowUpdateOne) SetOrganizationID(u uuid.UUID) *WorkflowUpdateOne { + wuo.mutation.SetOrganizationID(u) + return wuo +} + // AddRobotaccountIDs adds the "robotaccounts" edge to the RobotAccount entity by IDs. func (wuo *WorkflowUpdateOne) AddRobotaccountIDs(ids ...uuid.UUID) *WorkflowUpdateOne { wuo.mutation.AddRobotaccountIDs(ids...) @@ -788,12 +794,6 @@ func (wuo *WorkflowUpdateOne) AddWorkflowruns(w ...*WorkflowRun) *WorkflowUpdate return wuo.AddWorkflowrunIDs(ids...) } -// SetOrganizationID sets the "organization" edge to the Organization entity by ID. -func (wuo *WorkflowUpdateOne) SetOrganizationID(id uuid.UUID) *WorkflowUpdateOne { - wuo.mutation.SetOrganizationID(id) - return wuo -} - // SetOrganization sets the "organization" edge to the Organization entity. func (wuo *WorkflowUpdateOne) SetOrganization(o *Organization) *WorkflowUpdateOne { return wuo.SetOrganizationID(o.ID) diff --git a/app/controlplane/internal/data/referrer.go b/app/controlplane/internal/data/referrer.go index c7784f584..ca22e191d 100644 --- a/app/controlplane/internal/data/referrer.go +++ b/app/controlplane/internal/data/referrer.go @@ -71,20 +71,14 @@ func (r *ReferrerRepo) Save(ctx context.Context, referrers []*biz.Referrer, work } storedRef, err = tx.Referrer.Create(). - SetDigest(r.Digest).SetKind(r.Kind).SetDownloadable(r.Downloadable). - AddOrganizationIDs(wf.OrgID). - AddWorkflowIDs(workflowID). - Save(ctx) + SetDigest(r.Digest).SetKind(r.Kind).SetDownloadable(r.Downloadable).AddWorkflowIDs(workflowID).Save(ctx) if err != nil { return fmt.Errorf("failed to create referrer: %w", err) } } // associate it with the possibly new organization and workflow - storedRef, err = storedRef.Update(). - AddOrganizationIDs(wf.OrgID). - AddWorkflowIDs(workflowID). - Save(ctx) + storedRef, err = storedRef.Update().AddWorkflowIDs(workflowID).Save(ctx) if err != nil { return fmt.Errorf("failed to add organization to referrer: %w", err) } @@ -131,7 +125,6 @@ func (r *ReferrerRepo) GetFromRoot(ctx context.Context, digest string, orgIDs [] // filter by the allowed organizations and by the visibility of the attached workflows if needed predicateReferrer := []predicate.Referrer{ referrer.Digest(digest), - referrer.HasOrganizationsWith(organization.IDIn(orgIDs...)), } // We might be filtering by the rootKind, this will prevent ambiguity @@ -152,7 +145,7 @@ func (r *ReferrerRepo) GetFromRoot(ctx context.Context, digest string, orgIDs [] // Attach the workflow predicate predicateReferrer = append(predicateReferrer, referrer.HasWorkflowsWith(predicateWF...)) - refs, err := r.data.db.Referrer.Query().Where(predicateReferrer...).WithWorkflows().WithOrganizations().All(ctx) + refs, err := r.data.db.Referrer.Query().Where(predicateReferrer...).WithWorkflows().All(ctx) if err != nil { return nil, fmt.Errorf("failed to query referrer: %w", err) } @@ -184,38 +177,20 @@ func (r *ReferrerRepo) GetFromRoot(ctx context.Context, digest string, orgIDs [] const maxTraverseLevels = 1 func (r *ReferrerRepo) doGet(ctx context.Context, root *ent.Referrer, allowedOrgs []uuid.UUID, public *bool, level int) (*biz.StoredReferrer, error) { - // Find if it has a public workflow associated - // The list of associated workflows and organizations - // that come preloaded in the edges already - isPublic := false - workflowIDs := make([]uuid.UUID, 0, len(root.Edges.Workflows)) - for _, wf := range root.Edges.Workflows { - if wf.Public { - isPublic = true - } - workflowIDs = append(workflowIDs, wf.ID) - } - - // Organization associated to the root referrer - rootOrgsIDs := make([]uuid.UUID, 0, len(root.Edges.Organizations)) - for _, org := range root.Edges.Organizations { - rootOrgsIDs = append(rootOrgsIDs, org.ID) - } - // Assemble the referrer to return res := &biz.StoredReferrer{ ID: root.ID, CreatedAt: toTimePtr(root.CreatedAt), Referrer: &biz.Referrer{ - Digest: root.Digest, - Kind: root.Kind, - Downloadable: root.Downloadable, - InPublicWorkflow: isPublic, + Digest: root.Digest, + Kind: root.Kind, + Downloadable: root.Downloadable, }, - WorkflowIDs: workflowIDs, - OrgIDs: rootOrgsIDs, } + // add additional information related to the workflows + hydrateWorkflowsInfo(root, res) + // Next: We'll find the references recursively up to a max of maxTraverseLevels levels if level >= maxTraverseLevels { return res, nil @@ -223,9 +198,7 @@ func (r *ReferrerRepo) doGet(ctx context.Context, root *ent.Referrer, allowedOrg // Find the references and call recursively filtered out by the allowed organizations // and by the visibility if needed - predicateReferrer := []predicate.Referrer{ - referrer.HasOrganizationsWith(organization.IDIn(allowedOrgs...)), - } + predicateReferrer := []predicate.Referrer{} predicateWF := []predicate.Workflow{ workflow.DeletedAtIsNil(), workflow.HasOrganizationWith(organization.IDIn(allowedOrgs...)), @@ -239,7 +212,7 @@ func (r *ReferrerRepo) doGet(ctx context.Context, root *ent.Referrer, allowedOrg // Attach the workflow predicate predicateReferrer = append(predicateReferrer, referrer.HasWorkflowsWith(predicateWF...)) - refs, err := root.QueryReferences().Where(predicateReferrer...).WithWorkflows().WithOrganizations().Order(referrer.ByDigest()).All(ctx) + refs, err := root.QueryReferences().Where(predicateReferrer...).WithWorkflows().Order(referrer.ByDigest()).All(ctx) if err != nil { return nil, fmt.Errorf("failed to query references: %w", err) } @@ -258,3 +231,28 @@ func (r *ReferrerRepo) doGet(ctx context.Context, root *ent.Referrer, allowedOrg return res, nil } + +// hydrate the referrer with the following information: +// - isPublic: if it has a public workflow associated +// - workflowIDs: the list of associated workflows +// - orgIDs: the list of associated organizations +func hydrateWorkflowsInfo(root *ent.Referrer, out *biz.StoredReferrer) { + isPublic := false + workflowIDs := make([]uuid.UUID, 0, len(root.Edges.Workflows)) + orgIDs := make([]uuid.UUID, 0) + orgsMap := make(map[uuid.UUID]struct{}, 0) + for _, wf := range root.Edges.Workflows { + if wf.Public { + isPublic = true + } + workflowIDs = append(workflowIDs, wf.ID) + if _, ok := orgsMap[wf.OrganizationID]; !ok { + orgIDs = append(orgIDs, wf.OrganizationID) + } + orgsMap[wf.OrganizationID] = struct{}{} + } + + out.InPublicWorkflow = isPublic + out.WorkflowIDs = workflowIDs + out.OrgIDs = orgIDs +} From fcfb8ce0121e7170a3c9327f6b2c49291d0c806d Mon Sep 17 00:00:00 2001 From: Miguel Martinez Trivino Date: Thu, 16 Nov 2023 22:40:33 +0100 Subject: [PATCH 7/7] remove organization table Signed-off-by: Miguel Martinez Trivino --- app/controlplane/configs/config.devel.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controlplane/configs/config.devel.yaml b/app/controlplane/configs/config.devel.yaml index b1335f3f9..9e72e1a88 100644 --- a/app/controlplane/configs/config.devel.yaml +++ b/app/controlplane/configs/config.devel.yaml @@ -48,7 +48,7 @@ auth: # Private key used to sign the JWTs meant to be consumed by the CAS cas_robot_account_private_key_path: "../../devel/devkeys/cas.pem" -referrer_shared_index: - enabled: true - allowed_orgs: - - 7ae5a35a-9f01-4711-b293-bd1d161c01a9 # practical_mayer +# referrer_shared_index: +# enabled: true +# allowed_orgs: +# - deadbeef