Skip to content

Commit

Permalink
feat(artifact): enable gcs ListObjects (#6409)
Browse files Browse the repository at this point in the history
Signed-off-by: Tianchu Zhao <evantczhao@gmail.com>
  • Loading branch information
tczhao authored Jul 26, 2021
1 parent 8966006 commit 959ce6b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion workflow/artifacts/gcs/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,5 +302,21 @@ func uploadObject(client *storage.Client, bucket, key, localPath string) error {
}

func (g *ArtifactDriver) ListObjects(artifact *wfv1.Artifact) ([]string, error) {
return nil, fmt.Errorf("ListObjects is currently not supported for this artifact type, but it will be in a future version")
var files []string
err := waitutil.Backoff(defaultRetry,
func() (bool, error) {
log.Infof("GCS List bucekt: %s, key: %s", artifact.GCS.Bucket, artifact.GCS.Key)
client, err := g.newGCSClient()
if err != nil {
log.Warnf("Failed to create new GCS client: %v", err)
return isTransientGCSErr(err), err
}
defer client.Close()
files, err = listByPrefix(client, artifact.GCS.Bucket, artifact.GCS.Key, "")
if err != nil {
return isTransientGCSErr(err), err
}
return true, nil
})
return files, err
}

0 comments on commit 959ce6b

Please sign in to comment.