@@ -84,6 +84,7 @@ import (
84
84
"encoding/base64"
85
85
"errors"
86
86
"fmt"
87
+ "hash/fnv"
87
88
"io"
88
89
"io/fs"
89
90
"net/http"
@@ -119,6 +120,12 @@ type ArtifactContext struct {
119
120
Resp http.ResponseWriter
120
121
}
121
122
123
+ func artifactNameToID (s string ) int64 {
124
+ h := fnv .New64a ()
125
+ h .Write ([]byte (s ))
126
+ return int64 (h .Sum64 ())
127
+ }
128
+
122
129
func (c ArtifactContext ) Error (status int , _ ... interface {}) {
123
130
c .Resp .WriteHeader (status )
124
131
}
@@ -342,7 +349,7 @@ func (r *artifactV4Routes) finalizeArtifact(ctx *ArtifactContext) {
342
349
343
350
respData := FinalizeArtifactResponse {
344
351
Ok : true ,
345
- ArtifactId : 1 ,
352
+ ArtifactId : artifactNameToID ( req . Name ) ,
346
353
}
347
354
r .sendProtbufBody (ctx , & respData )
348
355
}
@@ -368,11 +375,12 @@ func (r *artifactV4Routes) listArtifacts(ctx *ArtifactContext) {
368
375
list := []* ListArtifactsResponse_MonolithArtifact {}
369
376
370
377
for _ , entry := range entries {
371
- if req .NameFilter == nil || req .NameFilter .Value == entry .Name () {
378
+ id := artifactNameToID (entry .Name ())
379
+ if (req .NameFilter == nil || req .NameFilter .Value == entry .Name ()) || (req .IdFilter == nil || req .IdFilter .Value == id ) {
372
380
data := & ListArtifactsResponse_MonolithArtifact {
373
381
Name : entry .Name (),
374
382
CreatedAt : timestamppb .Now (),
375
- DatabaseId : 1 ,
383
+ DatabaseId : id ,
376
384
WorkflowRunBackendId : req .WorkflowRunBackendId ,
377
385
WorkflowJobRunBackendId : req .WorkflowJobRunBackendId ,
378
386
Size : 0 ,
@@ -442,7 +450,7 @@ func (r *artifactV4Routes) deleteArtifact(ctx *ArtifactContext) {
442
450
443
451
respData := DeleteArtifactResponse {
444
452
Ok : true ,
445
- ArtifactId : 1 ,
453
+ ArtifactId : artifactNameToID ( req . Name ) ,
446
454
}
447
455
r .sendProtbufBody (ctx , & respData )
448
456
}
0 commit comments