本文整理匯總了Golang中github.com/elodina/stack-deploy/framework.Variables.SetStackVariable方法的典型用法代碼示例。如果您正苦於以下問題:Golang Variables.SetStackVariable方法的具體用法?Golang Variables.SetStackVariable怎麽用?Golang Variables.SetStackVariable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/elodina/stack-deploy/framework.Variables
的用法示例。
在下文中一共展示了Variables.SetStackVariable方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: FillContext
func (etr *ElasticsearchTaskRunner) FillContext(context *framework.Variables, application *framework.Application, task marathon.Task) error {
context.SetStackVariable(fmt.Sprintf("%s.host", application.ID), task.Host)
for idx, port := range task.Ports {
context.SetStackVariable(fmt.Sprintf("%s.port%d", application.ID, idx), fmt.Sprint(port))
}
api := fmt.Sprintf("http://%s:%d", task.Host, task.Ports[0])
context.SetStackVariable(fmt.Sprintf("%s.api", application.ID), api)
client := NewElasticsearchClient(api)
err := client.AwaitRunning(etr.awaitTimeout, etr.backoffTimeout)
if err != nil {
return err
}
tasks, err := client.GetTasks()
if err != nil {
return err
}
for idx, task := range tasks {
context.SetStackVariable(fmt.Sprintf("%s.%d.httpAddress", application.ID, idx), task.HttpAddress)
context.SetStackVariable(fmt.Sprintf("%s.%d.transportAddress", application.ID, idx), task.TransportAddress)
}
return nil
}
示例2: fillTaskContext
func (dtr *DSE02xTaskRunner) fillTaskContext(context *framework.Variables, application *framework.Application, response []byte) error {
startResponse := new(DSEMesos02xStartResponse)
err := json.Unmarshal(response, &startResponse)
if err != nil {
return err
}
if startResponse.Status == "timeout" {
return errors.New("Timed out")
}
servers := make([]string, 0)
for _, node := range startResponse.Nodes {
nodeEndpoint := fmt.Sprintf("%s:%d", node.Runtime.Address, node.Runtime.Reservation.Ports["cql"])
context.SetStackVariable(fmt.Sprintf("%s.cassandra-%s", application.ID, fmt.Sprint(node.ID)), nodeEndpoint)
context.SetStackVariable(fmt.Sprintf("%s.cassandra-%s.host", application.ID, fmt.Sprint(node.ID)), node.Runtime.Address)
for name, port := range node.Runtime.Reservation.Ports {
context.SetStackVariable(fmt.Sprintf("%s.cassandra-%s.%sPort", application.ID, fmt.Sprint(node.ID), name), fmt.Sprint(port))
}
servers = append(servers, nodeEndpoint)
}
context.SetStackVariable(fmt.Sprintf("%s.cassandraConnect", application.ID), strings.Join(servers, ","))
return nil
}
示例3: fillTaskContext
func (dtr *DSETaskRunner) fillTaskContext(context *framework.Variables, application *framework.Application, response map[string]interface{}) error {
servers := make([]string, 0)
serversMap := make(map[string]string)
value, ok := response["value"].(map[string]interface{})
if !ok {
return errors.New("Wrong value field")
}
clusterArr, ok := value["cluster"].([]interface{})
if !ok {
return errors.New("Wrong cluster field")
}
for _, clusterIface := range clusterArr {
cluster, ok := clusterIface.(map[string]interface{})
if !ok {
return errors.New("Wrong cluster field")
}
id, ok := cluster["id"].(string)
if !ok {
return errors.New("Wrong id field")
}
runtime, ok := cluster["runtime"].(map[string]interface{})
if !ok {
return errors.New("Wrong runtime field")
}
hostname, ok := runtime["hostname"].(string)
if !ok {
return errors.New("Wrong hostname field")
}
serversMap[id] = hostname
servers = append(servers, hostname)
}
for id, host := range servers {
context.SetStackVariable(fmt.Sprintf("%s.cassandra-node-%s", application.ID, fmt.Sprint(id)), host)
}
context.SetStackVariable(fmt.Sprintf("%s.cassandraConnect", application.ID), strings.Join(servers, ","))
return nil
}
示例4: fillTaskContext
func (etr *ExhibitorTaskRunner) fillTaskContext(context *framework.Variables, application *framework.Application, response *exhibitorCluster) error {
servers := make([]string, 0)
serversMap := make(map[string]string)
for _, server := range response.Cluster {
hostname := fmt.Sprintf("%s:%s", server.Config.Hostname, etr.getClientPort(server))
serversMap[server.Id] = hostname
servers = append(servers, hostname)
}
for id, host := range servers {
context.SetStackVariable(fmt.Sprintf("%s.exhibitor-%s", application.ID, fmt.Sprint(id)), host)
}
context.SetStackVariable(fmt.Sprintf("%s.zkConnect", application.ID), strings.Join(servers, ","))
return nil
}
示例5: fillTaskContext
func (ztr *ZipkinTaskRunner) fillTaskContext(context *framework.Variables, application *framework.Application, response map[string]interface{}) error {
valueArr, ok := response["value"].([]interface{})
if !ok {
return errors.New("Wrong value field")
}
for _, valueIface := range valueArr {
value, ok := valueIface.(map[string]interface{})
if !ok {
return errors.New("Wrong value interface field")
}
id, ok := value["id"].(string)
if !ok {
return errors.New("Wrong id field")
}
config, ok := value["config"].(map[string]interface{})
if !ok {
return errors.New("Wrong config field")
}
hostname, ok := config["hostname"].(string)
if !ok {
return errors.New("Wrong hostname field")
}
env, ok := config["env"].(map[string]interface{})
if !ok {
return errors.New("Wrong env field")
}
queryPort, ok := env["QUERY_PORT"].(string)
if !ok {
return errors.New("Wrong QUERY_PORT env")
}
context.SetStackVariable(fmt.Sprintf("%s.query-%s.endpoint", application.ID, id), fmt.Sprintf("%s:%s", hostname, queryPort))
}
return nil
}
示例6: FillContext
func (dtr *DSETaskRunner) FillContext(context *framework.Variables, application *framework.Application, task marathon.Task) error {
context.SetStackVariable(fmt.Sprintf("%s.host", application.ID), task.Host)
for idx, port := range task.Ports {
context.SetStackVariable(fmt.Sprintf("%s.port%d", application.ID, idx), fmt.Sprint(port))
}
context.SetStackVariable(fmt.Sprintf("%s.api", application.ID), fmt.Sprintf("http://%s:%d", task.Host, task.Ports[0]))
return nil
}