-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move the s3 and docker packages into the upload package, rename the uploader to scheduler
- Loading branch information
Showing
14 changed files
with
98 additions
and
68 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
File renamed without changes.
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package upload | ||
package scheduler | ||
|
||
import "fmt" | ||
|
||
|
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,40 @@ | ||
package scheduler | ||
|
||
import "fmt" | ||
|
||
// FileCopyJob is an upload jobs for files to S3 repositories | ||
type FileCopyJob struct { | ||
UserData interface{} | ||
Src string | ||
Dst string | ||
} | ||
|
||
// LocalPath returns the local path of the file that is uploaded | ||
func (f *FileCopyJob) LocalPath() string { | ||
return f.Src | ||
} | ||
|
||
// RemoteDest returns the destination path | ||
func (f *FileCopyJob) RemoteDest() string { | ||
return f.Dst | ||
} | ||
|
||
// Type returns JobFileCopy | ||
func (f *FileCopyJob) Type() JobType { | ||
return JobFileCopy | ||
} | ||
|
||
// GetUserData returns the UserData | ||
func (f *FileCopyJob) GetUserData() interface{} { | ||
return f.UserData | ||
} | ||
|
||
// SetUserData sets the UserData | ||
func (f *FileCopyJob) SetUserData(u interface{}) { | ||
f.UserData = u | ||
} | ||
|
||
// String returns the string representation | ||
func (f *FileCopyJob) String() string { | ||
return fmt.Sprintf("%s -> %s", f.Src, f.Dst) | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package upload | ||
package scheduler | ||
|
||
// JobType describes the type of a job | ||
type JobType int | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package upload | ||
package scheduler | ||
|
||
import "fmt" | ||
|
||
|
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,18 @@ | ||
package scheduler | ||
|
||
import "time" | ||
|
||
// Manager is an interface for upload managers | ||
type Manager interface { | ||
Add(Job) | ||
Start() | ||
Stop() | ||
} | ||
|
||
// Result result of an upload attempt | ||
type Result struct { | ||
Err error | ||
URL string | ||
Duration time.Duration | ||
Job Job | ||
} |
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 |
---|---|---|
@@ -1,31 +1,6 @@ | ||
package upload | ||
|
||
import ( | ||
"context" | ||
"time" | ||
) | ||
|
||
// S3Uploader is an interface for S3 uploader | ||
type S3Uploader interface { | ||
Upload(file, dest string) (string, error) | ||
} | ||
|
||
// DockerUploader is an interface for docker uploader | ||
type DockerUploader interface { | ||
Upload(ctx context.Context, image, dest string) (string, error) | ||
} | ||
|
||
// Manager is an interface for upload managers | ||
type Manager interface { | ||
Add(Job) | ||
Start() | ||
Stop() | ||
} | ||
|
||
// Result result of an upload attempt | ||
type Result struct { | ||
Err error | ||
URL string | ||
Duration time.Duration | ||
Job Job | ||
//Uploader is an interface for storing files in another place | ||
type Uploader interface { | ||
Upload(from, to string) (string, error) | ||
} |