本文整理汇总了Golang中github.com/juju/names.ActionTag.String方法的典型用法代码示例。如果您正苦于以下问题:Golang ActionTag.String方法的具体用法?Golang ActionTag.String怎么用?Golang ActionTag.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/names.ActionTag
的用法示例。
在下文中一共展示了ActionTag.String方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ActionFinish
// ActionFinish captures the structured output of an action.
func (st *State) ActionFinish(tag names.ActionTag, status string, results map[string]interface{}, message string) error {
var outcome params.ErrorResults
args := params.ActionExecutionResults{
Results: []params.ActionExecutionResult{
{
ActionTag: tag.String(),
Status: status,
Results: results,
Message: message,
},
},
}
err := st.facade.FacadeCall("FinishActions", args, &outcome)
if err != nil {
return err
}
if len(outcome.Results) != 1 {
return fmt.Errorf("expected 1 result, got %d", len(outcome.Results))
}
result := outcome.Results[0]
if result.Error != nil {
return result.Error
}
return nil
}
示例2: getOneAction
// getOneAction retrieves a single Action from the state server.
func (st *State) getOneAction(tag *names.ActionTag) (params.ActionsQueryResult, error) {
nothing := params.ActionsQueryResult{}
args := params.Entities{
Entities: []params.Entity{
{Tag: tag.String()},
},
}
var results params.ActionsQueryResults
err := st.facade.FacadeCall("Actions", args, &results)
if err != nil {
return nothing, err
}
if len(results.Results) > 1 {
return nothing, fmt.Errorf("expected only 1 action query result, got %d", len(results.Results))
}
// handle server errors
result := results.Results[0]
if err := result.Error; err != nil {
return nothing, err
}
return result, nil
}
示例3: ActionBegin
// ActionBegin marks an action as running.
func (c *Client) ActionBegin(tag names.ActionTag) error {
var results params.ErrorResults
args := params.Entities{
Entities: []params.Entity{{Tag: tag.String()}},
}
err := c.facade.FacadeCall("BeginActions", args, &results)
if err != nil {
return errors.Trace(err)
}
return results.OneError()
}
示例4: ActionFinish
// ActionFinish captures the structured output of an action.
func (c *Client) ActionFinish(tag names.ActionTag, status string, actionResults map[string]interface{}, message string) error {
var results params.ErrorResults
args := params.ActionExecutionResults{
Results: []params.ActionExecutionResult{{
ActionTag: tag.String(),
Status: status,
Results: actionResults,
Message: message,
}},
}
err := c.facade.FacadeCall("FinishActions", args, &results)
if err != nil {
return errors.Trace(err)
}
return results.OneError()
}
示例5: ActionBegin
// ActionBegin marks an action as running.
func (st *State) ActionBegin(tag names.ActionTag) error {
var outcome params.ErrorResults
args := params.Entities{
Entities: []params.Entity{
{Tag: tag.String()},
},
}
err := st.facade.FacadeCall("BeginActions", args, &outcome)
if err != nil {
return err
}
if len(outcome.Results) != 1 {
return fmt.Errorf("expected 1 result, got %d", len(outcome.Results))
}
result := outcome.Results[0]
if result.Error != nil {
return result.Error
}
return nil
}
示例6: getOneAction
func (c *Client) getOneAction(tag names.ActionTag) (params.ActionResult, error) {
nothing := params.ActionResult{}
args := params.Entities{
Entities: []params.Entity{{Tag: tag.String()}},
}
var results params.ActionResults
err := c.facade.FacadeCall("Actions", args, &results)
if err != nil {
return nothing, errors.Trace(err)
}
if len(results.Results) > 1 {
return nothing, errors.Errorf("expected only 1 action query result, got %d", len(results.Results))
}
result := results.Results[0]
if result.Error != nil {
return nothing, errors.Trace(result.Error)
}
return result, nil
}
示例7: ActionFail
// ActionFail captures the action tag and error of a failed action.
func (st *State) ActionFail(tag names.ActionTag, err string) error {
var result params.BoolResult
args := params.ActionResult{ActionTag: tag.String(), Message: err, Failed: true}
return st.facade.FacadeCall("ActionFinish", args, &result)
}
示例8: ActionComplete
// ActionComplete captures the structured output of an action.
func (st *State) ActionComplete(tag names.ActionTag, results map[string]interface{}) error {
var result params.BoolResult
args := params.ActionResult{ActionTag: tag.String(), Results: results}
return st.facade.FacadeCall("ActionFinish", args, &result)
}
示例9: ActionFail
func (st *State) ActionFail(tag names.ActionTag, errorMessage string) error {
var result params.BoolResult
args := params.ActionResult{ActionTag: tag.String(), Output: errorMessage}
return st.call("ActionFail", args, &result)
}
示例10: ActionComplete
func (st *State) ActionComplete(tag names.ActionTag, output string) error {
var result params.BoolResult
args := params.ActionResult{ActionTag: tag.String(), Output: output}
return st.call("ActionComplete", args, &result)
}