@@ -12,17 +12,17 @@ import (
1212 awsConfig "github.com/aws/aws-sdk-go-v2/config"
1313 "github.com/aws/aws-sdk-go-v2/credentials"
1414 "github.com/aws/aws-sdk-go-v2/service/s3"
15+ "github.com/calypr/data-client/drs"
1516 "github.com/calypr/data-client/fence"
17+ "github.com/calypr/data-client/hash"
1618 "github.com/calypr/data-client/indexd"
17- "github.com/calypr/data-client/indexd/drs "
18- "github.com/calypr/data-client/indexd/hash "
19+ "github.com/calypr/data-client/s3utils "
20+ "github.com/calypr/git-drs/cloud "
1921 "github.com/calypr/git-drs/common"
2022 "github.com/calypr/git-drs/drslog"
2123 "github.com/calypr/git-drs/drsmap"
2224 "github.com/calypr/git-drs/lfs"
2325 "github.com/calypr/git-drs/messages"
24- "github.com/calypr/git-drs/s3_utils"
25- "github.com/calypr/git-drs/utils"
2626)
2727
2828// getBucketDetails fetches bucket details from Gen3 using data-client.
@@ -32,7 +32,7 @@ func (inc *GitDrsIdxdClient) getBucketDetails(ctx context.Context, bucket string
3232
3333// FetchS3MetadataWithBucketDetails fetches S3 metadata given bucket details.
3434func FetchS3MetadataWithBucketDetails (ctx context.Context , s3URL , awsAccessKey , awsSecretKey , region , endpoint string , bucketDetails * fence.S3Bucket , s3Client * s3.Client , logger * slog.Logger ) (int64 , string , error ) {
35- bucket , key , err := utils .ParseS3URL (s3URL )
35+ bucket , key , err := cloud .ParseS3URL (s3URL )
3636 if err != nil {
3737 return 0 , "" , fmt .Errorf ("failed to parse S3 URL: %w" , err )
3838 }
@@ -101,7 +101,7 @@ func FetchS3MetadataWithBucketDetails(ctx context.Context, s3URL, awsAccessKey,
101101}
102102
103103func (inc * GitDrsIdxdClient ) fetchS3Metadata (ctx context.Context , s3URL , awsAccessKey , awsSecretKey , region , endpoint string , s3Client * s3.Client , httpClient * http.Client , logger * slog.Logger ) (int64 , string , error ) {
104- bucket , _ , err := utils .ParseS3URL (s3URL )
104+ bucket , _ , err := cloud .ParseS3URL (s3URL )
105105 if err != nil {
106106 return 0 , "" , fmt .Errorf ("failed to parse S3 URL: %w" , err )
107107 }
@@ -145,7 +145,7 @@ func (inc *GitDrsIdxdClient) upsertIndexdRecord(ctx context.Context, url string,
145145
146146 // If no record exists, create one
147147 logger .Debug ("creating new record" )
148- _ , relPath , _ := utils .ParseS3URL (url )
148+ _ , relPath , _ := cloud .ParseS3URL (url )
149149
150150 drsObj , err := drs .BuildDrsObj (relPath , sha256 , fileSize , uuid , inc .Config .BucketName , projectId )
151151 if err != nil {
@@ -157,11 +157,11 @@ func (inc *GitDrsIdxdClient) upsertIndexdRecord(ctx context.Context, url string,
157157 return inc .RegisterRecord (ctx , drsObj )
158158}
159159
160- func (inc * GitDrsIdxdClient ) AddURL (s3URL , sha256 , awsAccessKey , awsSecretKey , regionFlag , endpointFlag string , opts ... s3_utils .AddURLOption ) (s3_utils .S3Meta , error ) {
160+ func (inc * GitDrsIdxdClient ) AddURL (s3URL , sha256 , awsAccessKey , awsSecretKey , regionFlag , endpointFlag string , opts ... cloud .AddURLOption ) (s3utils .S3Meta , error ) {
161161 ctx , cancel := context .WithTimeout (context .Background (), 10 * time .Second )
162162 defer cancel ()
163163
164- cfg := & s3_utils .AddURLConfig {}
164+ cfg := & cloud .AddURLConfig {}
165165 for _ , opt := range opts {
166166 opt (cfg )
167167 }
@@ -170,48 +170,48 @@ func (inc *GitDrsIdxdClient) AddURL(s3URL, sha256, awsAccessKey, awsSecretKey, r
170170 inc .Logger = drslog .NewNoOpLogger ()
171171 }
172172
173- if err := s3_utils .ValidateInputs (s3URL , sha256 ); err != nil {
174- return s3_utils .S3Meta {}, err
173+ if err := s3utils .ValidateInputs (s3URL , sha256 ); err != nil {
174+ return s3utils .S3Meta {}, err
175175 }
176176
177- _ , relPath , err := utils .ParseS3URL (s3URL )
177+ _ , relPath , err := cloud .ParseS3URL (s3URL )
178178 if err != nil {
179- return s3_utils .S3Meta {}, fmt .Errorf ("failed to parse S3 URL: %w" , err )
179+ return s3utils .S3Meta {}, fmt .Errorf ("failed to parse S3 URL: %w" , err )
180180 }
181181
182- isLFS , err := lfs .IsLFSTracked (".gitattributes" , relPath )
182+ isLFS , err := lfs .IsLFSTracked (relPath )
183183 if err != nil {
184- return s3_utils .S3Meta {}, fmt .Errorf ("unable to determine if file is tracked by LFS: %w" , err )
184+ return s3utils .S3Meta {}, fmt .Errorf ("unable to determine if file is tracked by LFS: %w" , err )
185185 }
186186 if ! isLFS {
187- return s3_utils .S3Meta {}, fmt .Errorf ("file is not tracked by LFS" )
187+ return s3utils .S3Meta {}, fmt .Errorf ("file is not tracked by LFS" )
188188 }
189189
190190 inc .Logger .Debug ("Fetching S3 metadata..." )
191191 fileSize , modifiedDate , err := inc .fetchS3Metadata (ctx , s3URL , awsAccessKey , awsSecretKey , regionFlag , endpointFlag , cfg .S3Client , cfg .HttpClient , inc .Logger )
192192 if err != nil {
193- return s3_utils .S3Meta {}, fmt .Errorf ("failed to fetch S3 metadata: %w" , err )
193+ return s3utils .S3Meta {}, fmt .Errorf ("failed to fetch S3 metadata: %w" , err )
194194 }
195195
196196 inc .Logger .Debug (fmt .Sprintf ("Fetched S3 metadata successfully: %d bytes, modified: %s" , fileSize , modifiedDate ))
197197
198198 inc .Logger .Debug ("Processing indexd record..." )
199199 drsObj , err := inc .upsertIndexdRecord (ctx , s3URL , sha256 , fileSize , inc .Logger )
200200 if err != nil {
201- return s3_utils .S3Meta {}, fmt .Errorf ("failed to create indexd record: %w" , err )
201+ return s3utils .S3Meta {}, fmt .Errorf ("failed to create indexd record: %w" , err )
202202 }
203203
204204 drsObjPath , err := drsmap .GetObjectPath (common .DRS_OBJS_PATH , drsObj .Checksums .SHA256 )
205205 if err != nil {
206- return s3_utils .S3Meta {}, err
206+ return s3utils .S3Meta {}, err
207207 }
208208 if err := drsmap .WriteDrsObj (drsObj , sha256 , drsObjPath ); err != nil {
209- return s3_utils .S3Meta {}, err
209+ return s3utils .S3Meta {}, err
210210 }
211211
212212 inc .Logger .Debug ("Indexd updated" )
213213
214- return s3_utils .S3Meta {
214+ return s3utils .S3Meta {
215215 Size : fileSize ,
216216 LastModified : modifiedDate ,
217217 }, nil
0 commit comments