mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 07:47:32 +00:00
linting
This commit is contained in:
@@ -24,24 +24,23 @@ func InstanceRepository(client database.QueryExecutor) domain.InstanceRepository
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// repository
|
||||
// -------------------------------------------------------------
|
||||
|
||||
const (
|
||||
queryInstanceStmt = `SELECT instances.id, instances.name, instances.default_org_id, instances.iam_project_id, instances.console_client_id, instances.console_app_id, instances.default_language, instances.created_at, instances.updated_at` +
|
||||
` , CASE WHEN count(instance_domains.domain) > 0 THEN jsonb_agg(json_build_object('domain', instance_domains.domain, 'isVerified', instance_domains.is_verified, 'isPrimary', instance_domains.is_primary, 'isGenerated', instance_domains.is_generated, 'validationType', instance_domains.validation_type, 'createdAt', instance_domains.created_at, 'updatedAt', instance_domains.updated_at)) ELSE NULL::JSONB END domains` +
|
||||
` FROM zitadel.instances`
|
||||
` , CASE WHEN count(instance_domains.domain) > 0 THEN jsonb_agg(json_build_object('domain', instance_domains.domain, 'isVerified', instance_domains.is_verified, 'isPrimary', instance_domains.is_primary, 'isGenerated', instance_domains.is_generated, 'validationType', instance_domains.validation_type, 'createdAt', instance_domains.created_at, 'updatedAt', instance_domains.updated_at)) ELSE NULL::JSONB END domains` +
|
||||
` FROM zitadel.instances`
|
||||
)
|
||||
|
||||
// Get implements [domain.InstanceRepository].
|
||||
func (i *instance) Get(ctx context.Context, opts ...database.QueryOption) (*domain.Instance, error) {
|
||||
opts = append(opts,
|
||||
i.joinDomains(),
|
||||
opts = append(opts,
|
||||
i.joinDomains(),
|
||||
database.WithGroupBy(i.IDColumn(true)),
|
||||
)
|
||||
|
||||
|
||||
options := new(database.QueryOpts)
|
||||
for _, opt := range opts {
|
||||
opt(options)
|
||||
@@ -56,11 +55,11 @@ func (i *instance) Get(ctx context.Context, opts ...database.QueryOption) (*doma
|
||||
|
||||
// List implements [domain.InstanceRepository].
|
||||
func (i *instance) List(ctx context.Context, opts ...database.QueryOption) ([]*domain.Instance, error) {
|
||||
opts = append(opts,
|
||||
i.joinDomains(),
|
||||
opts = append(opts,
|
||||
i.joinDomains(),
|
||||
database.WithGroupBy(i.IDColumn(true)),
|
||||
)
|
||||
|
||||
|
||||
options := new(database.QueryOpts)
|
||||
for _, opt := range opts {
|
||||
opt(options)
|
||||
@@ -243,7 +242,7 @@ func scanInstance(ctx context.Context, querier database.Querier, builder *databa
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
var instance rawInstance
|
||||
if err := rows.(database.CollectableRows).CollectExactlyOneRow(&instance); err != nil {
|
||||
return nil, err
|
||||
|
@@ -229,4 +229,4 @@ func scanInstanceDomain(ctx context.Context, querier database.Querier, builder *
|
||||
}
|
||||
|
||||
return instanceDomain, nil
|
||||
}
|
||||
}
|
||||
|
@@ -58,12 +58,12 @@ func (o *org) List(ctx context.Context, opts ...database.QueryOption) ([]*domain
|
||||
database.WithGroupBy(o.InstanceIDColumn(true), o.IDColumn(true)),
|
||||
)
|
||||
|
||||
options := new(database.QueryOpts)
|
||||
options := new(database.QueryOpts)
|
||||
for _, opt := range opts {
|
||||
opt(options)
|
||||
}
|
||||
|
||||
var builder database.StatementBuilder
|
||||
|
||||
var builder database.StatementBuilder
|
||||
builder.WriteString(queryOrganizationStmt)
|
||||
options.Write(&builder)
|
||||
|
||||
@@ -72,7 +72,7 @@ func (o *org) List(ctx context.Context, opts ...database.QueryOption) ([]*domain
|
||||
|
||||
func (o *org) joinDomains() database.QueryOption {
|
||||
columns := make([]database.Condition, 0, 3)
|
||||
columns = append(columns,
|
||||
columns = append(columns,
|
||||
database.NewColumnCondition(o.InstanceIDColumn(true), o.Domains(false).InstanceIDColumn(true)),
|
||||
database.NewColumnCondition(o.IDColumn(true), o.Domains(false).OrgIDColumn(true)),
|
||||
)
|
||||
@@ -89,7 +89,6 @@ func (o *org) joinDomains() database.QueryOption {
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
const createOrganizationStmt = `INSERT INTO zitadel.organizations (id, name, instance_id, state)` +
|
||||
` VALUES ($1, $2, $3, $4)` +
|
||||
` RETURNING created_at, updated_at`
|
||||
@@ -103,7 +102,6 @@ func (o *org) Create(ctx context.Context, organization *domain.Organization) err
|
||||
return o.client.QueryRow(ctx, builder.String(), builder.Args()...).Scan(&organization.CreatedAt, &organization.UpdatedAt)
|
||||
}
|
||||
|
||||
|
||||
// Update implements [domain.OrganizationRepository].
|
||||
func (o *org) Update(ctx context.Context, id domain.OrgIdentifierCondition, instanceID string, changes ...database.Change) (int64, error) {
|
||||
if len(changes) == 0 {
|
||||
@@ -266,7 +264,7 @@ func scanOrganizations(ctx context.Context, querier database.Querier, builder *d
|
||||
if err := rows.(database.CollectableRows).Collect(&rawOrgs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
organizations := make([]*domain.Organization, len(rawOrgs))
|
||||
for i, org := range rawOrgs {
|
||||
if len(org.RawDomains) > 0 {
|
||||
|
@@ -14,8 +14,6 @@ type orgDomain struct {
|
||||
*org
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// repository
|
||||
// -------------------------------------------------------------
|
||||
@@ -146,7 +144,7 @@ func (o orgDomain) OrgIDCondition(orgID string) database.Condition {
|
||||
// Subtle: this method shadows the method ([domain.OrganizationRepository]).CreatedAtColumn of orgDomain.org.
|
||||
func (orgDomain) CreatedAtColumn(qualified bool) database.Column {
|
||||
if qualified {
|
||||
return database.NewColumn("org_domains.created_at")
|
||||
return database.NewColumn("org_domains.created_at")
|
||||
}
|
||||
return database.NewColumn("created_at")
|
||||
}
|
||||
@@ -154,7 +152,7 @@ func (orgDomain) CreatedAtColumn(qualified bool) database.Column {
|
||||
// DomainColumn implements [domain.OrganizationDomainRepository].
|
||||
func (orgDomain) DomainColumn(qualified bool) database.Column {
|
||||
if qualified {
|
||||
return database.NewColumn("org_domains.domain")
|
||||
return database.NewColumn("org_domains.domain")
|
||||
}
|
||||
return database.NewColumn("domain")
|
||||
}
|
||||
@@ -163,7 +161,7 @@ func (orgDomain) DomainColumn(qualified bool) database.Column {
|
||||
// Subtle: this method shadows the method ([domain.OrganizationRepository]).InstanceIDColumn of orgDomain.org.
|
||||
func (orgDomain) InstanceIDColumn(qualified bool) database.Column {
|
||||
if qualified {
|
||||
return database.NewColumn("org_domains.instance_id")
|
||||
return database.NewColumn("org_domains.instance_id")
|
||||
}
|
||||
return database.NewColumn("instance_id")
|
||||
}
|
||||
@@ -171,7 +169,7 @@ func (orgDomain) InstanceIDColumn(qualified bool) database.Column {
|
||||
// IsPrimaryColumn implements [domain.OrganizationDomainRepository].
|
||||
func (orgDomain) IsPrimaryColumn(qualified bool) database.Column {
|
||||
if qualified {
|
||||
return database.NewColumn("org_domains.is_primary")
|
||||
return database.NewColumn("org_domains.is_primary")
|
||||
}
|
||||
return database.NewColumn("is_primary")
|
||||
}
|
||||
@@ -179,7 +177,7 @@ func (orgDomain) IsPrimaryColumn(qualified bool) database.Column {
|
||||
// IsVerifiedColumn implements [domain.OrganizationDomainRepository].
|
||||
func (orgDomain) IsVerifiedColumn(qualified bool) database.Column {
|
||||
if qualified {
|
||||
return database.NewColumn("org_domains.is_verified")
|
||||
return database.NewColumn("org_domains.is_verified")
|
||||
}
|
||||
return database.NewColumn("is_verified")
|
||||
}
|
||||
@@ -187,7 +185,7 @@ func (orgDomain) IsVerifiedColumn(qualified bool) database.Column {
|
||||
// OrgIDColumn implements [domain.OrganizationDomainRepository].
|
||||
func (orgDomain) OrgIDColumn(qualified bool) database.Column {
|
||||
if qualified {
|
||||
return database.NewColumn("org_domains.org_id")
|
||||
return database.NewColumn("org_domains.org_id")
|
||||
}
|
||||
return database.NewColumn("org_id")
|
||||
}
|
||||
@@ -196,7 +194,7 @@ func (orgDomain) OrgIDColumn(qualified bool) database.Column {
|
||||
// Subtle: this method shadows the method ([domain.OrganizationRepository]).UpdatedAtColumn of orgDomain.org.
|
||||
func (orgDomain) UpdatedAtColumn(qualified bool) database.Column {
|
||||
if qualified {
|
||||
return database.NewColumn("org_domains.updated_at")
|
||||
return database.NewColumn("org_domains.updated_at")
|
||||
}
|
||||
return database.NewColumn("updated_at")
|
||||
}
|
||||
@@ -204,7 +202,7 @@ func (orgDomain) UpdatedAtColumn(qualified bool) database.Column {
|
||||
// ValidationTypeColumn implements [domain.OrganizationDomainRepository].
|
||||
func (orgDomain) ValidationTypeColumn(qualified bool) database.Column {
|
||||
if qualified {
|
||||
return database.NewColumn("org_domains.validation_type")
|
||||
return database.NewColumn("org_domains.validation_type")
|
||||
}
|
||||
return database.NewColumn("validation_type")
|
||||
}
|
||||
@@ -218,7 +216,7 @@ func scanOrganizationDomain(ctx context.Context, client database.Querier, builde
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
organizationDomain := &domain.OrganizationDomain{}
|
||||
if err := rows.(database.CollectableRows).CollectExactlyOneRow(organizationDomain); err != nil {
|
||||
return nil, err
|
||||
|
@@ -74,4 +74,3 @@ package repository_test
|
||||
// user.Human().Update(context.Background(), user.IDCondition("test"), user.SetUsername("test"))
|
||||
// })
|
||||
// }
|
||||
|
||||
|
Reference in New Issue
Block a user