func restartPolicyFromGRPC(p *swarmapi.RestartPolicy) *types.RestartPolicy { var rp *types.RestartPolicy if p != nil { rp = &types.RestartPolicy{} switch p.Condition { case swarmapi.RestartOnNone: rp.Condition = types.RestartPolicyConditionNone case swarmapi.RestartOnFailure: rp.Condition = types.RestartPolicyConditionOnFailure case swarmapi.RestartOnAny: rp.Condition = types.RestartPolicyConditionAny default: rp.Condition = types.RestartPolicyConditionAny } if p.Delay != nil { delay, _ := ptypes.Duration(p.Delay) rp.Delay = &delay } if p.Window != nil { window, _ := ptypes.Duration(p.Window) rp.Window = &window } rp.MaxAttempts = &p.MaxAttempts } return rp }
func restartPolicyFromGRPC(p *swarmapi.RestartPolicy) *types.RestartPolicy { var rp *types.RestartPolicy if p != nil { rp = &types.RestartPolicy{} rp.Condition = types.RestartPolicyCondition(strings.ToLower(p.Condition.String())) if p.Delay != nil { delay, _ := ptypes.Duration(p.Delay) rp.Delay = &delay } if p.Window != nil { window, _ := ptypes.Duration(p.Window) rp.Window = &window } rp.MaxAttempts = &p.MaxAttempts } return rp }