forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy_application_source.go
31 lines (25 loc) · 984 Bytes
/
copy_application_source.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
package copy_application_source
import (
"fmt"
"strings"
"github.com/cloudfoundry/cli/cf/configuration/core_config"
"github.com/cloudfoundry/cli/cf/net"
)
type CopyApplicationSourceRepository interface {
CopyApplication(sourceAppGuid, targetAppGuid string) error
}
type CloudControllerApplicationSourceRepository struct {
config core_config.Reader
gateway net.Gateway
}
func NewCloudControllerCopyApplicationSourceRepository(config core_config.Reader, gateway net.Gateway) *CloudControllerApplicationSourceRepository {
return &CloudControllerApplicationSourceRepository{
config: config,
gateway: gateway,
}
}
func (repo *CloudControllerApplicationSourceRepository) CopyApplication(sourceAppGuid, targetAppGuid string) error {
url := fmt.Sprintf("/v2/apps/%s/copy_bits", targetAppGuid)
body := fmt.Sprintf(`{"source_app_guid":"%s"}`, sourceAppGuid)
return repo.gateway.CreateResource(repo.config.ApiEndpoint(), url, strings.NewReader(body), new(interface{}))
}