2015-02-11 14:21:38 -05:00
|
|
|
package opts
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/docker/docker/pkg/ulimit"
|
|
|
|
)
|
|
|
|
|
|
|
|
type UlimitOpt struct {
|
2015-05-05 00:18:28 -04:00
|
|
|
values *map[string]*ulimit.Ulimit
|
2015-02-11 14:21:38 -05:00
|
|
|
}
|
|
|
|
|
2015-05-05 00:18:28 -04:00
|
|
|
func NewUlimitOpt(ref *map[string]*ulimit.Ulimit) *UlimitOpt {
|
|
|
|
if ref == nil {
|
|
|
|
ref = &map[string]*ulimit.Ulimit{}
|
|
|
|
}
|
2015-02-11 14:21:38 -05:00
|
|
|
return &UlimitOpt{ref}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o *UlimitOpt) Set(val string) error {
|
|
|
|
l, err := ulimit.Parse(val)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2015-05-05 00:18:28 -04:00
|
|
|
(*o.values)[l.Name] = l
|
2015-02-11 14:21:38 -05:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o *UlimitOpt) String() string {
|
|
|
|
var out []string
|
2015-05-05 00:18:28 -04:00
|
|
|
for _, v := range *o.values {
|
2015-02-11 14:21:38 -05:00
|
|
|
out = append(out, v.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Sprintf("%v", out)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o *UlimitOpt) GetList() []*ulimit.Ulimit {
|
|
|
|
var ulimits []*ulimit.Ulimit
|
2015-05-05 00:18:28 -04:00
|
|
|
for _, v := range *o.values {
|
2015-02-11 14:21:38 -05:00
|
|
|
ulimits = append(ulimits, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
return ulimits
|
|
|
|
}
|