Use go 1.26 syntax

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-03-06 15:00:42 +01:00
parent 54f80596b6
commit d4b3025463
28 changed files with 136 additions and 167 deletions

View File

@@ -19,7 +19,6 @@ import (
"fmt"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/s3"
"go.gearno.de/crypto/uuid"
"go.gearno.de/kit/pg"
@@ -347,11 +346,11 @@ func (s AuditService) UploadReport(
}
_, err = s.svc.s3.PutObject(ctx, &s3.PutObjectInput{
Bucket: aws.String(s.svc.bucket),
Key: aws.String(objectKey.String()),
Bucket: new(s.svc.bucket),
Key: new(objectKey.String()),
Body: req.File.Content,
ContentType: aws.String(req.File.ContentType),
CacheControl: aws.String("private, max-age=3600"),
ContentType: new(req.File.ContentType),
CacheControl: new("private, max-age=3600"),
Metadata: map[string]string{
"type": "report",
"report-id": reportID.String(),

View File

@@ -16,7 +16,6 @@ import (
"github.com/jackc/pgx/v5"
"go.gearno.de/crypto/uuid"
"go.gearno.de/kit/pg"
"go.gearno.de/x/ref"
"go.probo.inc/probo/packages/emails"
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/docgen"
@@ -1787,12 +1786,12 @@ func (s *DocumentService) BuildAndUploadExport(ctx context.Context, exportJobID
_, err = s.svc.s3.PutObject(
ctx,
&s3.PutObjectInput{
Bucket: ref.Ref(s.svc.bucket),
Key: ref.Ref(uuid.String()),
Bucket: new(s.svc.bucket),
Key: new(uuid.String()),
Body: tempFile,
ContentLength: ref.Ref(fileInfo.Size()),
ContentType: ref.Ref("application/zip"),
CacheControl: ref.Ref("private, max-age=3600"),
ContentLength: new(fileInfo.Size()),
ContentType: new("application/zip"),
CacheControl: new("private, max-age=3600"),
Metadata: map[string]string{
"type": "document-export",
"export-job-id": exportJob.ID.String(),
@@ -2087,11 +2086,11 @@ func (s *DocumentService) GenerateDocumentExportDownloadURL(
presignedReq, err := presignClient.PresignGetObject(
ctx,
&s3.GetObjectInput{
Bucket: ref.Ref(s.svc.bucket),
Key: ref.Ref(file.FileKey),
ResponseCacheControl: ref.Ref("max-age=3600, public"),
ResponseContentType: ref.Ref(file.MimeType),
ResponseContentDisposition: ref.Ref(fmt.Sprintf("attachment; filename=\"%s\"", file.FileName)),
Bucket: new(s.svc.bucket),
Key: new(file.FileKey),
ResponseCacheControl: new("max-age=3600, public"),
ResponseContentType: new(file.MimeType),
ResponseContentDisposition: new(fmt.Sprintf("attachment; filename=\"%s\"", file.FileName)),
},
func(opts *s3.PresignOptions) {
opts.Expires = documentExportEmailExpiresIn

View File

@@ -21,7 +21,6 @@ import (
"net/url"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/s3"
"go.gearno.de/crypto/uuid"
"go.gearno.de/kit/pg"
@@ -97,11 +96,11 @@ func (s FileService) UploadAndSaveFile(
ctx,
&s3.PutObjectInput{
Bucket: &s.svc.bucket,
Key: aws.String(objectKey.String()),
Key: new(objectKey.String()),
Body: req.Content,
Metadata: s3Metadata,
ContentType: aws.String(mimeType),
CacheControl: aws.String("private, max-age=3600"),
ContentType: new(mimeType),
CacheControl: new("private, max-age=3600"),
},
)
if err != nil {
@@ -109,8 +108,8 @@ func (s FileService) UploadAndSaveFile(
}
headOutput, err := s.svc.s3.HeadObject(ctx, &s3.HeadObjectInput{
Bucket: aws.String(s.svc.bucket),
Key: aws.String(objectKey.String()),
Bucket: new(s.svc.bucket),
Key: new(objectKey.String()),
})
if err != nil {
return nil, fmt.Errorf("cannot get object metadata: %w", err)
@@ -184,7 +183,7 @@ func (s FileService) GenerateFileTempURL(
&s3.GetObjectInput{
Bucket: &s.svc.bucket,
Key: &file.FileKey,
ResponseCacheControl: aws.String("max-age=3600, public"),
ResponseCacheControl: new("max-age=3600, public"),
ResponseContentType: &file.MimeType,
ResponseContentDisposition: &contentDisposition,
},

View File

@@ -24,11 +24,9 @@ import (
"strings"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/s3"
"go.gearno.de/crypto/uuid"
"go.gearno.de/kit/pg"
"go.gearno.de/x/ref"
"go.probo.inc/probo/packages/emails"
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/gid"
@@ -255,8 +253,8 @@ func (s FrameworkService) Export(
object, err := s.svc.s3.GetObject(
ctx,
&s3.GetObjectInput{
Bucket: aws.String(s.svc.bucket),
Key: aws.String(evidence_file.FileKey),
Bucket: new(s.svc.bucket),
Key: new(evidence_file.FileKey),
},
)
if err != nil {
@@ -657,11 +655,11 @@ func (s FrameworkService) GenerateFrameworkExportDownloadURL(
presignedReq, err := presignClient.PresignGetObject(
ctx,
&s3.GetObjectInput{
Bucket: ref.Ref(s.svc.bucket),
Key: ref.Ref(file.FileKey),
ResponseCacheControl: ref.Ref("max-age=3600, public"),
ResponseContentType: ref.Ref(file.MimeType),
ResponseContentDisposition: ref.Ref(fmt.Sprintf("attachment; filename=\"%s\"", file.FileName)),
Bucket: new(s.svc.bucket),
Key: new(file.FileKey),
ResponseCacheControl: new("max-age=3600, public"),
ResponseContentType: new(file.MimeType),
ResponseContentDisposition: new(fmt.Sprintf("attachment; filename=\"%s\"", file.FileName)),
},
func(opts *s3.PresignOptions) {
opts.Expires = frameworkExportEmailExpiresIn
@@ -724,12 +722,12 @@ func (s *FrameworkService) BuildAndUploadExport(ctx context.Context, exportJobID
_, err = s.svc.s3.PutObject(
ctx,
&s3.PutObjectInput{
Bucket: ref.Ref(s.svc.bucket),
Key: ref.Ref(uuid.String()),
Bucket: new(s.svc.bucket),
Key: new(uuid.String()),
Body: tempFile,
ContentLength: ref.Ref(fileInfo.Size()),
ContentType: ref.Ref("application/zip"),
CacheControl: ref.Ref("private, max-age=3600"),
ContentLength: new(fileInfo.Size()),
ContentType: new("application/zip"),
CacheControl: new("private, max-age=3600"),
Metadata: map[string]string{
"type": "framework-export",
"export-job-id": exportJob.ID.String(),

View File

@@ -19,7 +19,6 @@ import (
"fmt"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/s3"
"go.gearno.de/kit/pg"
"go.probo.inc/probo/pkg/coredata"
@@ -88,11 +87,11 @@ func (s ReportService) GenerateDownloadURL(
presignClient := s3.NewPresignClient(s.svc.s3)
presignedReq, err := presignClient.PresignGetObject(ctx, &s3.GetObjectInput{
Bucket: aws.String(s.svc.bucket),
Key: aws.String(report.ObjectKey),
ResponseCacheControl: aws.String("max-age=3600, public"),
ResponseContentType: aws.String(report.MimeType),
ResponseContentDisposition: aws.String(fmt.Sprintf("attachment; filename=\"%s\"", report.Filename)),
Bucket: new(s.svc.bucket),
Key: new(report.ObjectKey),
ResponseCacheControl: new("max-age=3600, public"),
ResponseContentType: new(report.MimeType),
ResponseContentDisposition: new(fmt.Sprintf("attachment; filename=\"%s\"", report.Filename)),
}, func(opts *s3.PresignOptions) {
opts.Expires = expiresIn
})

View File

@@ -22,7 +22,6 @@ import (
"github.com/aws/aws-sdk-go-v2/service/s3"
"go.gearno.de/kit/log"
"go.gearno.de/kit/pg"
"go.gearno.de/x/ref"
"go.probo.inc/probo/pkg/agents"
"go.probo.inc/probo/pkg/certmanager"
"go.probo.inc/probo/pkg/coredata"
@@ -342,7 +341,7 @@ func (s *Service) lockExportJob(ctx context.Context) (*coredata.ExportJob, error
scope = coredata.NewScope(exportJob.ID.TenantID())
exportJob.Status = coredata.ExportJobStatusProcessing
exportJob.StartedAt = ref.Ref(time.Now())
exportJob.StartedAt = new(time.Now())
if err := exportJob.Update(ctx, tx, scope); err != nil {
return fmt.Errorf("cannot update %s export job: %w", exportJob.Type, err)
}
@@ -358,7 +357,7 @@ func (s *Service) lockExportJob(ctx context.Context) (*coredata.ExportJob, error
}
func (s *Service) commitFailedExport(ctx context.Context, exportJob *coredata.ExportJob, failureErr error) error {
exportJob.CompletedAt = ref.Ref(time.Now())
exportJob.CompletedAt = new(time.Now())
exportJob.Status = coredata.ExportJobStatusFailed
errorMsg := failureErr.Error()
exportJob.Error = &errorMsg
@@ -377,7 +376,7 @@ func (s *Service) commitFailedExport(ctx context.Context, exportJob *coredata.Ex
}
func (s *Service) commitSuccessfulExport(ctx context.Context, exportJob *coredata.ExportJob) error {
exportJob.CompletedAt = ref.Ref(time.Now())
exportJob.CompletedAt = new(time.Now())
exportJob.Status = coredata.ExportJobStatusCompleted
return s.pg.WithConn(

View File

@@ -23,7 +23,6 @@ import (
"path/filepath"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/s3"
"go.gearno.de/crypto/uuid"
"go.gearno.de/kit/pg"
@@ -375,11 +374,11 @@ func (s TrustCenterFileService) uploadFile(
}
_, err = s.svc.s3.PutObject(ctx, &s3.PutObjectInput{
Bucket: aws.String(s.svc.bucket),
Key: aws.String(objectKey.String()),
Bucket: new(s.svc.bucket),
Key: new(objectKey.String()),
Body: fileContent,
ContentType: aws.String(contentType),
CacheControl: aws.String("private, max-age=3600"),
ContentType: new(contentType),
CacheControl: new("private, max-age=3600"),
Metadata: map[string]string{
"type": "trust-center-file",
"trust-center-file-id": trustCenterFileID.String(),
@@ -414,7 +413,7 @@ func (s TrustCenterFileService) cleanupS3Object(ctx context.Context, s3Key strin
}
_, _ = s.svc.s3.DeleteObject(ctx, &s3.DeleteObjectInput{
Bucket: aws.String(s.svc.bucket),
Key: aws.String(s3Key),
Bucket: new(s.svc.bucket),
Key: new(s3Key),
})
}

View File

@@ -24,7 +24,6 @@ import (
"path/filepath"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/s3"
"go.gearno.de/crypto/uuid"
"go.gearno.de/kit/pg"
@@ -321,10 +320,10 @@ func (s TrustCenterReferenceService) GenerateLogoURL(
encodedFilename, encodedFilename)
presignedReq, err := presignClient.PresignGetObject(ctx, &s3.GetObjectInput{
Bucket: aws.String(s.svc.bucket),
Key: aws.String(file.FileKey),
ResponseCacheControl: aws.String("max-age=3600, public"),
ResponseContentDisposition: aws.String(contentDisposition),
Bucket: new(s.svc.bucket),
Key: new(file.FileKey),
ResponseCacheControl: new("max-age=3600, public"),
ResponseContentDisposition: new(contentDisposition),
}, func(opts *s3.PresignOptions) {
opts.Expires = duration
})
@@ -395,11 +394,11 @@ func (s TrustCenterReferenceService) uploadLogoFile(
}
_, err = s.svc.s3.PutObject(ctx, &s3.PutObjectInput{
Bucket: aws.String(s.svc.bucket),
Key: aws.String(objectKey.String()),
Bucket: new(s.svc.bucket),
Key: new(objectKey.String()),
Body: fileContent,
ContentType: aws.String(contentType),
CacheControl: aws.String("max-age=3600, public"),
ContentType: new(contentType),
CacheControl: new("max-age=3600, public"),
Metadata: map[string]string{
"type": "trust-center-reference-logo",
"trust-center-reference-id": referenceID.String(),
@@ -434,7 +433,7 @@ func (s TrustCenterReferenceService) cleanupS3Object(ctx context.Context, s3Key
}
_, _ = s.svc.s3.DeleteObject(ctx, &s3.DeleteObjectInput{
Bucket: aws.String(s.svc.bucket),
Key: aws.String(s3Key),
Bucket: new(s.svc.bucket),
Key: new(s3Key),
})
}

View File

@@ -24,7 +24,6 @@ import (
"path/filepath"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/s3"
"go.gearno.de/crypto/uuid"
"go.gearno.de/kit/pg"
@@ -232,10 +231,10 @@ func (s TrustCenterService) UploadNDA(
_, err := s.svc.s3.PutObject(ctx, &s3.PutObjectInput{
Bucket: &s.svc.bucket,
Key: aws.String(objectKey.String()),
Key: new(objectKey.String()),
Body: req.File,
ContentType: &mimeType,
CacheControl: aws.String("private, max-age=3600"),
CacheControl: new("private, max-age=3600"),
Metadata: map[string]string{
"type": "trust-center-nda",
"trust-center-id": req.TrustCenterID.String(),
@@ -247,8 +246,8 @@ func (s TrustCenterService) UploadNDA(
}
headOutput, err := s.svc.s3.HeadObject(ctx, &s3.HeadObjectInput{
Bucket: aws.String(s.svc.bucket),
Key: aws.String(objectKey.String()),
Bucket: new(s.svc.bucket),
Key: new(objectKey.String()),
})
if err != nil {
return fmt.Errorf("cannot get object metadata: %w", err)
@@ -410,10 +409,10 @@ func (s TrustCenterService) uploadFile(
_, err = s.svc.s3.PutObject(ctx, &s3.PutObjectInput{
Bucket: &s.svc.bucket,
Key: aws.String(objectKey.String()),
Key: new(objectKey.String()),
Body: fileUpload.Content,
ContentType: &mimeType,
CacheControl: aws.String("max-age=3600, public"),
CacheControl: new("max-age=3600, public"),
Metadata: map[string]string{
"type": fileType,
"trust-center-id": trustCenter.ID.String(),
@@ -425,8 +424,8 @@ func (s TrustCenterService) uploadFile(
}
headOutput, err := s.svc.s3.HeadObject(ctx, &s3.HeadObjectInput{
Bucket: aws.String(s.svc.bucket),
Key: aws.String(objectKey.String()),
Bucket: new(s.svc.bucket),
Key: new(objectKey.String()),
})
if err != nil {
return nil, fmt.Errorf("cannot get object metadata: %w", err)

View File

@@ -23,7 +23,6 @@ import (
"path/filepath"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/s3"
"go.gearno.de/crypto/uuid"
"go.gearno.de/kit/pg"
@@ -127,10 +126,10 @@ func (s VendorBusinessAssociateAgreementService) Upload(
_, err := s.svc.s3.PutObject(ctx, &s3.PutObjectInput{
Bucket: &s.svc.bucket,
Key: aws.String(objectKey.String()),
Key: new(objectKey.String()),
Body: req.File,
ContentType: &mimeType,
CacheControl: aws.String("private, max-age=3600"),
CacheControl: new("private, max-age=3600"),
Metadata: map[string]string{
"type": "vendor-business-associate-agreement",
"vendor-id": vendorID.String(),
@@ -142,8 +141,8 @@ func (s VendorBusinessAssociateAgreementService) Upload(
}
headOutput, err := s.svc.s3.HeadObject(ctx, &s3.HeadObjectInput{
Bucket: aws.String(s.svc.bucket),
Key: aws.String(objectKey.String()),
Bucket: new(s.svc.bucket),
Key: new(objectKey.String()),
})
if err != nil {
return fmt.Errorf("cannot get object metadata: %w", err)
@@ -259,10 +258,10 @@ func (s VendorBusinessAssociateAgreementService) GenerateFileURL(
encodedFilename, encodedFilename)
presignedReq, err := presignClient.PresignGetObject(ctx, &s3.GetObjectInput{
Bucket: aws.String(s.svc.bucket),
Key: aws.String(file.FileKey),
ResponseCacheControl: aws.String("max-age=3600, public"),
ResponseContentDisposition: aws.String(contentDisposition),
Bucket: new(s.svc.bucket),
Key: new(file.FileKey),
ResponseCacheControl: new("max-age=3600, public"),
ResponseContentDisposition: new(contentDisposition),
}, func(opts *s3.PresignOptions) {
opts.Expires = expiresIn
})

View File

@@ -23,7 +23,6 @@ import (
"path/filepath"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/s3"
"go.gearno.de/crypto/uuid"
"go.gearno.de/kit/pg"
@@ -127,10 +126,10 @@ func (s VendorDataPrivacyAgreementService) Upload(
mimeType := mime.TypeByExtension(filepath.Ext(req.FileName))
_, err := s.svc.s3.PutObject(ctx, &s3.PutObjectInput{
Bucket: &s.svc.bucket,
Key: aws.String(objectKey.String()),
Key: new(objectKey.String()),
Body: req.File,
ContentType: &mimeType,
CacheControl: aws.String("private, max-age=3600"),
CacheControl: new("private, max-age=3600"),
Metadata: map[string]string{
"type": "vendor-data-privacy-agreement",
"vendor-id": vendorID.String(),
@@ -141,8 +140,8 @@ func (s VendorDataPrivacyAgreementService) Upload(
return fmt.Errorf("cannot upload file to S3: %w", err)
}
headOutput, err := s.svc.s3.HeadObject(ctx, &s3.HeadObjectInput{
Bucket: aws.String(s.svc.bucket),
Key: aws.String(objectKey.String()),
Bucket: new(s.svc.bucket),
Key: new(objectKey.String()),
})
if err != nil {
return fmt.Errorf("cannot get object metadata: %w", err)
@@ -257,10 +256,10 @@ func (s VendorDataPrivacyAgreementService) GenerateFileURL(
encodedFilename, encodedFilename)
presignedReq, err := presignClient.PresignGetObject(ctx, &s3.GetObjectInput{
Bucket: aws.String(s.svc.bucket),
Key: aws.String(file.FileKey),
ResponseCacheControl: aws.String("max-age=3600, public"),
ResponseContentDisposition: aws.String(contentDisposition),
Bucket: new(s.svc.bucket),
Key: new(file.FileKey),
ResponseCacheControl: new("max-age=3600, public"),
ResponseContentDisposition: new(contentDisposition),
}, func(opts *s3.PresignOptions) {
opts.Expires = expiresIn
})