Run go fmt/fix

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2026-03-13 14:16:00 +01:00
parent 8657761293
commit d5c62a9383
44 changed files with 319 additions and 364 deletions

View File

@@ -237,7 +237,7 @@ func TestAsset_List(t *testing.T) {
profileID := factory.CreateUser(owner) profileID := factory.CreateUser(owner)
// Create multiple assets // Create multiple assets
for i := 0; i < 3; i++ { for i := range 3 {
const query = ` const query = `
mutation($input: CreateAssetInput!) { mutation($input: CreateAssetInput!) {
createAsset(input: $input) { createAsset(input: $input) {

View File

@@ -16,6 +16,7 @@ package console_test
import ( import (
"fmt" "fmt"
"maps"
"strings" "strings"
"testing" "testing"
"time" "time"
@@ -114,9 +115,7 @@ func TestAudit_Create(t *testing.T) {
"organizationId": owner.GetOrganizationID().String(), "organizationId": owner.GetOrganizationID().String(),
"frameworkId": frameworkID, "frameworkId": frameworkID,
} }
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
var result struct { var result struct {
CreateAudit struct { CreateAudit struct {
@@ -254,9 +253,7 @@ func TestAudit_Create_Validation(t *testing.T) {
if !tt.skipFramework { if !tt.skipFramework {
input["frameworkId"] = frameworkID input["frameworkId"] = frameworkID
} }
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
_, err := owner.Do(query, map[string]any{"input": input}) _, err := owner.Do(query, map[string]any{"input": input})
require.Error(t, err) require.Error(t, err)
@@ -1132,7 +1129,7 @@ func TestAudit_Pagination(t *testing.T) {
frameworkID := factory.NewFramework(owner).WithName("Framework for Pagination").Create() frameworkID := factory.NewFramework(owner).WithName("Framework for Pagination").Create()
for i := 0; i < 5; i++ { for i := range 5 {
factory.NewAudit(owner, frameworkID). factory.NewAudit(owner, frameworkID).
WithName(fmt.Sprintf("Pagination Audit %d", i)). WithName(fmt.Sprintf("Pagination Audit %d", i)).
Create() Create()

View File

@@ -242,7 +242,7 @@ func TestContinualImprovement_List(t *testing.T) {
} }
` `
for i := 0; i < 3; i++ { for i := range 3 {
_, err := owner.Do(createQuery, map[string]any{ _, err := owner.Do(createQuery, map[string]any{
"input": map[string]any{ "input": map[string]any{
"organizationId": owner.GetOrganizationID().String(), "organizationId": owner.GetOrganizationID().String(),

View File

@@ -16,6 +16,7 @@ package console_test
import ( import (
"fmt" "fmt"
"maps"
"strings" "strings"
"testing" "testing"
"time" "time"
@@ -104,9 +105,7 @@ func TestDatum_Create(t *testing.T) {
"organizationId": owner.GetOrganizationID().String(), "organizationId": owner.GetOrganizationID().String(),
"ownerId": profileID, "ownerId": profileID,
} }
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
var result struct { var result struct {
CreateDatum struct { CreateDatum struct {
@@ -253,9 +252,7 @@ func TestDatum_Create_Validation(t *testing.T) {
if !tt.skipOwner { if !tt.skipOwner {
input["ownerId"] = profileID input["ownerId"] = profileID
} }
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
_, err := owner.Do(query, map[string]any{"input": input}) _, err := owner.Do(query, map[string]any{"input": input})
require.Error(t, err) require.Error(t, err)
@@ -1103,7 +1100,7 @@ func TestDatum_Pagination(t *testing.T) {
owner := testutil.NewClient(t, testutil.RoleOwner) owner := testutil.NewClient(t, testutil.RoleOwner)
profileID := factory.CreateUser(owner) profileID := factory.CreateUser(owner)
for i := 0; i < 5; i++ { for i := range 5 {
factory.NewDatum(owner, profileID). factory.NewDatum(owner, profileID).
WithName(fmt.Sprintf("Pagination Datum %d", i)). WithName(fmt.Sprintf("Pagination Datum %d", i)).
Create() Create()

View File

@@ -16,6 +16,7 @@ package console_test
import ( import (
"fmt" "fmt"
"maps"
"strings" "strings"
"testing" "testing"
"time" "time"
@@ -115,9 +116,7 @@ func TestDocument_Create(t *testing.T) {
"organizationId": owner.GetOrganizationID().String(), "organizationId": owner.GetOrganizationID().String(),
"approverIds": []string{approverProfileID}, "approverIds": []string{approverProfileID},
} }
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
var result struct { var result struct {
CreateDocument struct { CreateDocument struct {
@@ -285,9 +284,7 @@ func TestDocument_Create_Validation(t *testing.T) {
if !tt.skipApprover { if !tt.skipApprover {
input["approverIds"] = []string{approverProfileID} input["approverIds"] = []string{approverProfileID}
} }
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
_, err := owner.Do(query, map[string]any{"input": input}) _, err := owner.Do(query, map[string]any{"input": input})
require.Error(t, err) require.Error(t, err)
@@ -1120,7 +1117,7 @@ func TestDocument_Pagination(t *testing.T) {
owner := testutil.NewClient(t, testutil.RoleOwner) owner := testutil.NewClient(t, testutil.RoleOwner)
approverProfileID := factory.CreateUser(owner) approverProfileID := factory.CreateUser(owner)
for i := 0; i < 5; i++ { for i := range 5 {
factory.NewDocument(owner, approverProfileID). factory.NewDocument(owner, approverProfileID).
WithTitle(fmt.Sprintf("Pagination Document %d", i)). WithTitle(fmt.Sprintf("Pagination Document %d", i)).
Create() Create()

View File

@@ -16,6 +16,7 @@ package console_test
import ( import (
"fmt" "fmt"
"maps"
"strings" "strings"
"testing" "testing"
"time" "time"
@@ -74,9 +75,7 @@ func TestFramework_Create(t *testing.T) {
input := map[string]any{ input := map[string]any{
"organizationId": owner.GetOrganizationID().String(), "organizationId": owner.GetOrganizationID().String(),
} }
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
var result struct { var result struct {
CreateFramework struct { CreateFramework struct {
@@ -216,9 +215,7 @@ func TestFramework_Create_Validation(t *testing.T) {
if !tt.skipOrganization { if !tt.skipOrganization {
input["organizationId"] = owner.GetOrganizationID().String() input["organizationId"] = owner.GetOrganizationID().String()
} }
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
_, err := owner.Do(query, map[string]any{"input": input}) _, err := owner.Do(query, map[string]any{"input": input})
require.Error(t, err) require.Error(t, err)
@@ -753,9 +750,7 @@ func TestFramework_OmittableDescription(t *testing.T) {
` `
input := map[string]any{"id": frameworkID} input := map[string]any{"id": frameworkID}
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
var result struct { var result struct {
UpdateFramework struct { UpdateFramework struct {
@@ -1121,9 +1116,7 @@ func TestFramework_MaxLength_Validation(t *testing.T) {
input := map[string]any{ input := map[string]any{
"organizationId": owner.GetOrganizationID().String(), "organizationId": owner.GetOrganizationID().String(),
} }
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
_, err := owner.Do(query, map[string]any{"input": input}) _, err := owner.Do(query, map[string]any{"input": input})
require.Error(t, err) require.Error(t, err)
@@ -1163,9 +1156,7 @@ func TestFramework_MaxLength_Validation(t *testing.T) {
` `
input := map[string]any{"id": frameworkID} input := map[string]any{"id": frameworkID}
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
_, err := owner.Do(query, map[string]any{"input": input}) _, err := owner.Do(query, map[string]any{"input": input})
require.Error(t, err) require.Error(t, err)
@@ -1236,7 +1227,7 @@ func TestFramework_Pagination(t *testing.T) {
owner := testutil.NewClient(t, testutil.RoleOwner) owner := testutil.NewClient(t, testutil.RoleOwner)
// Create exactly 5 frameworks for pagination testing // Create exactly 5 frameworks for pagination testing
for i := 0; i < 5; i++ { for i := range 5 {
factory.NewFramework(owner). factory.NewFramework(owner).
WithName(fmt.Sprintf("Pagination Framework %d", i)). WithName(fmt.Sprintf("Pagination Framework %d", i)).
Create() Create()

View File

@@ -16,6 +16,7 @@ package console_test
import ( import (
"fmt" "fmt"
"maps"
"strings" "strings"
"testing" "testing"
"time" "time"
@@ -113,9 +114,7 @@ func TestMeasure_Create(t *testing.T) {
input := map[string]any{ input := map[string]any{
"organizationId": owner.GetOrganizationID().String(), "organizationId": owner.GetOrganizationID().String(),
} }
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
var result struct { var result struct {
CreateMeasure struct { CreateMeasure struct {
@@ -301,9 +300,7 @@ func TestMeasure_Create_Validation(t *testing.T) {
if !tt.skipOrganization { if !tt.skipOrganization {
input["organizationId"] = owner.GetOrganizationID().String() input["organizationId"] = owner.GetOrganizationID().String()
} }
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
_, err := owner.Do(query, map[string]any{"input": input}) _, err := owner.Do(query, map[string]any{"input": input})
require.Error(t, err) require.Error(t, err)
@@ -875,9 +872,7 @@ func TestMeasure_OmittableDescription(t *testing.T) {
` `
input := map[string]any{"id": measureID} input := map[string]any{"id": measureID}
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
var result struct { var result struct {
UpdateMeasure struct { UpdateMeasure struct {
@@ -1246,9 +1241,7 @@ func TestMeasure_MaxLength_Validation(t *testing.T) {
input := map[string]any{ input := map[string]any{
"organizationId": owner.GetOrganizationID().String(), "organizationId": owner.GetOrganizationID().String(),
} }
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
_, err := owner.Do(query, map[string]any{"input": input}) _, err := owner.Do(query, map[string]any{"input": input})
require.Error(t, err) require.Error(t, err)
@@ -1293,9 +1286,7 @@ func TestMeasure_MaxLength_Validation(t *testing.T) {
` `
input := map[string]any{"id": measureID} input := map[string]any{"id": measureID}
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
_, err := owner.Do(query, map[string]any{"input": input}) _, err := owner.Do(query, map[string]any{"input": input})
require.Error(t, err) require.Error(t, err)
@@ -1496,7 +1487,7 @@ func TestMeasure_Pagination(t *testing.T) {
// Create multiple measures for pagination testing // Create multiple measures for pagination testing
measureIDs := make([]string, 5) measureIDs := make([]string, 5)
for i := 0; i < 5; i++ { for i := range 5 {
measureIDs[i] = factory.NewMeasure(owner). measureIDs[i] = factory.NewMeasure(owner).
WithName(fmt.Sprintf("Pagination Measure %d", i)). WithName(fmt.Sprintf("Pagination Measure %d", i)).
Create() Create()

View File

@@ -16,6 +16,7 @@ package console_test
import ( import (
"fmt" "fmt"
"maps"
"strings" "strings"
"testing" "testing"
"time" "time"
@@ -77,9 +78,7 @@ func TestMeeting_Create(t *testing.T) {
input := map[string]any{ input := map[string]any{
"organizationId": owner.GetOrganizationID().String(), "organizationId": owner.GetOrganizationID().String(),
} }
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
var result struct { var result struct {
CreateMeeting struct { CreateMeeting struct {
@@ -211,9 +210,7 @@ func TestMeeting_Create_Validation(t *testing.T) {
if !tt.skipOrganization { if !tt.skipOrganization {
input["organizationId"] = owner.GetOrganizationID().String() input["organizationId"] = owner.GetOrganizationID().String()
} }
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
_, err := owner.Do(query, map[string]any{"input": input}) _, err := owner.Do(query, map[string]any{"input": input})
require.Error(t, err) require.Error(t, err)
@@ -1023,7 +1020,7 @@ func TestMeeting_Pagination(t *testing.T) {
t.Parallel() t.Parallel()
owner := testutil.NewClient(t, testutil.RoleOwner) owner := testutil.NewClient(t, testutil.RoleOwner)
for i := 0; i < 5; i++ { for i := range 5 {
factory.NewMeeting(owner). factory.NewMeeting(owner).
WithName(fmt.Sprintf("Pagination Meeting %d", i)). WithName(fmt.Sprintf("Pagination Meeting %d", i)).
Create() Create()

View File

@@ -323,7 +323,7 @@ func TestNonconformity_List(t *testing.T) {
} }
` `
for i := 0; i < 3; i++ { for i := range 3 {
var createResult struct { var createResult struct {
CreateNonconformity struct { CreateNonconformity struct {
NonconformityEdge struct { NonconformityEdge struct {

View File

@@ -16,6 +16,7 @@ package console_test
import ( import (
"fmt" "fmt"
"maps"
"testing" "testing"
"time" "time"
@@ -114,9 +115,7 @@ func TestProcessingActivity_Create(t *testing.T) {
input := map[string]any{ input := map[string]any{
"organizationId": owner.GetOrganizationID().String(), "organizationId": owner.GetOrganizationID().String(),
} }
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
var result struct { var result struct {
CreateProcessingActivity struct { CreateProcessingActivity struct {
@@ -193,9 +192,7 @@ func TestProcessingActivity_Create_Validation(t *testing.T) {
if !tt.skipOrganization { if !tt.skipOrganization {
input["organizationId"] = owner.GetOrganizationID().String() input["organizationId"] = owner.GetOrganizationID().String()
} }
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
_, err := owner.Do(query, map[string]any{"input": input}) _, err := owner.Do(query, map[string]any{"input": input})
require.Error(t, err) require.Error(t, err)
@@ -898,7 +895,7 @@ func TestProcessingActivity_Pagination(t *testing.T) {
t.Parallel() t.Parallel()
owner := testutil.NewClient(t, testutil.RoleOwner) owner := testutil.NewClient(t, testutil.RoleOwner)
for i := 0; i < 5; i++ { for i := range 5 {
factory.NewProcessingActivity(owner). factory.NewProcessingActivity(owner).
WithName(fmt.Sprintf("Pagination PA %d", i)). WithName(fmt.Sprintf("Pagination PA %d", i)).
Create() Create()

View File

@@ -249,7 +249,7 @@ func TestRightsRequest_List(t *testing.T) {
} }
` `
for i := 0; i < 3; i++ { for i := range 3 {
_, err := owner.Do(createQuery, map[string]any{ _, err := owner.Do(createQuery, map[string]any{
"input": map[string]any{ "input": map[string]any{
"organizationId": owner.GetOrganizationID().String(), "organizationId": owner.GetOrganizationID().String(),

View File

@@ -15,6 +15,7 @@
package console_test package console_test
import ( import (
"maps"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@@ -401,9 +402,7 @@ func TestRisk_RequiredFields(t *testing.T) {
if !tt.skipOrganization { if !tt.skipOrganization {
input["organizationId"] = owner.GetOrganizationID().String() input["organizationId"] = owner.GetOrganizationID().String()
} }
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
_, err := owner.Do(query, map[string]any{"input": input}) _, err := owner.Do(query, map[string]any{"input": input})
require.Error(t, err) require.Error(t, err)

View File

@@ -230,7 +230,7 @@ func TestVendorContact_List(t *testing.T) {
vendorID := factory.NewVendor(owner).WithName("List Contacts Vendor").Create() vendorID := factory.NewVendor(owner).WithName("List Contacts Vendor").Create()
// Create multiple contacts // Create multiple contacts
for i := 0; i < 3; i++ { for i := range 3 {
query := ` query := `
mutation CreateVendorContact($input: CreateVendorContactInput!) { mutation CreateVendorContact($input: CreateVendorContactInput!) {
createVendorContact(input: $input) { createVendorContact(input: $input) {

View File

@@ -15,6 +15,7 @@
package console_test package console_test
import ( import (
"maps"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@@ -340,9 +341,7 @@ func TestVendor_RequiredFields(t *testing.T) {
if !tt.skipOrganization { if !tt.skipOrganization {
input["organizationId"] = owner.GetOrganizationID().String() input["organizationId"] = owner.GetOrganizationID().String()
} }
for k, v := range tt.input { maps.Copy(input, tt.input)
input[k] = v
}
_, err := owner.Do(query, map[string]any{"input": input}) _, err := owner.Do(query, map[string]any{"input": input})
require.Error(t, err) require.Error(t, err)

View File

@@ -193,7 +193,7 @@ func (b *Builder) Build() (*probod.FullConfig, error) {
TokenURL: b.getEnvOrDefault("CONNECTOR_SLACK_TOKEN_URL", "https://slack.com/api/oauth.v2.access"), TokenURL: b.getEnvOrDefault("CONNECTOR_SLACK_TOKEN_URL", "https://slack.com/api/oauth.v2.access"),
Scopes: []string{"chat:write", "channels:join", "incoming-webhook"}, Scopes: []string{"chat:write", "channels:join", "incoming-webhook"},
}, },
RawSettings: map[string]interface{}{ RawSettings: map[string]any{
"signing-secret": b.getEnv("CONNECTOR_SLACK_SIGNING_SECRET"), "signing-secret": b.getEnv("CONNECTOR_SLACK_SIGNING_SECRET"),
}, },
}, },
@@ -311,7 +311,7 @@ func (b *Builder) parseOriginsList(s string) []string {
} }
var result []string var result []string
for _, part := range strings.Split(s, ",") { for part := range strings.SplitSeq(s, ",") {
part = strings.TrimSpace(part) part = strings.TrimSpace(part)
part = strings.Trim(part, "\"") part = strings.Trim(part, "\"")
if part != "" { if part != "" {

View File

@@ -329,7 +329,7 @@ func TestBuilder_Build_SlackConnector(t *testing.T) {
assert.Equal(t, "https://slack.com/oauth/v2/authorize", rawConfig.AuthURL) assert.Equal(t, "https://slack.com/oauth/v2/authorize", rawConfig.AuthURL)
assert.Equal(t, "https://slack.com/api/oauth.v2.access", rawConfig.TokenURL) assert.Equal(t, "https://slack.com/api/oauth.v2.access", rawConfig.TokenURL)
assert.Equal(t, []string{"chat:write", "channels:join", "incoming-webhook"}, rawConfig.Scopes) assert.Equal(t, []string{"chat:write", "channels:join", "incoming-webhook"}, rawConfig.Scopes)
rawSettings := connector.RawSettings.(map[string]interface{}) rawSettings := connector.RawSettings.(map[string]any)
assert.Equal(t, "slack-signing-secret", rawSettings["signing-secret"]) assert.Equal(t, "slack-signing-secret", rawSettings["signing-secret"])
} }

View File

@@ -126,7 +126,7 @@ func TestWriteConfig_CompleteConfig(t *testing.T) {
ClientSecret: "client-secret", ClientSecret: "client-secret",
Scopes: []string{"chat:write"}, Scopes: []string{"chat:write"},
}, },
RawSettings: map[string]interface{}{ RawSettings: map[string]any{
"signing-secret": "secret", "signing-secret": "secret",
}, },
}, },

View File

@@ -42,7 +42,7 @@ func (i BusinessImpact) String() string {
return string(i) return string(i)
} }
func (i *BusinessImpact) Scan(value interface{}) error { func (i *BusinessImpact) Scan(value any) error {
switch v := value.(type) { switch v := value.(type) {
case string: case string:
switch v { switch v {

View File

@@ -44,7 +44,7 @@ func (i DataSensitivity) String() string {
return string(i) return string(i)
} }
func (i *DataSensitivity) Scan(value interface{}) error { func (i *DataSensitivity) Scan(value any) error {
switch v := value.(type) { switch v := value.(type) {
case string: case string:
switch v { switch v {

View File

@@ -38,7 +38,7 @@ func (dc DocumentClassification) String() string {
} }
// Scan implements the sql.Scanner interface for database deserialization. // Scan implements the sql.Scanner interface for database deserialization.
func (dc *DocumentClassification) Scan(value interface{}) error { func (dc *DocumentClassification) Scan(value any) error {
if value == nil { if value == nil {
return nil return nil
} }

View File

@@ -31,40 +31,40 @@ import (
type ( type (
MembershipProfile struct { MembershipProfile struct {
ID gid.GID `db:"id"` ID gid.GID `db:"id"`
IdentityID gid.GID `db:"identity_id"` IdentityID gid.GID `db:"identity_id"`
OrganizationID gid.GID `db:"organization_id"` OrganizationID gid.GID `db:"organization_id"`
EmailAddress mail.Addr `db:"email_address"` EmailAddress mail.Addr `db:"email_address"`
Source ProfileSource `db:"source"` Source ProfileSource `db:"source"`
State ProfileState `db:"state"` State ProfileState `db:"state"`
FullName string `db:"full_name"` FullName string `db:"full_name"`
Kind *string `db:"kind"` Kind *string `db:"kind"`
AdditionalEmailAddresses mail.Addrs `db:"additional_email_addresses"` AdditionalEmailAddresses mail.Addrs `db:"additional_email_addresses"`
Position *string `db:"position"` Position *string `db:"position"`
ContractStartDate *time.Time `db:"contract_start_date"` ContractStartDate *time.Time `db:"contract_start_date"`
ContractEndDate *time.Time `db:"contract_end_date"` ContractEndDate *time.Time `db:"contract_end_date"`
OrganizationName string `db:"organization_name"` OrganizationName string `db:"organization_name"`
UserName *string `db:"user_name"` UserName *string `db:"user_name"`
ExternalID *string `db:"external_id"` ExternalID *string `db:"external_id"`
Nickname *string `db:"nickname"` Nickname *string `db:"nickname"`
Locale *string `db:"locale"` Locale *string `db:"locale"`
Timezone *string `db:"timezone"` Timezone *string `db:"timezone"`
ProfileUrl *string `db:"profile_url"` ProfileUrl *string `db:"profile_url"`
PreferredLanguage *string `db:"preferred_language"` PreferredLanguage *string `db:"preferred_language"`
GivenName *string `db:"given_name"` GivenName *string `db:"given_name"`
FamilyName *string `db:"family_name"` FamilyName *string `db:"family_name"`
FormattedName *string `db:"formatted_name"` FormattedName *string `db:"formatted_name"`
MiddleName *string `db:"middle_name"` MiddleName *string `db:"middle_name"`
HonorificPrefix *string `db:"honorific_prefix"` HonorificPrefix *string `db:"honorific_prefix"`
HonorificSuffix *string `db:"honorific_suffix"` HonorificSuffix *string `db:"honorific_suffix"`
EmployeeNumber *string `db:"employee_number"` EmployeeNumber *string `db:"employee_number"`
Department *string `db:"department"` Department *string `db:"department"`
CostCenter *string `db:"cost_center"` CostCenter *string `db:"cost_center"`
EnterpriseOrganization *string `db:"enterprise_organization"` EnterpriseOrganization *string `db:"enterprise_organization"`
Division *string `db:"division"` Division *string `db:"division"`
ManagerValue *string `db:"manager_value"` ManagerValue *string `db:"manager_value"`
CreatedAt time.Time `db:"created_at"` CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"` UpdatedAt time.Time `db:"updated_at"`
} }
MembershipProfiles []*MembershipProfile MembershipProfiles []*MembershipProfile
@@ -1240,7 +1240,7 @@ VALUES (
"contract_end_date": p.ContractEndDate, "contract_end_date": p.ContractEndDate,
"user_name": p.UserName, "user_name": p.UserName,
"external_id": p.ExternalID, "external_id": p.ExternalID,
"nickname": p.Nickname, "nickname": p.Nickname,
"locale": p.Locale, "locale": p.Locale,
"timezone": p.Timezone, "timezone": p.Timezone,
"profile_url": p.ProfileUrl, "profile_url": p.ProfileUrl,
@@ -1330,7 +1330,7 @@ WHERE
"contract_end_date": p.ContractEndDate, "contract_end_date": p.ContractEndDate,
"user_name": p.UserName, "user_name": p.UserName,
"external_id": p.ExternalID, "external_id": p.ExternalID,
"nickname": p.Nickname, "nickname": p.Nickname,
"locale": p.Locale, "locale": p.Locale,
"timezone": p.Timezone, "timezone": p.Timezone,
"profile_url": p.ProfileUrl, "profile_url": p.ProfileUrl,

View File

@@ -78,7 +78,7 @@ func (i VendorCategory) String() string {
return string(i) return string(i)
} }
func (i *VendorCategory) Scan(value interface{}) error { func (i *VendorCategory) Scan(value any) error {
switch v := value.(type) { switch v := value.(type) {
case string: case string:
switch v { switch v {

View File

@@ -30,13 +30,13 @@ func TestGenerate(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
keyType keys.Type keyType keys.Type
checkFunc func(t *testing.T, key interface{}) checkFunc func(t *testing.T, key any)
expectError bool expectError bool
}{ }{
{ {
name: "EC256", name: "EC256",
keyType: keys.TypeEC256, keyType: keys.TypeEC256,
checkFunc: func(t *testing.T, key interface{}) { checkFunc: func(t *testing.T, key any) {
ecKey, ok := key.(*ecdsa.PrivateKey) ecKey, ok := key.(*ecdsa.PrivateKey)
require.True(t, ok, "expected *ecdsa.PrivateKey, got %T", key) require.True(t, ok, "expected *ecdsa.PrivateKey, got %T", key)
assert.Equal(t, elliptic.P256(), ecKey.Curve, "expected P256 curve") assert.Equal(t, elliptic.P256(), ecKey.Curve, "expected P256 curve")
@@ -45,7 +45,7 @@ func TestGenerate(t *testing.T) {
{ {
name: "EC384", name: "EC384",
keyType: keys.TypeEC384, keyType: keys.TypeEC384,
checkFunc: func(t *testing.T, key interface{}) { checkFunc: func(t *testing.T, key any) {
ecKey, ok := key.(*ecdsa.PrivateKey) ecKey, ok := key.(*ecdsa.PrivateKey)
require.True(t, ok, "expected *ecdsa.PrivateKey, got %T", key) require.True(t, ok, "expected *ecdsa.PrivateKey, got %T", key)
assert.Equal(t, elliptic.P384(), ecKey.Curve, "expected P384 curve") assert.Equal(t, elliptic.P384(), ecKey.Curve, "expected P384 curve")
@@ -54,7 +54,7 @@ func TestGenerate(t *testing.T) {
{ {
name: "RSA2048", name: "RSA2048",
keyType: keys.TypeRSA2048, keyType: keys.TypeRSA2048,
checkFunc: func(t *testing.T, key interface{}) { checkFunc: func(t *testing.T, key any) {
rsaKey, ok := key.(*rsa.PrivateKey) rsaKey, ok := key.(*rsa.PrivateKey)
require.True(t, ok, "expected *rsa.PrivateKey, got %T", key) require.True(t, ok, "expected *rsa.PrivateKey, got %T", key)
bitSize := rsaKey.N.BitLen() bitSize := rsaKey.N.BitLen()
@@ -65,7 +65,7 @@ func TestGenerate(t *testing.T) {
{ {
name: "RSA4096", name: "RSA4096",
keyType: keys.TypeRSA4096, keyType: keys.TypeRSA4096,
checkFunc: func(t *testing.T, key interface{}) { checkFunc: func(t *testing.T, key any) {
rsaKey, ok := key.(*rsa.PrivateKey) rsaKey, ok := key.(*rsa.PrivateKey)
require.True(t, ok, "expected *rsa.PrivateKey, got %T", key) require.True(t, ok, "expected *rsa.PrivateKey, got %T", key)
bitSize := rsaKey.N.BitLen() bitSize := rsaKey.N.BitLen()
@@ -118,7 +118,7 @@ func TestGenerateConcurrency(t *testing.T) {
const numGoroutines = 10 const numGoroutines = 10
errorsChan := make(chan error, numGoroutines) errorsChan := make(chan error, numGoroutines)
for i := 0; i < numGoroutines; i++ { for range numGoroutines {
go func() { go func() {
key, err := keys.Generate(keyType) key, err := keys.Generate(keyType)
if err != nil { if err != nil {
@@ -133,7 +133,7 @@ func TestGenerateConcurrency(t *testing.T) {
}() }()
} }
for i := 0; i < numGoroutines; i++ { for range numGoroutines {
err := <-errorsChan err := <-errorsChan
assert.NoError(t, err, "concurrent generation failed") assert.NoError(t, err, "concurrent generation failed")
} }

View File

@@ -359,7 +359,7 @@ func TestDocumentVersionSignatureStates(t *testing.T) {
func TestLargeContent(t *testing.T) { func TestLargeContent(t *testing.T) {
// Create a large markdown content // Create a large markdown content
var largeContent strings.Builder var largeContent strings.Builder
for i := 0; i < 1000; i++ { for i := range 1000 {
largeContent.WriteString("# Section ") largeContent.WriteString("# Section ")
largeContent.WriteString(string(rune('A' + i%26))) largeContent.WriteString(string(rune('A' + i%26)))
largeContent.WriteString("\n\nThis is a paragraph with **bold** and *italic* text.\n\n") largeContent.WriteString("\n\nThis is a paragraph with **bold** and *italic* text.\n\n")

View File

@@ -95,7 +95,7 @@ func (gid GID) Timestamp() time.Time {
} }
// Scan implements the database/sql/driver.Scanner interface // Scan implements the database/sql/driver.Scanner interface
func (gid *GID) Scan(value interface{}) error { func (gid *GID) Scan(value any) error {
var str string var str string
switch v := value.(type) { switch v := value.(type) {
case string: case string:

View File

@@ -103,7 +103,7 @@ func (id TenantID) Value() (driver.Value, error) {
} }
// Scan implements the database/sql.Scanner interface // Scan implements the database/sql.Scanner interface
func (id *TenantID) Scan(value interface{}) error { func (id *TenantID) Scan(value any) error {
switch v := value.(type) { switch v := value.(type) {
case string: case string:
decoded, err := base64.RawURLEncoding.DecodeString(v) decoded, err := base64.RawURLEncoding.DecodeString(v)

View File

@@ -70,20 +70,20 @@ func ParseMargin(margin string) Margin {
margin = strings.TrimSpace(margin) margin = strings.TrimSpace(margin)
// Handle different units // Handle different units
if strings.HasSuffix(margin, "in") { if before, ok := strings.CutSuffix(margin, "in"); ok {
if val, err := strconv.ParseFloat(strings.TrimSuffix(margin, "in"), 64); err == nil { if val, err := strconv.ParseFloat(before, 64); err == nil {
return NewMarginInches(val) return NewMarginInches(val)
} }
} else if strings.HasSuffix(margin, "mm") { } else if before, ok := strings.CutSuffix(margin, "mm"); ok {
if val, err := strconv.ParseFloat(strings.TrimSuffix(margin, "mm"), 64); err == nil { if val, err := strconv.ParseFloat(before, 64); err == nil {
return NewMarginMillimeters(val) return NewMarginMillimeters(val)
} }
} else if strings.HasSuffix(margin, "cm") { } else if before, ok := strings.CutSuffix(margin, "cm"); ok {
if val, err := strconv.ParseFloat(strings.TrimSuffix(margin, "cm"), 64); err == nil { if val, err := strconv.ParseFloat(before, 64); err == nil {
return NewMarginCentimeters(val) return NewMarginCentimeters(val)
} }
} else if strings.HasSuffix(margin, "pt") { } else if before, ok := strings.CutSuffix(margin, "pt"); ok {
if val, err := strconv.ParseFloat(strings.TrimSuffix(margin, "pt"), 64); err == nil { if val, err := strconv.ParseFloat(before, 64); err == nil {
return NewMarginPoints(val) return NewMarginPoints(val)
} }
} else { } else {

View File

@@ -17,6 +17,7 @@ package policy
import ( import (
"errors" "errors"
"fmt" "fmt"
"maps"
"go.probo.inc/probo/pkg/gid" "go.probo.inc/probo/pkg/gid"
) )
@@ -108,9 +109,7 @@ func (a *Authorizer) Authorize(params AuthorizeParams) error {
} }
// Add resource attributes to context // Add resource attributes to context
for k, v := range params.ResourceAttributes { maps.Copy(conditionCtx.Resource, params.ResourceAttributes)
conditionCtx.Resource[k] = v
}
// Build authorization request // Build authorization request
req := AuthorizationRequest{ req := AuthorizationRequest{

View File

@@ -148,7 +148,7 @@ func (c Condition) Evaluate(ctx ConditionContext) bool {
// Support a comma-separated "set" value, e.g. // Support a comma-separated "set" value, e.g.
// principal.organization_ids = "org_1,org_2" // principal.organization_ids = "org_1,org_2"
if strings.Contains(resolved, ",") { if strings.Contains(resolved, ",") {
for _, item := range strings.Split(resolved, ",") { for item := range strings.SplitSeq(resolved, ",") {
if value == strings.TrimSpace(item) { if value == strings.TrimSpace(item) {
return true return true
} }
@@ -170,7 +170,7 @@ func (c Condition) Evaluate(ctx ConditionContext) bool {
} }
if strings.Contains(resolved, ",") { if strings.Contains(resolved, ",") {
for _, item := range strings.Split(resolved, ",") { for item := range strings.SplitSeq(resolved, ",") {
if value == strings.TrimSpace(item) { if value == strings.TrimSpace(item) {
return false return false
} }

View File

@@ -109,7 +109,7 @@ func (p *Provider) ListUsers(ctx context.Context) (scimclient.Users, error) {
return allUsers, nil return allUsers, nil
} }
func (p *Provider) extractOrganizationFields(raw interface{}, user *scimclient.User) { func (p *Provider) extractOrganizationFields(raw any, user *scimclient.User) {
if raw == nil { if raw == nil {
return return
} }
@@ -151,7 +151,7 @@ func (p *Provider) extractOrganizationFields(raw interface{}, user *scimclient.U
user.UserType = org.Description user.UserType = org.Description
} }
func (p *Provider) extractEmployeeNumber(raw interface{}, user *scimclient.User) { func (p *Provider) extractEmployeeNumber(raw any, user *scimclient.User) {
if raw == nil { if raw == nil {
return return
} }
@@ -178,7 +178,7 @@ func (p *Provider) extractEmployeeNumber(raw interface{}, user *scimclient.User)
} }
} }
func (p *Provider) extractRelations(raw interface{}, user *scimclient.User) { func (p *Provider) extractRelations(raw any, user *scimclient.User) {
if raw == nil { if raw == nil {
return return
} }
@@ -201,7 +201,7 @@ func (p *Provider) extractRelations(raw interface{}, user *scimclient.User) {
} }
} }
func (p *Provider) extractPreferredLanguage(raw interface{}, user *scimclient.User) { func (p *Provider) extractPreferredLanguage(raw any, user *scimclient.User) {
if raw == nil { if raw == nil {
return return
} }

View File

@@ -37,10 +37,7 @@ func (r *BridgeRunner) calculateBackoff(consecutiveFailures int) time.Duration {
// Cap the shift exponent to prevent integer overflow from the shift itself. // Cap the shift exponent to prevent integer overflow from the shift itself.
// Bit 63 is the sign bit, so shifting by 63+ produces negative or zero values. // Bit 63 is the sign bit, so shifting by 63+ produces negative or zero values.
const maxShift = 62 const maxShift = 62
shiftAmount := consecutiveFailures shiftAmount := min(consecutiveFailures, maxShift)
if shiftAmount > maxShift {
shiftAmount = maxShift
}
backoff := r.cfg.Interval * time.Duration(1<<shiftAmount) backoff := r.cfg.Interval * time.Duration(1<<shiftAmount)

View File

@@ -223,12 +223,12 @@ func (s *Service) CreateUser(
CreatedAt: now, CreatedAt: now,
UpdatedAt: now, UpdatedAt: now,
} }
if attrs.UserType != "" { if attrs.UserType != "" {
kind := attrs.UserType kind := attrs.UserType
profile.Kind = &kind profile.Kind = &kind
} }
err = profile.Insert(ctx, tx) err = profile.Insert(ctx, tx)
if err != nil { if err != nil {
if errors.Is(err, coredata.ErrResourceAlreadyExists) { if errors.Is(err, coredata.ErrResourceAlreadyExists) {
return scimerrors.ScimErrorUniqueness return scimerrors.ScimErrorUniqueness
@@ -268,11 +268,11 @@ func (s *Service) CreateUser(
profile.Division = ref.RefOrNil(attrs.Division) profile.Division = ref.RefOrNil(attrs.Division)
profile.ManagerValue = ref.RefOrNil(attrs.ManagerValue) profile.ManagerValue = ref.RefOrNil(attrs.ManagerValue)
profile.UpdatedAt = now profile.UpdatedAt = now
if attrs.UserType != "" { if attrs.UserType != "" {
kind := attrs.UserType kind := attrs.UserType
profile.Kind = &kind profile.Kind = &kind
} }
if err := profile.Update(ctx, tx, scope); err != nil { if err := profile.Update(ctx, tx, scope); err != nil {
return fmt.Errorf("cannot update profile: %w", err) return fmt.Errorf("cannot update profile: %w", err)
} }
} }
@@ -501,189 +501,189 @@ func (s *Service) updateUser(
profile.UpdatedAt = now profile.UpdatedAt = now
} }
if attrs.Title != nil { if attrs.Title != nil {
if *attrs.Title == "" { if *attrs.Title == "" {
profile.Position = nil profile.Position = nil
} else { } else {
profile.Position = attrs.Title profile.Position = attrs.Title
}
} }
}
if attrs.UserName != nil { if attrs.UserName != nil {
profile.UserName = attrs.UserName profile.UserName = attrs.UserName
profile.UpdatedAt = now profile.UpdatedAt = now
} }
if attrs.ExternalID != nil { if attrs.ExternalID != nil {
if *attrs.ExternalID == "" { if *attrs.ExternalID == "" {
profile.ExternalID = nil profile.ExternalID = nil
} else { } else {
profile.ExternalID = attrs.ExternalID profile.ExternalID = attrs.ExternalID
}
profile.UpdatedAt = now
} }
profile.UpdatedAt = now
}
if attrs.UserType != nil { if attrs.UserType != nil {
if *attrs.UserType == "" { if *attrs.UserType == "" {
profile.Kind = nil profile.Kind = nil
} else { } else {
profile.Kind = attrs.UserType profile.Kind = attrs.UserType
} }
profile.UpdatedAt = now profile.UpdatedAt = now
}
if attrs.Nickname != nil {
if *attrs.Nickname == "" {
profile.Nickname = nil
} else {
profile.Nickname = attrs.Nickname
} }
profile.UpdatedAt = now
}
if attrs.Locale != nil { if attrs.Nickname != nil {
if *attrs.Locale == "" { if *attrs.Nickname == "" {
profile.Locale = nil profile.Nickname = nil
} else { } else {
profile.Locale = attrs.Locale profile.Nickname = attrs.Nickname
}
profile.UpdatedAt = now
} }
profile.UpdatedAt = now
}
if attrs.Timezone != nil { if attrs.Locale != nil {
if *attrs.Timezone == "" { if *attrs.Locale == "" {
profile.Timezone = nil profile.Locale = nil
} else { } else {
profile.Timezone = attrs.Timezone profile.Locale = attrs.Locale
}
profile.UpdatedAt = now
} }
profile.UpdatedAt = now
}
if attrs.ProfileUrl != nil { if attrs.Timezone != nil {
if *attrs.ProfileUrl == "" { if *attrs.Timezone == "" {
profile.ProfileUrl = nil profile.Timezone = nil
} else { } else {
profile.ProfileUrl = attrs.ProfileUrl profile.Timezone = attrs.Timezone
} }
profile.UpdatedAt = now profile.UpdatedAt = now
} }
if attrs.PreferredLanguage != nil { if attrs.ProfileUrl != nil {
if *attrs.PreferredLanguage == "" { if *attrs.ProfileUrl == "" {
profile.PreferredLanguage = nil profile.ProfileUrl = nil
} else { } else {
profile.PreferredLanguage = attrs.PreferredLanguage profile.ProfileUrl = attrs.ProfileUrl
} }
profile.UpdatedAt = now profile.UpdatedAt = now
} }
if attrs.GivenName != nil { if attrs.PreferredLanguage != nil {
if *attrs.GivenName == "" { if *attrs.PreferredLanguage == "" {
profile.GivenName = nil profile.PreferredLanguage = nil
} else { } else {
profile.GivenName = attrs.GivenName profile.PreferredLanguage = attrs.PreferredLanguage
} }
profile.UpdatedAt = now profile.UpdatedAt = now
} }
if attrs.FamilyName != nil { if attrs.GivenName != nil {
if *attrs.FamilyName == "" { if *attrs.GivenName == "" {
profile.FamilyName = nil profile.GivenName = nil
} else { } else {
profile.FamilyName = attrs.FamilyName profile.GivenName = attrs.GivenName
} }
profile.UpdatedAt = now profile.UpdatedAt = now
} }
if attrs.FormattedName != nil { if attrs.FamilyName != nil {
if *attrs.FormattedName == "" { if *attrs.FamilyName == "" {
profile.FormattedName = nil profile.FamilyName = nil
} else { } else {
profile.FormattedName = attrs.FormattedName profile.FamilyName = attrs.FamilyName
} }
profile.UpdatedAt = now profile.UpdatedAt = now
} }
if attrs.MiddleName != nil { if attrs.FormattedName != nil {
if *attrs.MiddleName == "" { if *attrs.FormattedName == "" {
profile.MiddleName = nil profile.FormattedName = nil
} else { } else {
profile.MiddleName = attrs.MiddleName profile.FormattedName = attrs.FormattedName
} }
profile.UpdatedAt = now profile.UpdatedAt = now
} }
if attrs.HonorificPrefix != nil { if attrs.MiddleName != nil {
if *attrs.HonorificPrefix == "" { if *attrs.MiddleName == "" {
profile.HonorificPrefix = nil profile.MiddleName = nil
} else { } else {
profile.HonorificPrefix = attrs.HonorificPrefix profile.MiddleName = attrs.MiddleName
} }
profile.UpdatedAt = now profile.UpdatedAt = now
} }
if attrs.HonorificSuffix != nil { if attrs.HonorificPrefix != nil {
if *attrs.HonorificSuffix == "" { if *attrs.HonorificPrefix == "" {
profile.HonorificSuffix = nil profile.HonorificPrefix = nil
} else { } else {
profile.HonorificSuffix = attrs.HonorificSuffix profile.HonorificPrefix = attrs.HonorificPrefix
} }
profile.UpdatedAt = now profile.UpdatedAt = now
} }
if attrs.EmployeeNumber != nil { if attrs.HonorificSuffix != nil {
if *attrs.EmployeeNumber == "" { if *attrs.HonorificSuffix == "" {
profile.EmployeeNumber = nil profile.HonorificSuffix = nil
} else { } else {
profile.EmployeeNumber = attrs.EmployeeNumber profile.HonorificSuffix = attrs.HonorificSuffix
} }
profile.UpdatedAt = now profile.UpdatedAt = now
} }
if attrs.Department != nil { if attrs.EmployeeNumber != nil {
if *attrs.Department == "" { if *attrs.EmployeeNumber == "" {
profile.Department = nil profile.EmployeeNumber = nil
} else { } else {
profile.Department = attrs.Department profile.EmployeeNumber = attrs.EmployeeNumber
} }
profile.UpdatedAt = now profile.UpdatedAt = now
} }
if attrs.CostCenter != nil { if attrs.Department != nil {
if *attrs.CostCenter == "" { if *attrs.Department == "" {
profile.CostCenter = nil profile.Department = nil
} else { } else {
profile.CostCenter = attrs.CostCenter profile.Department = attrs.Department
} }
profile.UpdatedAt = now profile.UpdatedAt = now
} }
if attrs.EnterpriseOrganization != nil { if attrs.CostCenter != nil {
if *attrs.EnterpriseOrganization == "" { if *attrs.CostCenter == "" {
profile.EnterpriseOrganization = nil profile.CostCenter = nil
} else { } else {
profile.EnterpriseOrganization = attrs.EnterpriseOrganization profile.CostCenter = attrs.CostCenter
} }
profile.UpdatedAt = now profile.UpdatedAt = now
} }
if attrs.Division != nil { if attrs.EnterpriseOrganization != nil {
if *attrs.Division == "" { if *attrs.EnterpriseOrganization == "" {
profile.Division = nil profile.EnterpriseOrganization = nil
} else { } else {
profile.Division = attrs.Division profile.EnterpriseOrganization = attrs.EnterpriseOrganization
} }
profile.UpdatedAt = now profile.UpdatedAt = now
} }
if attrs.ManagerValue != nil { if attrs.Division != nil {
if *attrs.ManagerValue == "" { if *attrs.Division == "" {
profile.ManagerValue = nil profile.Division = nil
} else { } else {
profile.ManagerValue = attrs.ManagerValue profile.Division = attrs.Division
} }
profile.UpdatedAt = now profile.UpdatedAt = now
} }
if attrs.ManagerValue != nil {
if *attrs.ManagerValue == "" {
profile.ManagerValue = nil
} else {
profile.ManagerValue = attrs.ManagerValue
}
profile.UpdatedAt = now
}
if shouldReactivate { if shouldReactivate {
profile.State = coredata.ProfileStateActive profile.State = coredata.ProfileStateActive

View File

@@ -202,7 +202,6 @@ func (r *Resolver) ProboService(ctx context.Context, tenantID gid.TenantID) *pro
return r.probo.WithTenant(tenantID) return r.probo.WithTenant(tenantID)
} }
func (r *Resolver) Permission(ctx context.Context, obj types.Node, action string) (bool, error) { func (r *Resolver) Permission(ctx context.Context, obj types.Node, action string) (bool, error) {
return r.authorize(ctx, obj.GetID(), action) == nil, nil return r.authorize(ctx, obj.GetID(), action) == nil, nil
} }

View File

@@ -22,17 +22,17 @@ import (
) )
type TrustCenter struct { type TrustCenter struct {
ID gid.GID `json:"id"` ID gid.GID `json:"id"`
Active bool `json:"active"` Active bool `json:"active"`
LogoFileURL *string `json:"logoFileUrl,omitempty"` LogoFileURL *string `json:"logoFileUrl,omitempty"`
DarkLogoFileURL *string `json:"darkLogoFileUrl,omitempty"` DarkLogoFileURL *string `json:"darkLogoFileUrl,omitempty"`
NdaFileName *string `json:"ndaFileName,omitempty"` NdaFileName *string `json:"ndaFileName,omitempty"`
NdaFileURL *string `json:"ndaFileUrl,omitempty"` NdaFileURL *string `json:"ndaFileUrl,omitempty"`
CreatedAt time.Time `json:"createdAt"` CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"` UpdatedAt time.Time `json:"updatedAt"`
Organization *Organization `json:"organization"` Organization *Organization `json:"organization"`
Accesses *TrustCenterAccessConnection `json:"accesses"` Accesses *TrustCenterAccessConnection `json:"accesses"`
References *TrustCenterReferenceConnection `json:"references"` References *TrustCenterReferenceConnection `json:"references"`
ComplianceFrameworks *ComplianceFrameworkConnection `json:"complianceFrameworks"` ComplianceFrameworks *ComplianceFrameworkConnection `json:"complianceFrameworks"`
ExternalUrls *ComplianceExternalURLConnection `json:"externalUrls"` ExternalUrls *ComplianceExternalURLConnection `json:"externalUrls"`
MailingList *MailingList `json:"mailingList,omitempty"` MailingList *MailingList `json:"mailingList,omitempty"`

View File

@@ -26,7 +26,7 @@ type ComplianceFramework struct {
FrameworkID gid.GID `json:"-"` FrameworkID gid.GID `json:"-"`
} }
func (ComplianceFramework) IsNode() {} func (ComplianceFramework) IsNode() {}
func (cf ComplianceFramework) GetID() gid.GID { return cf.ID } func (cf ComplianceFramework) GetID() gid.GID { return cf.ID }
type ComplianceFrameworkConnection struct { type ComplianceFrameworkConnection struct {

View File

@@ -42,7 +42,7 @@ func (t TracingExtension) Validate(schema graphql.ExecutableSchema) error {
return nil return nil
} }
func (t TracingExtension) InterceptField(ctx context.Context, next graphql.Resolver) (interface{}, error) { func (t TracingExtension) InterceptField(ctx context.Context, next graphql.Resolver) (any, error) {
rootSpan := trace.SpanFromContext(ctx) rootSpan := trace.SpanFromContext(ctx)
if rootSpan.IsRecording() { if rootSpan.IsRecording() {

View File

@@ -57,7 +57,7 @@ func MarshalCursorKeyScalar(ck page.CursorKey) graphql.Marshaler {
}) })
} }
func UnmarshalCursorKeyScalar(v interface{}) (page.CursorKey, error) { func UnmarshalCursorKeyScalar(v any) (page.CursorKey, error) {
s, ok := v.(string) s, ok := v.(string)
if !ok { if !ok {
return page.CursorKeyNil, errors.New("must be a string") return page.CursorKeyNil, errors.New("must be a string")

View File

@@ -33,7 +33,7 @@ func MarshalGIDScalar(id gid.GID) graphql.Marshaler {
) )
} }
func UnmarshalGIDScalar(v interface{}) (gid.GID, error) { func UnmarshalGIDScalar(v any) (gid.GID, error) {
s, ok := v.(string) s, ok := v.(string)
if !ok { if !ok {
return gid.Nil, errors.New("must be a string") return gid.Nil, errors.New("must be a string")

View File

@@ -33,7 +33,7 @@ func MarshalAddrScalar(a mail.Addr) graphql.Marshaler {
) )
} }
func UnmarshalAddrScalar(v interface{}) (mail.Addr, error) { func UnmarshalAddrScalar(v any) (mail.Addr, error) {
s, ok := v.(string) s, ok := v.(string)
if !ok { if !ok {
return mail.Nil, errors.New("must be a string") return mail.Nil, errors.New("must be a string")

View File

@@ -39,12 +39,12 @@ func (v *Validator) Check(value any, field string, validators ...ValidatorFunc)
if value != nil { if value != nil {
val := reflect.ValueOf(value) val := reflect.ValueOf(value)
// Dereference all pointer levels // Dereference all pointer levels
for val.Kind() == reflect.Ptr && !val.IsNil() { for val.Kind() == reflect.Pointer && !val.IsNil() {
val = val.Elem() val = val.Elem()
actualValue = val.Interface() actualValue = val.Interface()
} }
// If we ended up with a nil pointer at any level, set actualValue to nil // If we ended up with a nil pointer at any level, set actualValue to nil
if val.Kind() == reflect.Ptr && val.IsNil() { if val.Kind() == reflect.Pointer && val.IsNil() {
actualValue = nil actualValue = nil
} }
} }
@@ -75,7 +75,7 @@ func (v *Validator) CheckEach(items any, field string, fn func(index int, item a
val := reflect.ValueOf(items) val := reflect.ValueOf(items)
// Dereference pointer levels to get to the actual slice // Dereference pointer levels to get to the actual slice
for val.Kind() == reflect.Ptr { for val.Kind() == reflect.Pointer {
if val.IsNil() { if val.IsNil() {
return return
} }
@@ -138,7 +138,7 @@ func dereferenceValue(value any) (any, bool) {
val := reflect.ValueOf(value) val := reflect.ValueOf(value)
// Dereference all pointer levels // Dereference all pointer levels
for val.Kind() == reflect.Ptr { for val.Kind() == reflect.Pointer {
if val.IsNil() { if val.IsNil() {
return nil, true return nil, true
} }

View File

@@ -23,7 +23,7 @@ import (
func MinItems(min int) ValidatorFunc { func MinItems(min int) ValidatorFunc {
return func(value any) *ValidationError { return func(value any) *ValidationError {
v := reflect.ValueOf(value) v := reflect.ValueOf(value)
if v.Kind() == reflect.Ptr { if v.Kind() == reflect.Pointer {
if v.IsNil() { if v.IsNil() {
return nil return nil
} }
@@ -49,7 +49,7 @@ func MinItems(min int) ValidatorFunc {
func MaxItems(max int) ValidatorFunc { func MaxItems(max int) ValidatorFunc {
return func(value any) *ValidationError { return func(value any) *ValidationError {
v := reflect.ValueOf(value) v := reflect.ValueOf(value)
if v.Kind() == reflect.Ptr { if v.Kind() == reflect.Pointer {
if v.IsNil() { if v.IsNil() {
return nil return nil
} }
@@ -75,7 +75,7 @@ func MaxItems(max int) ValidatorFunc {
func UniqueItems() ValidatorFunc { func UniqueItems() ValidatorFunc {
return func(value any) *ValidationError { return func(value any) *ValidationError {
v := reflect.ValueOf(value) v := reflect.ValueOf(value)
if v.Kind() == reflect.Ptr { if v.Kind() == reflect.Pointer {
if v.IsNil() { if v.IsNil() {
return nil return nil
} }

View File

@@ -17,6 +17,7 @@ package validator
import ( import (
"net/url" "net/url"
"regexp" "regexp"
"slices"
"go.probo.inc/probo/pkg/gid" "go.probo.inc/probo/pkg/gid"
) )
@@ -182,13 +183,7 @@ func GID(entityTypes ...uint16) ValidatorFunc {
if len(entityTypes) > 0 { if len(entityTypes) > 0 {
parsedEntityType := gidValue.EntityType() parsedEntityType := gidValue.EntityType()
valid := false valid := slices.Contains(entityTypes, parsedEntityType)
for _, expected := range entityTypes {
if parsedEntityType == expected {
valid = true
break
}
}
if !valid { if !valid {
return newValidationError(ErrorCodeInvalidGID, "GID has invalid entity type") return newValidationError(ErrorCodeInvalidGID, "GID has invalid entity type")
} }

View File

@@ -197,7 +197,7 @@ func OneOfSlice[T any](allowed []T) ValidatorFunc {
// Dereference all pointer levels // Dereference all pointer levels
actualValue := value actualValue := value
val := reflect.ValueOf(value) val := reflect.ValueOf(value)
for val.Kind() == reflect.Ptr { for val.Kind() == reflect.Pointer {
if val.IsNil() { if val.IsNil() {
return nil return nil
} }
@@ -247,7 +247,7 @@ func NotOneOfSlice[T any](disallowed []T) ValidatorFunc {
// Dereference all pointer levels // Dereference all pointer levels
actualValue := value actualValue := value
val := reflect.ValueOf(value) val := reflect.ValueOf(value)
for val.Kind() == reflect.Ptr { for val.Kind() == reflect.Pointer {
if val.IsNil() { if val.IsNil() {
return nil return nil
} }

View File

@@ -23,19 +23,19 @@ import (
) )
type User struct { type User struct {
ID gid.GID `json:"id"` ID gid.GID `json:"id"`
OrganizationID gid.GID `json:"organizationId"` OrganizationID gid.GID `json:"organizationId"`
EmailAddress mail.Addr `json:"emailAddress"` EmailAddress mail.Addr `json:"emailAddress"`
FullName string `json:"fullName"` FullName string `json:"fullName"`
Kind *string `json:"kind"` Kind *string `json:"kind"`
Source coredata.ProfileSource `json:"source"` Source coredata.ProfileSource `json:"source"`
State coredata.ProfileState `json:"state"` State coredata.ProfileState `json:"state"`
AdditionalEmailAddresses mail.Addrs `json:"additionalEmailAddresses"` AdditionalEmailAddresses mail.Addrs `json:"additionalEmailAddresses"`
Position *string `json:"position"` Position *string `json:"position"`
ContractStartDate *time.Time `json:"contractStartDate"` ContractStartDate *time.Time `json:"contractStartDate"`
ContractEndDate *time.Time `json:"contractEndDate"` ContractEndDate *time.Time `json:"contractEndDate"`
CreatedAt time.Time `json:"createdAt"` CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"` UpdatedAt time.Time `json:"updatedAt"`
} }
func NewUser(p *coredata.MembershipProfile) *User { func NewUser(p *coredata.MembershipProfile) *User {