Skip to content

Commit 268c39e

Browse files
boxjanrandombenj
authored andcommitted
add forceVirtualHostedStyle for stores which only support virtual hosted style
1 parent b3d9055 commit 268c39e

7 files changed

Lines changed: 36 additions & 21 deletions

File tree

context/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ func (context *AptlyContext) GetPublishedStorage(name string) aptly.PublishedSto
393393
params.AccessKeyID, params.SecretAccessKey, params.SessionToken,
394394
params.Region, params.Endpoint, params.Bucket, params.ACL, params.Prefix, params.StorageClass,
395395
params.EncryptionMethod, params.PlusWorkaround, params.DisableMultiDel,
396-
params.ForceSigV2, params.Debug)
396+
params.ForceSigV2, params.ForceVirtualHostedStyle, params.Debug)
397397
if err != nil {
398398
Fatal(err)
399399
}

man/aptly.1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ Configuration file is stored in JSON format (default values shown below):
8484
"plusWorkaround": false,
8585
"disableMultiDel": false,
8686
"forceSigV2": false,
87+
"forceVirtualHostedStyle": false,
8788
"debug": false
8889
}
8990
},
@@ -265,6 +266,10 @@ bucket name
265266
(optional) disable Signature V4 support, useful with non\-AWS S3\-compatible object stores which do not support SigV4, shouldn\(cqt be enabled for AWS
266267
.
267268
.TP
269+
\fBforceVirtualHostedStyle\fR
270+
(optional) disable path style visit, useful with non\-AWS S3\-compatible object stores which only support virtual hosted style
271+
.
272+
.TP
268273
\fBdebug\fR
269274
(optional) enables detailed request/response dump for each S3 operation
270275
.

man/aptly.1.ronn.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Configuration file is stored in JSON format (default values shown below):
7676
"plusWorkaround": false,
7777
"disableMultiDel": false,
7878
"forceSigV2": false,
79+
"forceVirtualHostedStyle": true,
7980
"debug": false
8081
}
8182
},
@@ -251,6 +252,9 @@ and associated settings:
251252
* `forceSigV2`:
252253
(optional) disable Signature V4 support, useful with non-AWS S3-compatible object stores
253254
which do not support SigV4, shouldn't be enabled for AWS
255+
* `forceVirtualHostedStyle`:
256+
(optional) disable path style visit, useful with non-AWS S3-compatible object stores
257+
which only support virtual hosted style
254258
* `debug`:
255259
(optional) enables detailed request/response dump for each S3 operation
256260

s3/public.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,19 @@ func NewPublishedStorageRaw(
7979

8080
// NewPublishedStorage creates new instance of PublishedStorage with specified S3 access
8181
// keys, region and bucket name
82-
func NewPublishedStorage(accessKey, secretKey, sessionToken, region, endpoint, bucket, defaultACL, prefix,
83-
storageClass, encryptionMethod string, plusWorkaround, disableMultiDel, forceSigV2, debug bool) (*PublishedStorage, error) {
82+
func NewPublishedStorage(
83+
accessKey, secretKey, sessionToken, region, endpoint, bucket, defaultACL, prefix, storageClass, encryptionMethod string,
84+
plusWorkaround, disableMultiDel, forceSigV2, forceVirtualHostedStyle, debug bool) (*PublishedStorage, error) {
8485

8586
config := &aws.Config{
8687
Region: aws.String(region),
8788
}
8889

8990
if endpoint != "" {
90-
config = config.WithEndpoint(endpoint).WithS3ForcePathStyle(true)
91+
config = config.WithEndpoint(endpoint)
92+
if !forceVirtualHostedStyle {
93+
config = config.WithS3ForcePathStyle(true)
94+
}
9195
}
9296

9397
if accessKey != "" {

s3/public_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ func (s *PublishedStorageSuite) SetUpTest(c *C) {
2929
c.Assert(err, IsNil)
3030
c.Assert(s.srv, NotNil)
3131

32-
s.storage, err = NewPublishedStorage("aa", "bb", "", "test-1", s.srv.URL(), "test", "", "", "", "", false, true, false, false)
32+
s.storage, err = NewPublishedStorage("aa", "bb", "", "test-1", s.srv.URL(), "test", "", "", "", "", false, true, false, false, false)
3333
c.Assert(err, IsNil)
34-
s.prefixedStorage, err = NewPublishedStorage("aa", "bb", "", "test-1", s.srv.URL(), "test", "", "lala", "", "", false, true, false, false)
34+
s.prefixedStorage, err = NewPublishedStorage("aa", "bb", "", "test-1", s.srv.URL(), "test", "", "lala", "", "", false, true, false, false, false)
3535
c.Assert(err, IsNil)
36-
s.noSuchBucketStorage, err = NewPublishedStorage("aa", "bb", "", "test-1", s.srv.URL(), "no-bucket", "", "", "", "", false, true, false, false)
36+
s.noSuchBucketStorage, err = NewPublishedStorage("aa", "bb", "", "test-1", s.srv.URL(), "no-bucket", "", "", "", "", false, true, false, false, false)
3737
c.Assert(err, IsNil)
3838

3939
_, err = s.storage.s3.CreateBucket(&s3.CreateBucketInput{Bucket: aws.String("test")})

utils/config.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,21 @@ type FileSystemPublishRoot struct {
4646

4747
// S3PublishRoot describes single S3 publishing entry point
4848
type S3PublishRoot struct {
49-
Region string `json:"region"`
50-
Bucket string `json:"bucket"`
51-
Endpoint string `json:"endpoint"`
52-
AccessKeyID string `json:"awsAccessKeyID"`
53-
SecretAccessKey string `json:"awsSecretAccessKey"`
54-
SessionToken string `json:"awsSessionToken"`
55-
Prefix string `json:"prefix"`
56-
ACL string `json:"acl"`
57-
StorageClass string `json:"storageClass"`
58-
EncryptionMethod string `json:"encryptionMethod"`
59-
PlusWorkaround bool `json:"plusWorkaround"`
60-
DisableMultiDel bool `json:"disableMultiDel"`
61-
ForceSigV2 bool `json:"forceSigV2"`
62-
Debug bool `json:"debug"`
49+
Region string `json:"region"`
50+
Bucket string `json:"bucket"`
51+
Endpoint string `json:"endpoint"`
52+
AccessKeyID string `json:"awsAccessKeyID"`
53+
SecretAccessKey string `json:"awsSecretAccessKey"`
54+
SessionToken string `json:"awsSessionToken"`
55+
Prefix string `json:"prefix"`
56+
ACL string `json:"acl"`
57+
StorageClass string `json:"storageClass"`
58+
EncryptionMethod string `json:"encryptionMethod"`
59+
PlusWorkaround bool `json:"plusWorkaround"`
60+
DisableMultiDel bool `json:"disableMultiDel"`
61+
ForceSigV2 bool `json:"forceSigV2"`
62+
ForceVirtualHostedStyle bool `json:"forceVirtualHostedStyle"`
63+
Debug bool `json:"debug"`
6364
}
6465

6566
// SwiftPublishRoot describes single OpenStack Swift publishing entry point

utils/config_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ func (s *ConfigSuite) TestSaveConfig(c *C) {
102102
" \"plusWorkaround\": false,\n"+
103103
" \"disableMultiDel\": false,\n"+
104104
" \"forceSigV2\": false,\n"+
105+
" \"forceVirtualHostedStyle\": false,\n"+
105106
" \"debug\": false\n"+
106107
" }\n"+
107108
" },\n"+

0 commit comments

Comments
 (0)