Skip to content

Commit

Permalink
fix swift: fixed missing Content-Type headers issue (#2665)
Browse files Browse the repository at this point in the history
* fix swift: fixed missing Content-Type headers issue

Signed-off-by: Martin Chodur <[email protected]>

* chore CHANGELOG: add PR id

Signed-off-by: Martin Chodur <[email protected]>

* fix swift: fixed invalid lower range boundary

Signed-off-by: Martin Chodur <[email protected]>

* fix swift: fixed typo in ENV variable for testing bucket

Signed-off-by: Martin Chodur <[email protected]>

Co-authored-by: Giedrius Statkevičius <[email protected]>
  • Loading branch information
FUSAKLA and GiedriusS authored Jul 1, 2020
1 parent 2b10e9e commit 5f06821
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ We use *breaking* word for marking changes that are not backward compatible (rel

## Unreleased

### Fixed

* [#2665](https://github.com/thanos-io/thanos/pull/2665) Swift: fix issue with missing Content-Type HTTP headers.

### Changed

## [v0.14.0](https://github.com/thanos-io/thanos/releases) - IN PROGRESS

### Fixed
Expand Down
14 changes: 11 additions & 3 deletions pkg/objstore/swift/swift.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (c *Container) Iter(ctx context.Context, dir string, f func(string) error)
dir = strings.TrimSuffix(dir, DirDelim) + DirDelim
}

options := &objects.ListOpts{Full: false, Prefix: dir, Delimiter: DirDelim}
options := &objects.ListOpts{Full: true, Prefix: dir, Delimiter: DirDelim}
return objects.List(c.client, c.name, options).EachPage(func(page pagination.Page) (bool, error) {
objectNames, err := objects.ExtractNames(page)
if err != nil {
Expand All @@ -120,9 +120,17 @@ func (c *Container) Get(ctx context.Context, name string) (io.ReadCloser, error)

// GetRange returns a new range reader for the given object name and range.
func (c *Container) GetRange(ctx context.Context, name string, off, length int64) (io.ReadCloser, error) {
lowerLimit := ""
upperLimit := ""
if off >= 0 {
lowerLimit = fmt.Sprintf("%d", off)
}
if length > 0 {
upperLimit = fmt.Sprintf("%d", off+length-1)
}
options := objects.DownloadOpts{
Newest: true,
Range: fmt.Sprintf("bytes=%d-%d", off, off+length-1),
Range: fmt.Sprintf("bytes=%s-%s", lowerLimit, upperLimit),
}
response := objects.Download(c.client, c.name, name, options)
return response.Body, response.Err
Expand Down Expand Up @@ -251,7 +259,7 @@ func configFromEnv() SwiftConfig {
ProjectName: os.Getenv("OS_PROJECT_NAME"),
UserDomainID: os.Getenv("OS_USER_DOMAIN_ID"),
UserDomainName: os.Getenv("OS_USER_DOMAIN_NAME"),
ProjectDomainID: os.Getenv("OS_PROJET_DOMAIN_ID"),
ProjectDomainID: os.Getenv("OS_PROJECT_DOMAIN_ID"),
ProjectDomainName: os.Getenv("OS_PROJECT_DOMAIN_NAME"),
}

Expand Down

0 comments on commit 5f06821

Please sign in to comment.