Skip to content

Commit

Permalink
Merge pull request #3116 from hashicorp/b-fix-fs
Browse files Browse the repository at this point in the history
Fix logs/fs commands
  • Loading branch information
dadgar committed Aug 29, 2017
2 parents e036b9b + 7da50ff commit f3a694f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.6.2 (August 28, 2017)

BUG FIXES:
* api/cli: Fix logs and fs api and command [GH-3116]

## 0.6.1 (August 28, 2017)

__BACKWARDS INCOMPATIBILITIES:__
Expand Down
45 changes: 45 additions & 0 deletions api/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ func (a *AllocFS) List(alloc *Allocation, path string, q *QueryOptions) ([]*Allo
if err != nil {
return nil, nil, err
}

if q == nil {
q = &QueryOptions{}
}
if q.Params == nil {
q.Params = make(map[string]string)
}

q.Params["path"] = path

var resp []*AllocFileInfo
Expand All @@ -72,6 +80,14 @@ func (a *AllocFS) Stat(alloc *Allocation, path string, q *QueryOptions) (*AllocF
if err != nil {
return nil, nil, err
}

if q == nil {
q = &QueryOptions{}
}
if q.Params == nil {
q.Params = make(map[string]string)
}

q.Params["path"] = path

var resp AllocFileInfo
Expand All @@ -89,6 +105,14 @@ func (a *AllocFS) ReadAt(alloc *Allocation, path string, offset int64, limit int
if err != nil {
return nil, err
}

if q == nil {
q = &QueryOptions{}
}
if q.Params == nil {
q.Params = make(map[string]string)
}

q.Params["path"] = path
q.Params["offset"] = strconv.FormatInt(offset, 10)
q.Params["limit"] = strconv.FormatInt(limit, 10)
Expand All @@ -107,6 +131,14 @@ func (a *AllocFS) Cat(alloc *Allocation, path string, q *QueryOptions) (io.ReadC
if err != nil {
return nil, err
}

if q == nil {
q = &QueryOptions{}
}
if q.Params == nil {
q.Params = make(map[string]string)
}

q.Params["path"] = path

r, err := nodeClient.rawQuery(fmt.Sprintf("/v1/client/fs/cat/%s", alloc.ID), q)
Expand All @@ -131,6 +163,14 @@ func (a *AllocFS) Stream(alloc *Allocation, path, origin string, offset int64,
if err != nil {
return nil, err
}

if q == nil {
q = &QueryOptions{}
}
if q.Params == nil {
q.Params = make(map[string]string)
}

q.Params["path"] = path
q.Params["offset"] = strconv.FormatInt(offset, 10)
q.Params["origin"] = origin
Expand Down Expand Up @@ -195,9 +235,14 @@ func (a *AllocFS) Logs(alloc *Allocation, follow bool, task, logType, origin str
if err != nil {
return nil, err
}

if q == nil {
q = &QueryOptions{}
}
if q.Params == nil {
q.Params = make(map[string]string)
}

q.Params["follow"] = strconv.FormatBool(follow)
q.Params["task"] = task
q.Params["type"] = logType
Expand Down

0 comments on commit f3a694f

Please sign in to comment.