-
Notifications
You must be signed in to change notification settings - Fork 949
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1179 from Ace-Tang/run_flag_ulimit
feature: add run flag ulimit
- Loading branch information
Showing
12 changed files
with
225 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/alibaba/pouch/apis/types" | ||
|
||
units "github.com/docker/go-units" | ||
) | ||
|
||
// Ulimit defines ulimit options. | ||
type Ulimit struct { | ||
values map[string]*units.Ulimit | ||
} | ||
|
||
// Set implement Ulimit as pflag.Value interface. | ||
func (u *Ulimit) Set(val string) error { | ||
ul, err := units.ParseUlimit(val) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if u.values == nil { | ||
u.values = make(map[string]*units.Ulimit) | ||
} | ||
|
||
u.values[ul.Name] = ul | ||
return nil | ||
} | ||
|
||
// String implement Ulimit as pflag.Value interface. | ||
func (u *Ulimit) String() string { | ||
var str []string | ||
for _, ul := range u.values { | ||
str = append(str, ul.String()) | ||
} | ||
|
||
return fmt.Sprintf("%v", str) | ||
} | ||
|
||
// Type implement Ulimit as pflag.Value interface. | ||
func (u *Ulimit) Type() string { | ||
return "value" | ||
} | ||
|
||
// value return ulimit values as type ResourcesUlimitsItems0 | ||
func (u *Ulimit) value() []*types.Ulimit { | ||
var ulimit []*types.Ulimit | ||
for _, ul := range u.values { | ||
ulimit = append(ulimit, &types.Ulimit{ | ||
Name: ul.Name, | ||
Hard: ul.Hard, | ||
Soft: ul.Soft, | ||
}) | ||
} | ||
|
||
return ulimit | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters