コード例 #1
0
ファイル: deploy.go プロジェクト: massmep/env
func TryDeploy(contents []byte, instance Instance) (id metadata.ID, err error) {

	login := new(metadata.BasicAuth)
	login.SessionId = instance.UserInfo.SessionID

	options := new(metadata.DeployOptions)
	options.SinglePackage = true

	deploy := new(metadata.Deploy)
	deploy.DeployOptions = options

	b64 := base64.StdEncoding.EncodeToString(contents)

	deploy.ZipFile = b64

	port := metadata.NewMetadataPortType(instance.MetadataURL, false, login)

	response, err := port.Deploy(deploy)

	if err != nil {
		return
	}

	id = *response.Result.Id

	fmt.Println(*response.Result.State)
	fmt.Println(response.Result.Message)

	return
}
コード例 #2
0
ファイル: retrieve.go プロジェクト: massmep/env
func CheckAsyncRetrieve(id metadata.ID, instance Instance) (done bool, contents []byte) {
	login := new(metadata.BasicAuth)
	login.SessionId = instance.UserInfo.SessionID

	port := metadata.NewMetadataPortType(instance.MetadataURL, true, login)

	status := new(metadata.CheckRetrieveStatus)
	status.IncludeZip = true
	status.AsyncProcessId = &id

	response, err := port.CheckRetrieveStatus(status)

	if err != nil {
		fmt.Println("Check Retrieve failed! Error: " + err.Error())
		return true, nil
	}

	result := *response.Result

	fmt.Println("Status:")
	fmt.Println(*result.Status)
	fmt.Println("")

	if len(result.Messages) != 0 {
		fmt.Println("Messages:")

		for _, message := range result.Messages {
			fmt.Println(*message)
		}

		fmt.Println()
	}

	if !result.Success {
		fmt.Println("Retrieve failed!")
		fmt.Println(result.ErrorMessage)

		if result.ErrorStatusCode != nil {
			statusCode := result.ErrorStatusCode
			fmt.Println(*statusCode)
		}

		return true, nil
	}

	return result.Done, result.ZipFile
}
コード例 #3
0
ファイル: retrieve.go プロジェクト: massmep/env
func TryRetrieve(pkg Package, instance Instance) (Id metadata.ID, err error) {

	login := new(metadata.BasicAuth)
	login.SessionId = instance.UserInfo.SessionID

	port := metadata.NewMetadataPortType(instance.MetadataURL, true, login)

	request := new(metadata.RetrieveRequest)

	request.SinglePackage = true
	request.PackageNames = nil // needs to be nil
	request.ApiVersion = 35.0

	sfPkg := new(metadata.Package)

	sfPkg.Description = "something"

	memberList := make([]*metadata.PackageTypeMembers, len(pkg.Members))

	for j, memberType := range pkg.Members {

		members := new(metadata.PackageTypeMembers)
		members.Members = memberType.Names
		members.Name = memberType.MemberType

		memberList[j] = members
	}

	sfPkg.Types = memberList

	request.Unpackaged = sfPkg

	response, err := port.Retrieve(&metadata.Retrieve{RetrieveRequest: request})

	if err != nil {
		return
	}

	result := *response.Result

	fmt.Println(*result.State)
	fmt.Println(result.Message)

	return *result.Id, nil
}
コード例 #4
0
ファイル: deploy.go プロジェクト: massmep/env
// CheckAsyncDeploy checks the given AsyncProcessId on the given instance, and prints the result to console.
// This function returns the response.Result.Done value, which will be true once the job has completed.
func CheckAsyncDeploy(id metadata.ID, instance Instance) (done bool) {

	login := new(metadata.BasicAuth)
	login.SessionId = instance.UserInfo.SessionID

	port := metadata.NewMetadataPortType(instance.MetadataURL, true, login)

	status := new(metadata.CheckDeployStatus)
	status.IncludeDetails = true
	status.AsyncProcessId = &id
	response, err := port.CheckDeployStatus(status)

	if err != nil {
		fmt.Println("Check deploy failed! Error: " + err.Error())
		return true
	}

	result := *response.Result
	details := *result.Details
	resultStatus := *result.Status

	if result.ErrorStatusCode != nil {
		code := *result.ErrorStatusCode
		fmt.Println(code)
	}

	fmt.Println(resultStatus)
	fmt.Println()

	if len(details.ComponentFailures) > 0 {
		fmt.Println("Failures:")

		for _, v := range details.ComponentFailures {
			fmt.Println(v.FileName)
			fmt.Println(int(v.LineNumber), ":", "[", string(*v.ProblemType), "]", v.Problem)
		}

		fmt.Println()

		return true
	}

	return response.Result.Done
}
コード例 #5
0
ファイル: deploy.go プロジェクト: Steampunkrue/goforce
func TryDeploy(contents []byte, url, sessionId string) (success bool, err error) {

	login := new(metadata.BasicAuth)
	login.SessionId = sessionId

	options := new(metadata.DeployOptions)
	options.SinglePackage = true

	deploy := new(metadata.Deploy)
	deploy.DeployOptions = options

	b64 := base64.StdEncoding.EncodeToString(contents)

	port := metadata.NewMetadataPortType(url, false, login)

	response, err := port.Deploy(deploy)

	if err != nil {
		return
	}

	for true {
		time.Sleep(20)

		status := new(metadata.CheckDeployStatus)
		status.IncludeDetails = true
		status.AsyncProcessId = response.Result.Id
		statusResponse, err := port.CheckDeployStatus(status)

		if err != nil {
			success = false
			return
		}

		if statusResponse.Result.Done {
			fmt.Println(statusResponse.Result.Status)
			fmt.Println(statusResponse.Result.Details)

			success = true
			return
		}
	}
}