fix: resolve remaining gofmt alignment and deprecated API issues

- Fix struct tag alignment in dto/types.go (AffinityClientCount)
- Fix struct literal alignment in sora_generation_service.go
- Replace deprecated google.CredentialsFromJSONWithParams with
  option.WithCredentialsJSON for service account auth (SA1019)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
erio
2026-03-07 05:20:16 +08:00
co-authored by Claude Opus 4.6
parent 4aada8a336
commit 97343ed371
3 changed files with 5 additions and 11 deletions
+1 -1
View File
@@ -193,7 +193,7 @@ type Account struct {
ClientAffinityEnabled *bool `json:"client_affinity_enabled,omitempty"`
// 亲和客户端数据(仅 admin 列表端点注入,不由 mapper 填充)
AffinityClientCount *int64 `json:"affinity_client_count,omitempty"`
AffinityClientCount *int64 `json:"affinity_client_count,omitempty"`
AffinityClients []string `json:"affinity_clients,omitempty"`
// API Key 账号配额限制
@@ -153,13 +153,7 @@ func (s *SoraGDriveStorage) buildOAuth2Service(ctx context.Context, profile *Sor
}
func (s *SoraGDriveStorage) buildServiceAccountService(ctx context.Context, profile *SoraS3Profile) (*drive.Service, error) {
creds, err := google.CredentialsFromJSONWithParams(ctx, []byte(profile.ServiceAccountJSON), google.CredentialsParams{
Scopes: []string{drive.DriveFileScope},
})
if err != nil {
return nil, fmt.Errorf("parse service account json: %w", err)
}
srv, err := drive.NewService(ctx, option.WithCredentials(creds))
srv, err := drive.NewService(ctx, option.WithCredentialsJSON([]byte(profile.ServiceAccountJSON)))
if err != nil {
return nil, fmt.Errorf("create gdrive service account service: %w", err)
}
@@ -47,9 +47,9 @@ func NewSoraGenerationService(
quotaService *SoraQuotaService,
) *SoraGenerationService {
return &SoraGenerationService{
genRepo: genRepo,
objectStorage: objectStorage,
quotaService: quotaService,
genRepo: genRepo,
objectStorage: objectStorage,
quotaService: quotaService,
}
}