Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clients/mtaclient/fakes/fake_mta_client_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func (fb *FakeMtaClientBuilder) StartUploadMtaArchiveFromUrl(fileUrl string, nam
fb.FakeMtaClient.StartUploadMtaArchiveFromUrlReturnsOnCall(fileUrl, namespace, result, resultError)
return fb
}
func (fb *FakeMtaClientBuilder) GetAsyncUploadJob(jobId string, namespace *string, appInstanceId string, result mtaclient.AsyncUploadJobResult, resultErr error) *FakeMtaClientBuilder {
fb.FakeMtaClient.GetAsyncUploadJobReturnsOnCall(jobId, namespace, appInstanceId, result, resultErr)
func (fb *FakeMtaClientBuilder) GetAsyncUploadJob(jobId string, namespace *string, result mtaclient.AsyncUploadJobResult, resultErr error) *FakeMtaClientBuilder {
fb.FakeMtaClient.GetAsyncUploadJobReturnsOnCall(jobId, namespace, result, resultErr)
return fb
}
func (fb *FakeMtaClientBuilder) GetMtaOperationLogContent(operationID, logID string, result string, resultError error) *FakeMtaClientBuilder {
Expand Down
11 changes: 6 additions & 5 deletions clients/mtaclient/fakes/fake_mta_client_operations.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package fakes

import (
"github.com/cloudfoundry-incubator/multiapps-cli-plugin/util"
"net/http"
"sync"

"github.com/cloudfoundry-incubator/multiapps-cli-plugin/util"

"github.com/cloudfoundry-incubator/multiapps-cli-plugin/clients/models"
"github.com/cloudfoundry-incubator/multiapps-cli-plugin/clients/mtaclient"
)
Expand Down Expand Up @@ -706,18 +707,18 @@ func (fake *FakeMtaClientOperations) StartUploadMtaArchiveFromUrlReturnsOnCall(f
fake.startUploadMtaArchiveFromUrlMutex.Unlock()
}

func (fake *FakeMtaClientOperations) GetAsyncUploadJob(jobId string, namespace *string, appInstanceId string) (mtaclient.AsyncUploadJobResult, error) {
func (fake *FakeMtaClientOperations) GetAsyncUploadJob(jobId string, namespace *string) (mtaclient.AsyncUploadJobResult, error) {
fake.getAsyncUploadJobMutex.Lock()
result, specificReturn := fake.getAsyncUploadJobReturnsOnCall[jobId]
fake.recordInvocation("GetAsyncUploadJob", []interface{}{jobId, namespace, appInstanceId})
fake.recordInvocation("GetAsyncUploadJob", []interface{}{jobId, namespace})
fake.getAsyncUploadJobMutex.Unlock()
if specificReturn {
return result.result, result.err
}
return fake.getAsyncUploadJobReturns.result1, fake.startUploadMtaArchiveFromUrlReturns.result2
}

func (fake *FakeMtaClientOperations) GetAsyncUploadJobReturnsOnCall(jobId string, namespace *string, appInstanceId string, result mtaclient.AsyncUploadJobResult, err error) {
func (fake *FakeMtaClientOperations) GetAsyncUploadJobReturnsOnCall(jobId string, namespace *string, result mtaclient.AsyncUploadJobResult, err error) {
fake.getAsyncUploadJobMutex.Lock()
if fake.getAsyncUploadJobReturnsOnCall == nil {
fake.getAsyncUploadJobReturnsOnCall = make(map[string]struct {
Expand All @@ -729,7 +730,7 @@ func (fake *FakeMtaClientOperations) GetAsyncUploadJobReturnsOnCall(jobId string
result mtaclient.AsyncUploadJobResult
err error
}{result, err}
fake.recordInvocation("GetAsyncUploadJob", []interface{}{jobId, namespace, appInstanceId})
fake.recordInvocation("GetAsyncUploadJob", []interface{}{jobId, namespace})
fake.getAsyncUploadJobMutex.Unlock()
}

Expand Down
2 changes: 1 addition & 1 deletion clients/mtaclient/mta_client_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type MtaClientOperations interface {
StartMtaOperation(operation models.Operation) (ResponseHeader, error)
UploadMtaFile(file util.NamedReadSeeker, fileSize int64, namespace *string) (*models.FileMetadata, error)
StartUploadMtaArchiveFromUrl(fileUrl string, namespace *string) (http.Header, error)
GetAsyncUploadJob(jobId string, namespace *string, appInstanceId string) (AsyncUploadJobResult, error)
GetAsyncUploadJob(jobId string, namespace *string) (AsyncUploadJobResult, error)
GetMtaOperationLogContent(operationID, logID string) (string, error)
}

Expand Down
3 changes: 1 addition & 2 deletions clients/mtaclient/mta_rest_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func (c MtaRestClient) handle429(headers http.Header) error {
return &baseclient.RetryAfterError{Duration: dur}
}

func (c MtaRestClient) GetAsyncUploadJob(jobId string, namespace *string, appInstanceId string) (AsyncUploadJobResult, error) {
func (c MtaRestClient) GetAsyncUploadJob(jobId string, namespace *string) (AsyncUploadJobResult, error) {
requestUrl := "https://" + c.dsHost + "/" + restBaseURL + spacesURL + c.spaceGuid + "/files/jobs/" + jobId
if namespace != nil && len(*namespace) != 0 {
requestUrl += "?namespace=" + *namespace
Expand All @@ -379,7 +379,6 @@ func (c MtaRestClient) GetAsyncUploadJob(jobId string, namespace *string, appIns
}

req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("x-cf-app-instance", appInstanceId)

cl := c.client.Transport.(*client.Runtime)
httpClient := http.Client{Transport: cl.Transport, Jar: cl.Jar, Timeout: 5 * time.Minute}
Expand Down
4 changes: 2 additions & 2 deletions clients/mtaclient/retryable_mta_rest_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ func (c RetryableMtaRestClient) StartUploadMtaArchiveFromUrl(fileUrl string, nam
return resp.(http.Header), nil
}

func (c RetryableMtaRestClient) GetAsyncUploadJob(jobId string, namespace *string, appInstanceId string) (AsyncUploadJobResult, error) {
func (c RetryableMtaRestClient) GetAsyncUploadJob(jobId string, namespace *string) (AsyncUploadJobResult, error) {
getAsyncUploadJobCb := func() (interface{}, error) {
return c.mtaClient.GetAsyncUploadJob(jobId, namespace, appInstanceId)
return c.mtaClient.GetAsyncUploadJob(jobId, namespace)
}
resp, err := baseclient.CallWithRetry(getAsyncUploadJobCb, c.MaxRetriesCount, c.RetryInterval)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion commands/deploy_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ func (c *DeployCommand) doUploadFromUrl(encodedFileUrl string, mtaClient mtaclie
var file *models.FileMetadata
var jobResult mtaclient.AsyncUploadJobResult
for file == nil {
jobResult, err = mtaClient.GetAsyncUploadJob(jobId, &namespace, responseHeaders.Get("x-cf-app-instance"))
jobResult, err = mtaClient.GetAsyncUploadJob(jobId, &namespace)
if err != nil {
ui.Failed("Could not upload from url: %s", err)
return UploadFromUrlStatus{
Expand Down
2 changes: 1 addition & 1 deletion commands/deploy_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ var _ = Describe("DeployCommand", func() {
UploadMtaFile(extDescriptorFile, extDescriptor, nil).
StartUploadMtaArchiveFromUrl(base64.URLEncoding.EncodeToString([]byte(correctMtaUrl)), nil, fileUploadJobId, nil).
StartUploadMtaArchiveFromUrl(base64.URLEncoding.EncodeToString([]byte(incorrectMtaUrl)), nil, nil, fmt.Errorf("connection refused")).
GetAsyncUploadJob(jobId, nil, "", jobResult, nil).
GetAsyncUploadJob(jobId, nil, jobResult, nil).
StartMtaOperation(testutil.OperationResult, mtaclient.ResponseHeader{Location: "operations/1000?embed=messages"}, nil).
GetMtaOperation("1000", "messages", &testutil.OperationResult, nil).
GetMtaOperationLogContent("1000", testutil.LogID, testutil.LogContent, nil).
Expand Down