Skip to content

Commit aefc2b9

Browse files
committed
Release shell script and adding bucket prefix to the path
1 parent db39ad3 commit aefc2b9

4 files changed

Lines changed: 39 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
## v0.1.1
1+
## 0.2.0
2+
3+
* [@KensoDev] - 2015/06/29 - Added the `BucketPrefix` to `AWSConfig`.
4+
Added release.sh script
5+
6+
## v0.1.0
27

38
* [@KensoDev] - 2015/06/29 - First production ready release. Pre stress
49
testing.

cmd/proxy/release.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
git tag $1
2+
gox -os="linux" -tags="$1" -output="out"

document_handler.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package proxy
22

33
import (
44
"encoding/xml"
5-
"fmt"
65
"github.com/goamz/goamz/aws"
76
"github.com/goamz/goamz/s3"
7+
"path/filepath"
88
"strings"
99
)
1010

@@ -69,14 +69,18 @@ func (d *Add) GetNameAndId() (string, string) {
6969

7070
func (d *SolrDocument) Cache(awsConfig *AWSConfig) error {
7171
if d.Name == "" {
72-
// how should this case be handled?
72+
// TODO: how should this case be handled?
7373
return nil
7474
}
75-
documentName := fmt.Sprintf("%s/%s", d.Name, d.Id)
75+
documentName := d.GetDocumentName(awsConfig)
7676
auth, _ := aws.EnvAuth()
7777
region := aws.Region{Name: awsConfig.RegionName, S3Endpoint: awsConfig.S3Endpoint}
7878
svc := s3.New(auth, region)
7979
bucketName := awsConfig.BucketName
8080
bucket := svc.Bucket(bucketName)
8181
return bucket.Put(documentName, d.content, "text/xml", s3.AuthenticatedRead, s3.Options{})
8282
}
83+
84+
func (d *SolrDocument) GetDocumentName(awsConfig *AWSConfig) string {
85+
return filepath.Join(awsConfig.BucketPrefix, d.Name, d.Id)
86+
}

document_handler_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,27 @@ func (s *DocumentSuite) TestSolrDocument(c *C) {
6464
c.Assert(solrDoc.Id, Equals, "5000000000000")
6565
c.Assert(solrDoc.Name, Equals, "Hotel")
6666
}
67+
68+
func (s *DocumentSuite) TestDocumentNameWithBucketPrevix(c *C) {
69+
doc := &SolrDocument{
70+
Id: "1",
71+
Name: "Hotel",
72+
content: []byte(""),
73+
}
74+
config := &AWSConfig{
75+
BucketPrefix: "staging",
76+
}
77+
documentName := doc.GetDocumentName(config)
78+
c.Assert(documentName, Equals, "staging/Hotel/1")
79+
}
80+
81+
func (s *DocumentSuite) TestDocumentNameWithoutBucketPrefix(c *C) {
82+
doc := &SolrDocument{
83+
Id: "1",
84+
Name: "Hotel",
85+
content: []byte(""),
86+
}
87+
config := &AWSConfig{}
88+
documentName := doc.GetDocumentName(config)
89+
c.Assert(documentName, Equals, "Hotel/1")
90+
}

0 commit comments

Comments
 (0)