forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app_files.go
36 lines (28 loc) · 1019 Bytes
/
app_files.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package appfiles
import (
"fmt"
"code.cloudfoundry.org/cli/cf/configuration/coreconfig"
"code.cloudfoundry.org/cli/cf/net"
)
//go:generate counterfeiter . Repository
type Repository interface {
ListFiles(appGUID string, instance int, path string) (files string, apiErr error)
}
type CloudControllerAppFilesRepository struct {
config coreconfig.Reader
gateway net.Gateway
}
func NewCloudControllerAppFilesRepository(config coreconfig.Reader, gateway net.Gateway) (repo CloudControllerAppFilesRepository) {
repo.config = config
repo.gateway = gateway
return
}
func (repo CloudControllerAppFilesRepository) ListFiles(appGUID string, instance int, path string) (files string, apiErr error) {
url := fmt.Sprintf("%s/v2/apps/%s/instances/%d/files/%s", repo.config.APIEndpoint(), appGUID, instance, path)
request, apiErr := repo.gateway.NewRequest("GET", url, repo.config.AccessToken(), nil)
if apiErr != nil {
return
}
files, _, apiErr = repo.gateway.PerformRequestForTextResponse(request)
return
}