Skip to content

Commit

Permalink
feat: implement IsDirectory for OSS (argoproj#12188)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuangkun authored Nov 14, 2023
1 parent 222d53c commit ad5ac52
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions workflow/artifacts/oss/oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,21 @@ func ListOssDirectory(bucket *oss.Bucket, objectKey string) (files []string, err
return files, nil
}

func (g *ArtifactDriver) IsDirectory(artifact *wfv1.Artifact) (bool, error) {
return false, errors.New(errors.CodeNotImplemented, "IsDirectory currently unimplemented for OSS")
// IsDirectory tests if the key is acting like a OSS directory
func (ossDriver *ArtifactDriver) IsDirectory(artifact *wfv1.Artifact) (bool, error) {
osscli, err := ossDriver.newOSSClient()
if err != nil {
return !isTransientOSSErr(err), err
}
bucketName := artifact.OSS.Bucket
bucket, err := osscli.Bucket(bucketName)
if err != nil {
return !isTransientOSSErr(err), err
}
objectName := artifact.OSS.Key
isDir, err := IsOssDirectory(bucket, objectName)
if err != nil {
return !isTransientOSSErr(err), fmt.Errorf("failed to test if %s/%s is a directory: %w", bucketName, objectName, err)
}
return isDir, nil
}

0 comments on commit ad5ac52

Please sign in to comment.