mirror of
https://github.com/cooperspencer/gickup.git
synced 2025-05-10 17:25:34 +02:00
Fix bitbucket source, add temp token support to s3 dest (#302)
This commit is contained in:
parent
43ef607b13
commit
57a38a4d8f
5 changed files with 11 additions and 7 deletions
|
@ -121,7 +121,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
|||
Name: r.Name,
|
||||
URL: r.Links["clone"].([]interface{})[0].(map[string]interface{})["href"].(string),
|
||||
SSHURL: r.Links["clone"].([]interface{})[1].(map[string]interface{})["href"].(string),
|
||||
Token: "",
|
||||
Token: repo.Token,
|
||||
Defaultbranch: r.Mainbranch.Name,
|
||||
Origin: repo,
|
||||
Owner: user,
|
||||
|
@ -142,7 +142,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
|
|||
Name: r.Name,
|
||||
URL: r.Links["clone"].([]interface{})[0].(map[string]interface{})["href"].(string),
|
||||
SSHURL: r.Links["clone"].([]interface{})[1].(map[string]interface{})["href"].(string),
|
||||
Token: "",
|
||||
Token: repo.Token,
|
||||
Defaultbranch: r.Mainbranch.Name,
|
||||
Origin: repo,
|
||||
Owner: user,
|
||||
|
|
|
@ -102,7 +102,7 @@ func Locally(repo types.Repo, l types.Local, dry bool) bool {
|
|||
}
|
||||
} else {
|
||||
auth = &http.BasicAuth{
|
||||
Username: "xyz",
|
||||
Username: repo.Origin.User,
|
||||
Password: repo.Token,
|
||||
}
|
||||
}
|
||||
|
@ -528,7 +528,7 @@ func TempClone(repo types.Repo, tempdir string) (*git.Repository, error) {
|
|||
}
|
||||
} else {
|
||||
auth = &http.BasicAuth{
|
||||
Username: "xyz",
|
||||
Username: repo.Origin.User,
|
||||
Password: repo.Token,
|
||||
}
|
||||
}
|
||||
|
|
5
main.go
5
main.go
|
@ -237,7 +237,10 @@ func backup(repos []types.Repo, conf *types.Conf) {
|
|||
if err != nil {
|
||||
log.Error().Str("stage", "s3").Str("endpoint", d.Endpoint).Str("bucket", d.Bucket).Msg(err.Error())
|
||||
}
|
||||
|
||||
d.Token, err = d.GetKey(d.Token)
|
||||
if err != nil {
|
||||
log.Error().Str("stage", "s3").Str("endpoint", d.Endpoint).Str("bucket", d.Bucket).Msg(err.Error())
|
||||
}
|
||||
err = s3.UploadDirToS3(tempdir, d)
|
||||
if err != nil {
|
||||
log.Error().Str("stage", "s3").Str("endpoint", d.Endpoint).Str("bucket", d.Bucket).Msg(err.Error())
|
||||
|
|
4
s3/s3.go
4
s3/s3.go
|
@ -20,7 +20,7 @@ var (
|
|||
func UploadDirToS3(directory string, s3repo types.S3Repo) error {
|
||||
// Initialize minio client object.
|
||||
client, err := minio.New(s3repo.Endpoint, &minio.Options{
|
||||
Creds: credentials.NewStaticV4(s3repo.AccessKey, s3repo.SecretKey, ""),
|
||||
Creds: credentials.NewStaticV4(s3repo.AccessKey, s3repo.SecretKey, s3repo.Token),
|
||||
Secure: s3repo.UseSSL,
|
||||
Region: s3repo.Region,
|
||||
})
|
||||
|
@ -69,7 +69,7 @@ func DeleteObjectsNotInRepo(directory, bucketdir string, s3repo types.S3Repo) er
|
|||
sub = logger.CreateSubLogger("stage", "s3", "endpoint", s3repo.Endpoint, "bucket", s3repo.Bucket)
|
||||
// Initialize minio client object.
|
||||
client, err := minio.New(s3repo.Endpoint, &minio.Options{
|
||||
Creds: credentials.NewStaticV4(s3repo.AccessKey, s3repo.SecretKey, ""),
|
||||
Creds: credentials.NewStaticV4(s3repo.AccessKey, s3repo.SecretKey, s3repo.Token),
|
||||
Secure: s3repo.UseSSL,
|
||||
Region: s3repo.Region,
|
||||
})
|
||||
|
|
|
@ -539,6 +539,7 @@ type S3Repo struct {
|
|||
Endpoint string `yaml:"endpoint"`
|
||||
AccessKey string `yaml:"accesskey"`
|
||||
SecretKey string `yaml:"secretkey"`
|
||||
Token string `yaml:"token"`
|
||||
Region string `yaml:"region"`
|
||||
UseSSL bool `yaml:"usessl"`
|
||||
Structured bool `yaml:"structured"`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue