Skip to content

Commit e57234c

Browse files
authored
chore(controlplane): move OnboardingSpec message to public package (#1135)
Signed-off-by: Jose I. Paris <[email protected]>
1 parent dc1eb2e commit e57234c

File tree

16 files changed

+560
-395
lines changed

16 files changed

+560
-395
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ api:
1414
# generate config proto
1515
config:
1616
cd ./pkg/credentials/api && buf generate
17+
cd ./app/controlplane/pkg/conf && buf generate
1718
make -C ./app/controlplane config
1819
make -C ./app/artifact-cas config
1920

app/controlplane/internal/conf/controlplane/config/v1/conf.pb.go

Lines changed: 287 additions & 366 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/internal/conf/controlplane/config/v1/conf.proto

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ syntax = "proto3";
1818
package controlplane.config.v1;
1919

2020
import "buf/validate/validate.proto";
21-
import "controlplane/v1/response_messages.proto";
2221
import "credentials/v1/config.proto";
22+
import "controlplane/config/v1/config.proto";
2323
import "google/protobuf/duration.proto";
2424

2525
option go_package = "github.com/chainloop-dev/chainloop/app/controlplane/internal/conf/controlplane/config/v1;conf";
@@ -168,19 +168,6 @@ message CA {
168168
}
169169
}
170170

171-
// OnboardingSpec is a configuration to automatically onboard users in organizations with specific roles
172-
message OnboardingSpec {
173-
// Name of the organization
174-
string name = 1 [(buf.validate.field).string.min_len = 1];
175-
// Role to assign to the user
176-
controlplane.v1.MembershipRole role = 2 [
177-
(buf.validate.field).enum = {
178-
not_in: [0]
179-
},
180-
(buf.validate.field).enum.defined_only = true
181-
];
182-
}
183-
184171
// PrometheusIntegrationSpec is a configuration to enable Prometheus integration for the
185172
// specified organizations
186173
message PrometheusIntegrationSpec {

app/controlplane/pkg/biz/organization.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import (
2222
"io"
2323
"time"
2424

25-
conf "github.com/chainloop-dev/chainloop/app/controlplane/internal/conf/controlplane/config/v1"
2625
"github.com/chainloop-dev/chainloop/app/controlplane/pkg/authz"
26+
config "github.com/chainloop-dev/chainloop/app/controlplane/pkg/conf/controlplane/config/v1"
2727
"github.com/chainloop-dev/chainloop/pkg/servicelogger"
2828
"github.com/go-kratos/kratos/v2/log"
2929
"github.com/google/uuid"
@@ -48,10 +48,10 @@ type OrganizationUseCase struct {
4848
casBackendUseCase *CASBackendUseCase
4949
integrationUC *IntegrationUseCase
5050
membershipRepo MembershipRepo
51-
onboardingConfig []*conf.OnboardingSpec
51+
onboardingConfig []*config.OnboardingSpec
5252
}
5353

54-
func NewOrganizationUseCase(repo OrganizationRepo, repoUC *CASBackendUseCase, iUC *IntegrationUseCase, mRepo MembershipRepo, onboardingConfig []*conf.OnboardingSpec, l log.Logger) *OrganizationUseCase {
54+
func NewOrganizationUseCase(repo OrganizationRepo, repoUC *CASBackendUseCase, iUC *IntegrationUseCase, mRepo MembershipRepo, onboardingConfig []*config.OnboardingSpec, l log.Logger) *OrganizationUseCase {
5555
if l == nil {
5656
l = log.NewStdLogger(io.Discard)
5757
}

app/controlplane/pkg/biz/organization_integration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import (
2020
"testing"
2121

2222
v1 "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1"
23-
conf "github.com/chainloop-dev/chainloop/app/controlplane/internal/conf/controlplane/config/v1"
2423
"github.com/chainloop-dev/chainloop/app/controlplane/pkg/authz"
2524
"github.com/chainloop-dev/chainloop/app/controlplane/pkg/biz"
2625
"github.com/chainloop-dev/chainloop/app/controlplane/pkg/biz/testhelpers"
26+
config "github.com/chainloop-dev/chainloop/app/controlplane/pkg/conf/controlplane/config/v1"
2727
"github.com/chainloop-dev/chainloop/app/controlplane/plugins/sdk/v1"
2828
integrationMocks "github.com/chainloop-dev/chainloop/app/controlplane/plugins/sdk/v1/mocks"
2929
"github.com/google/uuid"
@@ -246,7 +246,7 @@ func (s *AuthOnboardingTestSuite) SetupTest() {
246246
t := s.T()
247247
ctx := context.Background()
248248

249-
s.TestingUseCases = testhelpers.NewTestingUseCases(t, testhelpers.WithOnboardingConfiguration([]*conf.OnboardingSpec{
249+
s.TestingUseCases = testhelpers.NewTestingUseCases(t, testhelpers.WithOnboardingConfiguration([]*config.OnboardingSpec{
250250
{
251251
Name: "non-existing-org",
252252
Role: v1.MembershipRole_MEMBERSHIP_ROLE_ORG_VIEWER,

app/controlplane/pkg/biz/testhelpers/database.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"testing"
2424
"time"
2525

26+
config "github.com/chainloop-dev/chainloop/app/controlplane/pkg/conf/controlplane/config/v1"
2627
// Required for the database waitFor strategy
2728
_ "github.com/lib/pq"
2829

@@ -87,7 +88,7 @@ type newTestingOpts struct {
8788
credsReaderWriter credentials.ReaderWriter
8889
integrations sdk.AvailablePlugins
8990
providers backends.Providers
90-
onboardingConfiguration []*conf.OnboardingSpec
91+
onboardingConfiguration []*config.OnboardingSpec
9192
}
9293

9394
type NewTestingUCOpt func(*newTestingOpts)
@@ -108,7 +109,7 @@ func WithRegisteredIntegration(i sdk.FanOut) NewTestingUCOpt {
108109
}
109110
}
110111

111-
func WithOnboardingConfiguration(conf []*conf.OnboardingSpec) NewTestingUCOpt {
112+
func WithOnboardingConfiguration(conf []*config.OnboardingSpec) NewTestingUCOpt {
112113
return func(tu *newTestingOpts) {
113114
tu.onboardingConfiguration = conf
114115
}

app/controlplane/pkg/biz/testhelpers/wire.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
conf "github.com/chainloop-dev/chainloop/app/controlplane/internal/conf/controlplane/config/v1"
2727
"github.com/chainloop-dev/chainloop/app/controlplane/pkg/authz"
2828
"github.com/chainloop-dev/chainloop/app/controlplane/pkg/biz"
29+
config "github.com/chainloop-dev/chainloop/app/controlplane/pkg/conf/controlplane/config/v1"
2930
"github.com/chainloop-dev/chainloop/app/controlplane/pkg/data"
3031
"github.com/chainloop-dev/chainloop/app/controlplane/plugins/sdk/v1"
3132
robotaccount "github.com/chainloop-dev/chainloop/internal/robotaccount/cas"
@@ -36,7 +37,7 @@ import (
3637
)
3738

3839
// wireTestData init testing data
39-
func WireTestData(*TestDatabase, *testing.T, log.Logger, credentials.ReaderWriter, *robotaccount.Builder, *conf.Auth, *conf.Bootstrap, []*conf.OnboardingSpec, sdk.AvailablePlugins, backends.Providers) (*TestingUseCases, func(), error) {
40+
func WireTestData(*TestDatabase, *testing.T, log.Logger, credentials.ReaderWriter, *robotaccount.Builder, *conf.Auth, *conf.Bootstrap, []*config.OnboardingSpec, sdk.AvailablePlugins, backends.Providers) (*TestingUseCases, func(), error) {
4041
panic(
4142
wire.Build(
4243
data.ProviderSet,

app/controlplane/pkg/biz/testhelpers/wire_gen.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controlplane/pkg/biz/user.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121
"time"
2222

2323
pb "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1"
24-
conf "github.com/chainloop-dev/chainloop/app/controlplane/internal/conf/controlplane/config/v1"
2524
"github.com/chainloop-dev/chainloop/app/controlplane/pkg/authz"
25+
config "github.com/chainloop-dev/chainloop/app/controlplane/pkg/conf/controlplane/config/v1"
2626
"github.com/go-kratos/kratos/v2/log"
2727
"github.com/google/uuid"
2828
)
@@ -50,14 +50,14 @@ type UserUseCase struct {
5050
logger *log.Helper
5151
membershipUseCase *MembershipUseCase
5252
organizationUseCase *OrganizationUseCase
53-
onboardingConfig []*conf.OnboardingSpec
53+
onboardingConfig []*config.OnboardingSpec
5454
}
5555

5656
type NewUserUseCaseParams struct {
5757
UserRepo UserRepo
5858
MembershipUseCase *MembershipUseCase
5959
OrganizationUseCase *OrganizationUseCase
60-
OnboardingConfig []*conf.OnboardingSpec
60+
OnboardingConfig []*config.OnboardingSpec
6161
Logger log.Logger
6262
}
6363

app/controlplane/pkg/biz/user_integration_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ import (
2020
"testing"
2121

2222
v1 "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1"
23-
conf "github.com/chainloop-dev/chainloop/app/controlplane/internal/conf/controlplane/config/v1"
2423
"github.com/chainloop-dev/chainloop/app/controlplane/pkg/authz"
2524
"github.com/chainloop-dev/chainloop/app/controlplane/pkg/biz"
2625
"github.com/chainloop-dev/chainloop/app/controlplane/pkg/biz/testhelpers"
27-
26+
config "github.com/chainloop-dev/chainloop/app/controlplane/pkg/conf/controlplane/config/v1"
2827
"github.com/stretchr/testify/assert"
2928
"github.com/stretchr/testify/require"
3029
"github.com/stretchr/testify/suite"
@@ -139,7 +138,7 @@ func (s *userOnboardingTestSuite) TestAutoOnboardOrganizationsNoConfiguration()
139138
func (s *userOnboardingTestSuite) TestAutoOnboardOrganizationsWithConfiguration() {
140139
ctx := context.Background()
141140
const orgName = "existing-org"
142-
s.TestingUseCases = testhelpers.NewTestingUseCases(s.T(), testhelpers.WithOnboardingConfiguration([]*conf.OnboardingSpec{
141+
s.TestingUseCases = testhelpers.NewTestingUseCases(s.T(), testhelpers.WithOnboardingConfiguration([]*config.OnboardingSpec{
143142
{
144143
Name: orgName,
145144
Role: v1.MembershipRole_MEMBERSHIP_ROLE_ORG_VIEWER,

0 commit comments

Comments
 (0)