From d394a2e3ac0d652b92e0022feac012cecb50bb16 Mon Sep 17 00:00:00 2001 From: colobas Date: Mon, 30 Oct 2017 11:46:22 +0000 Subject: [PATCH 1/5] first commit --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 7c3d609..effb38b 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,7 @@ import ( "github.com/mitchellh/cli" - "github.com/nerdalize/git-bits/command" + "github.com/jungleai/git-bits/command" ) var ( From 3ed96ca0aadacee1ab3217f8263690a24c48253d Mon Sep 17 00:00:00 2001 From: colobas Date: Mon, 30 Oct 2017 12:06:24 +0000 Subject: [PATCH 2/5] region --- bits/conf.go | 5 +++++ bits/repository.go | 1 + bits/s3.go | 4 ++-- command/install.go | 6 ++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/bits/conf.go b/bits/conf.go index db59a26..040d1d0 100644 --- a/bits/conf.go +++ b/bits/conf.go @@ -15,6 +15,9 @@ type Conf struct { //holds the aws s3 bucket name AWSS3BucketName string `json:"aws_s3_bucket_name"` + //holds the aws s3 bucket region + AWSRegion string `json:"aws_s3_bucket_region"` + //The aws key that has access to the above bucket AWSAccessKeyID string `json:"aws_access_key_id"` @@ -62,6 +65,8 @@ func (conf *Conf) OverwriteFromGit(repo *Repository) (err error) { conf.AWSAccessKeyID = fields[1] case "bits.aws-secret-access-key": conf.AWSSecretAccessKey = fields[1] + case "bits.aws-s3-bucket-region": + conf.AWSRegion = fields[1] } } diff --git a/bits/repository.go b/bits/repository.go index 818c43e..a79bb75 100644 --- a/bits/repository.go +++ b/bits/repository.go @@ -145,6 +145,7 @@ func NewRepository(dir string, output io.Writer) (repo *Repository, err error) { repo.conf.AWSS3BucketName, repo.conf.AWSAccessKeyID, repo.conf.AWSSecretAccessKey, + repo.conf.AWSRegion ) if err != nil { diff --git a/bits/s3.go b/bits/s3.go index 99f6ffd..7bd19ee 100644 --- a/bits/s3.go +++ b/bits/s3.go @@ -17,13 +17,13 @@ type S3Remote struct { repo *Repository } -func NewS3Remote(repo *Repository, remote, bucket, accessKey, secretKey string) (s3 *S3Remote, err error) { +func NewS3Remote(repo *Repository, remote, bucket, accessKey, secretKey string, region string) (s3 *S3Remote, err error) { s3 = &S3Remote{ repo: repo, gitRemote: remote, } - s3.bucket = s3gof3r.New("", s3gof3r.Keys{ + s3.bucket = s3gof3r.New(region, s3gof3r.Keys{ AccessKey: accessKey, SecretKey: secretKey, }).Bucket(bucket) diff --git a/command/install.go b/command/install.go index 86cbfdc..88eff9e 100644 --- a/command/install.go +++ b/command/install.go @@ -97,6 +97,12 @@ func (cmd *Install) Run(args []string) int { return 128 } + conf.AWSRegion, err = cmd.ui.Ask("What is the AWS region where the bucket is located?\n") + if err != nil { + cmd.ui.Error(fmt.Sprintf("failed to get input: %v", err)) + return 128 + } + conf.AWSSecretAccessKey, err = cmd.ui.AskSecret("What is your AWS Secret Key that autorizes the above access key? (input will be hidden)\n") if err != nil { cmd.ui.Error(fmt.Sprintf("failed to get input: %v", err)) From 17503f1e888f1e3652c969bf2307403abf5ae85d Mon Sep 17 00:00:00 2001 From: colobas Date: Mon, 30 Oct 2017 12:19:34 +0000 Subject: [PATCH 3/5] region --- bits/repository.go | 7 ++++++- command/install.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bits/repository.go b/bits/repository.go index a79bb75..651c4c0 100644 --- a/bits/repository.go +++ b/bits/repository.go @@ -145,7 +145,7 @@ func NewRepository(dir string, output io.Writer) (repo *Repository, err error) { repo.conf.AWSS3BucketName, repo.conf.AWSAccessKeyID, repo.conf.AWSSecretAccessKey, - repo.conf.AWSRegion + repo.conf.AWSRegion, ) if err != nil { @@ -240,6 +240,10 @@ func (repo *Repository) Install(w io.Writer, conf *Conf) (err error) { gconf["bits.aws-s3-bucket-name"] = conf.AWSS3BucketName } + if conf.AWSRegion != "" { + gconf["bits.aws-s3-bucket-region"] = conf.AWSRegion + } + if conf.AWSAccessKeyID != "" { gconf["bits.aws-access-key-id"] = conf.AWSAccessKeyID } @@ -262,6 +266,7 @@ func (repo *Repository) Install(w io.Writer, conf *Conf) (err error) { repo.conf.AWSS3BucketName, repo.conf.AWSAccessKeyID, repo.conf.AWSSecretAccessKey, + repo.conf.AWSRegion, ) if err != nil { diff --git a/command/install.go b/command/install.go index 88eff9e..53596de 100644 --- a/command/install.go +++ b/command/install.go @@ -7,7 +7,7 @@ import ( "github.com/jessevdk/go-flags" "github.com/mitchellh/cli" - "github.com/nerdalize/git-bits/bits" + "github.com/jungleai/git-bits/bits" ) var InstallOpts struct { From 02c88e703b82d5b3b7bffc70fb507761c7196cd8 Mon Sep 17 00:00:00 2001 From: colobas Date: Mon, 30 Oct 2017 13:58:18 +0000 Subject: [PATCH 4/5] cha cha changes --- bits/repository_test.go | 2 +- command/combine.go | 2 +- command/fetch.go | 2 +- command/pull.go | 2 +- command/push.go | 2 +- command/scan.go | 2 +- command/split.go | 2 +- glide.lock | 16 ++++++++++------ glide.yaml | 2 +- 9 files changed, 18 insertions(+), 14 deletions(-) diff --git a/bits/repository_test.go b/bits/repository_test.go index a169669..ba773d4 100644 --- a/bits/repository_test.go +++ b/bits/repository_test.go @@ -16,7 +16,7 @@ import ( "testing" "time" - "github.com/nerdalize/git-bits/bits" + "github.com/jungleai/git-bits/bits" ) func GitInitRemote(t *testing.T) (dir string) { diff --git a/command/combine.go b/command/combine.go index 0ce8498..4ec24cb 100644 --- a/command/combine.go +++ b/command/combine.go @@ -5,7 +5,7 @@ import ( "os" "github.com/mitchellh/cli" - "github.com/nerdalize/git-bits/bits" + "github.com/jungleai/git-bits/bits" ) type Combine struct { diff --git a/command/fetch.go b/command/fetch.go index c8028bc..d5823d9 100644 --- a/command/fetch.go +++ b/command/fetch.go @@ -5,7 +5,7 @@ import ( "os" "github.com/mitchellh/cli" - "github.com/nerdalize/git-bits/bits" + "github.com/jungleai/git-bits/bits" ) type Fetch struct { diff --git a/command/pull.go b/command/pull.go index 7747997..ed32076 100644 --- a/command/pull.go +++ b/command/pull.go @@ -5,7 +5,7 @@ import ( "os" "github.com/mitchellh/cli" - "github.com/nerdalize/git-bits/bits" + "github.com/jungleai/git-bits/bits" ) type Pull struct { diff --git a/command/push.go b/command/push.go index 6d2fc4d..a78dd2d 100644 --- a/command/push.go +++ b/command/push.go @@ -5,7 +5,7 @@ import ( "os" "github.com/mitchellh/cli" - "github.com/nerdalize/git-bits/bits" + "github.com/jungleai/git-bits/bits" ) type Push struct { diff --git a/command/scan.go b/command/scan.go index c26d459..7bb57c2 100644 --- a/command/scan.go +++ b/command/scan.go @@ -5,7 +5,7 @@ import ( "os" "github.com/mitchellh/cli" - "github.com/nerdalize/git-bits/bits" + "github.com/jungleai/git-bits/bits" ) type Scan struct { diff --git a/command/split.go b/command/split.go index 827c3e1..7f6b6f5 100644 --- a/command/split.go +++ b/command/split.go @@ -5,7 +5,7 @@ import ( "os" "github.com/mitchellh/cli" - "github.com/nerdalize/git-bits/bits" + "github.com/jungleai/git-bits/bits" ) type Split struct { diff --git a/glide.lock b/glide.lock index 92036d9..7aa67e4 100644 --- a/glide.lock +++ b/glide.lock @@ -1,10 +1,10 @@ -hash: 4fb003669fac10230575a0b78141ef639d6013a89171772914882a736b505d55 -updated: 2016-11-25T15:08:32.306532946+01:00 +hash: 17606e0631d26abc5b49fc11e6a547fa764d7e18b4a7efc41a47db8061be8e18 +updated: 2017-10-30T12:13:35.194905297Z imports: - name: github.com/armon/go-radix - version: 4239b77079c7b5d1243b7b4736304ce8ddb6f0f2 + version: 1fca145dffbcaa8fe914309b1ec0cfc67500fe61 - name: github.com/bgentry/speakeasy - version: 675b82c74c0ed12283ee81ba8a534c8982c07b85 + version: 4aabc24848ce5fd31929f7d1e4ea74d3709c14cd - name: github.com/boltdb/bolt version: 0d9f544bb94aac29c185968483459ef74d6deb5d - name: github.com/dustin/go-humanize @@ -12,9 +12,13 @@ imports: - name: github.com/jessevdk/go-flags version: 8bc97d602c3bfeb5fc6fc9b5a9c898f245495637 - name: github.com/mattn/go-isatty - version: 66b8e73f3f5cda9f96b69efd03dd3d7fc4a5cdb8 + version: a5cdd64afdee435007ee3e9f6ed4684af949d568 - name: github.com/mitchellh/cli version: fa17b36f6c61f1ddbbb08c9f6fde94b3c065a09d +- name: github.com/nerdalize/git-bits + version: 11f37a9f741b2db273eb925a9ec8e16f52676405 + subpackages: + - bits - name: github.com/restic/chunker version: bb2ecf9a98e35a0b336ffc23fc515fb6e7961577 - name: github.com/rlmcpherson/s3gof3r @@ -22,7 +26,7 @@ imports: - name: github.com/VividCortex/ewma version: c595cd886c223c6c28fc9ae2727a61b5e4693d85 - name: golang.org/x/sys - version: c200b10b5d5e122be351b67af224adc6128af5bf + version: 661970f62f5897bc0cd5fdca7e087ba8a98a8fa1 subpackages: - unix testImports: [] diff --git a/glide.yaml b/glide.yaml index e751108..5a1eab6 100644 --- a/glide.yaml +++ b/glide.yaml @@ -1,4 +1,4 @@ -package: github.com/nerdalize/git-bits +package: github.com/jungleai/git-bits import: - package: github.com/mitchellh/cli #cross-platform command lines version: fa17b36f6c61f1ddbbb08c9f6fde94b3c065a09d From 54bcc1d79f64c1ca75b1d265651a6634c3eb55ed Mon Sep 17 00:00:00 2001 From: colobas Date: Mon, 30 Oct 2017 14:36:10 +0000 Subject: [PATCH 5/5] domain --- bits/conf.go | 8 ++++---- bits/repository.go | 8 ++++---- bits/s3.go | 4 ++-- command/install.go | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bits/conf.go b/bits/conf.go index 040d1d0..d073aba 100644 --- a/bits/conf.go +++ b/bits/conf.go @@ -15,8 +15,8 @@ type Conf struct { //holds the aws s3 bucket name AWSS3BucketName string `json:"aws_s3_bucket_name"` - //holds the aws s3 bucket region - AWSRegion string `json:"aws_s3_bucket_region"` + //holds the aws s3 bucket domain + AWSDomain string `json:"aws_s3_bucket_domain"` //The aws key that has access to the above bucket AWSAccessKeyID string `json:"aws_access_key_id"` @@ -65,8 +65,8 @@ func (conf *Conf) OverwriteFromGit(repo *Repository) (err error) { conf.AWSAccessKeyID = fields[1] case "bits.aws-secret-access-key": conf.AWSSecretAccessKey = fields[1] - case "bits.aws-s3-bucket-region": - conf.AWSRegion = fields[1] + case "bits.aws-s3-bucket-domain": + conf.AWSDomain = fields[1] } } diff --git a/bits/repository.go b/bits/repository.go index 651c4c0..e16c58b 100644 --- a/bits/repository.go +++ b/bits/repository.go @@ -145,7 +145,7 @@ func NewRepository(dir string, output io.Writer) (repo *Repository, err error) { repo.conf.AWSS3BucketName, repo.conf.AWSAccessKeyID, repo.conf.AWSSecretAccessKey, - repo.conf.AWSRegion, + repo.conf.AWSDomain, ) if err != nil { @@ -240,8 +240,8 @@ func (repo *Repository) Install(w io.Writer, conf *Conf) (err error) { gconf["bits.aws-s3-bucket-name"] = conf.AWSS3BucketName } - if conf.AWSRegion != "" { - gconf["bits.aws-s3-bucket-region"] = conf.AWSRegion + if conf.AWSDomain != "" { + gconf["bits.aws-s3-bucket-domain"] = conf.AWSDomain } if conf.AWSAccessKeyID != "" { @@ -266,7 +266,7 @@ func (repo *Repository) Install(w io.Writer, conf *Conf) (err error) { repo.conf.AWSS3BucketName, repo.conf.AWSAccessKeyID, repo.conf.AWSSecretAccessKey, - repo.conf.AWSRegion, + repo.conf.AWSDomain, ) if err != nil { diff --git a/bits/s3.go b/bits/s3.go index 7bd19ee..2daf99e 100644 --- a/bits/s3.go +++ b/bits/s3.go @@ -17,13 +17,13 @@ type S3Remote struct { repo *Repository } -func NewS3Remote(repo *Repository, remote, bucket, accessKey, secretKey string, region string) (s3 *S3Remote, err error) { +func NewS3Remote(repo *Repository, remote, bucket, accessKey, secretKey string, domain string) (s3 *S3Remote, err error) { s3 = &S3Remote{ repo: repo, gitRemote: remote, } - s3.bucket = s3gof3r.New(region, s3gof3r.Keys{ + s3.bucket = s3gof3r.New(domain, s3gof3r.Keys{ AccessKey: accessKey, SecretKey: secretKey, }).Bucket(bucket) diff --git a/command/install.go b/command/install.go index 53596de..475a970 100644 --- a/command/install.go +++ b/command/install.go @@ -97,7 +97,7 @@ func (cmd *Install) Run(args []string) int { return 128 } - conf.AWSRegion, err = cmd.ui.Ask("What is the AWS region where the bucket is located?\n") + conf.AWSDomain, err = cmd.ui.Ask("What is the AWS where domain the bucket is located? (if left empty, defaults to s3.amazonaws.com)\n") if err != nil { cmd.ui.Error(fmt.Sprintf("failed to get input: %v", err)) return 128