From bf363b32347c2e2573f7c468fc9f221c98a6f312 Mon Sep 17 00:00:00 2001 From: Gabriel MABILLE Date: Fri, 3 Nov 2023 17:49:11 +0100 Subject: [PATCH] ServiceAccounts: Use `isManaged` in DTO instead of `isExternal` (#77634) * ServiceAccounts: Use IsManaged in DTO instead of isExternal * Revert omitempty * Modify the other DTO * Swagger --- pkg/services/serviceaccounts/models.go | 4 ++-- pkg/services/serviceaccounts/proxy/service.go | 4 ++-- pkg/services/serviceaccounts/proxy/service_test.go | 6 +++--- public/api-enterprise-spec.json | 4 ++-- public/api-merged.json | 4 ++-- public/openapi3.json | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pkg/services/serviceaccounts/models.go b/pkg/services/serviceaccounts/models.go index 90b74ee6634..d126fe57f96 100644 --- a/pkg/services/serviceaccounts/models.go +++ b/pkg/services/serviceaccounts/models.go @@ -85,7 +85,7 @@ type ServiceAccountDTO struct { // example: false IsDisabled bool `json:"isDisabled" xorm:"is_disabled"` // example: false - IsExternal bool `json:"isExternal,omitempty" xorm:"-"` + IsManaged bool `json:"isManaged,omitempty" xorm:"-"` // example: Viewer Role string `json:"role" xorm:"role"` // example: 0 @@ -157,7 +157,7 @@ type ServiceAccountProfileDTO struct { // example: [] Teams []string `json:"teams" xorm:"-"` // example: false - IsExternal bool `json:"isExternal,omitempty" xorm:"-"` + IsManaged bool `json:"isManaged,omitempty" xorm:"-"` Tokens int64 `json:"tokens,omitempty"` AccessControl map[string]bool `json:"accessControl,omitempty" xorm:"-"` diff --git a/pkg/services/serviceaccounts/proxy/service.go b/pkg/services/serviceaccounts/proxy/service.go index 62a3c9d05dc..875c4a3f48f 100644 --- a/pkg/services/serviceaccounts/proxy/service.go +++ b/pkg/services/serviceaccounts/proxy/service.go @@ -138,7 +138,7 @@ func (s *ServiceAccountsProxy) RetrieveServiceAccount(ctx context.Context, orgID } if s.isProxyEnabled { - sa.IsExternal = isExternalServiceAccount(sa.Login) + sa.IsManaged = isExternalServiceAccount(sa.Login) } return sa, nil @@ -175,7 +175,7 @@ func (s *ServiceAccountsProxy) SearchOrgServiceAccounts(ctx context.Context, que if s.isProxyEnabled { for i := range sa.ServiceAccounts { - sa.ServiceAccounts[i].IsExternal = isExternalServiceAccount(sa.ServiceAccounts[i].Login) + sa.ServiceAccounts[i].IsManaged = isExternalServiceAccount(sa.ServiceAccounts[i].Login) } } return sa, nil diff --git a/pkg/services/serviceaccounts/proxy/service_test.go b/pkg/services/serviceaccounts/proxy/service_test.go index db0325a2172..b5e6b5cce62 100644 --- a/pkg/services/serviceaccounts/proxy/service_test.go +++ b/pkg/services/serviceaccounts/proxy/service_test.go @@ -146,7 +146,7 @@ func TestProvideServiceAccount_crudServiceAccount(t *testing.T) { serviceMock.ExpectedServiceAccountProfile = tc.expectedServiceAccount sa, err := svc.RetrieveServiceAccount(context.Background(), testOrgId, testServiceAccountId) assert.NoError(t, err, tc.description) - assert.Equal(t, tc.expectedIsExternal, sa.IsExternal, tc.description) + assert.Equal(t, tc.expectedIsExternal, sa.IsManaged, tc.description) }) } }) @@ -164,8 +164,8 @@ func TestProvideServiceAccount_crudServiceAccount(t *testing.T) { res, err := svc.SearchOrgServiceAccounts(context.Background(), &serviceaccounts.SearchOrgServiceAccountsQuery{OrgID: 1}) require.Len(t, res.ServiceAccounts, 2) require.NoError(t, err) - require.False(t, res.ServiceAccounts[0].IsExternal) - require.True(t, res.ServiceAccounts[1].IsExternal) + require.False(t, res.ServiceAccounts[0].IsManaged) + require.True(t, res.ServiceAccounts[1].IsManaged) }) t.Run("should update service account", func(t *testing.T) { diff --git a/public/api-enterprise-spec.json b/public/api-enterprise-spec.json index 36113b6e632..a1335f43f03 100644 --- a/public/api-enterprise-spec.json +++ b/public/api-enterprise-spec.json @@ -6825,7 +6825,7 @@ "type": "boolean", "example": false }, - "isExternal": { + "isManaged": { "type": "boolean", "example": false }, @@ -6880,7 +6880,7 @@ "type": "boolean", "example": false }, - "isExternal": { + "isManaged": { "type": "boolean", "example": false }, diff --git a/public/api-merged.json b/public/api-merged.json index bf8b1330c52..ee7333b2152 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -18710,7 +18710,7 @@ "type": "boolean", "example": false }, - "isExternal": { + "isManaged": { "type": "boolean", "example": false }, @@ -18765,7 +18765,7 @@ "type": "boolean", "example": false }, - "isExternal": { + "isManaged": { "type": "boolean", "example": false }, diff --git a/public/openapi3.json b/public/openapi3.json index d56e135a892..e77ed17cddb 100644 --- a/public/openapi3.json +++ b/public/openapi3.json @@ -9631,7 +9631,7 @@ "example": false, "type": "boolean" }, - "isExternal": { + "isManaged": { "example": false, "type": "boolean" }, @@ -9686,7 +9686,7 @@ "example": false, "type": "boolean" }, - "isExternal": { + "isManaged": { "example": false, "type": "boolean" },