forked from ga4gh/task-execution-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding in code code allowing generic shared file system as an input
- Loading branch information
Showing
8 changed files
with
132 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package tes_taskengine_worker | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"strings" | ||
) | ||
|
||
var FILE_PROTOCOL = "file://" | ||
|
||
type FileAccess struct { | ||
Allowed []string | ||
} | ||
|
||
func NewFileAccess(allowed []string) *FileAccess { | ||
return &FileAccess{Allowed: allowed} | ||
} | ||
|
||
func (self *FileAccess) Get(storage string, hostPath string, class string) error { | ||
log.Printf("Starting download of %s", storage) | ||
storage = strings.TrimPrefix(storage, FILE_PROTOCOL) | ||
found := false | ||
for _, i := range self.Allowed { | ||
if strings.HasPrefix(storage, i) { | ||
found = true | ||
} | ||
} | ||
if !found { | ||
return fmt.Errorf("Can't access file %s", storage) | ||
} | ||
if class == "File" { | ||
CopyFile(storage, hostPath) | ||
return nil | ||
} else if class == "Directory" { | ||
CopyDir(storage, hostPath) | ||
return nil | ||
} | ||
return fmt.Errorf("Unknown element type: %s", class) | ||
|
||
} | ||
|
||
func (self *FileAccess) Put(storage string, hostPath string, class string) error { | ||
log.Printf("Starting upload of %s", storage) | ||
storage = strings.TrimPrefix(storage, FILE_PROTOCOL) | ||
found := false | ||
for _, i := range self.Allowed { | ||
if strings.HasPrefix(storage, i) { | ||
found = true | ||
} | ||
} | ||
if !found { | ||
return fmt.Errorf("Can't access file %s", storage) | ||
} | ||
if class == "File" { | ||
CopyFile(hostPath, storage) | ||
return nil | ||
} else if class == "Directory" { | ||
CopyDir(hostPath, storage) | ||
return nil | ||
} | ||
return fmt.Errorf("Unknown element type: %s", class) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters