代码拉取完成,页面将自动刷新
package nsenter
import "io"
type nsOptions struct {
types []NsType
pid int
procfs string
envs []string
output io.Writer
uid int
gid int
}
type Option interface {
apply(*nsOptions)
}
type nsTypesOption []NsType
func (opt nsTypesOption) apply(options *nsOptions) {
options.types = opt
}
// Types specify namespace types while creating Namespace instance, supports NET,
// UTS, IPC, USER, and PID.
func Types(types ...NsType) Option {
return nsTypesOption(types)
}
type pidOption int
func (opt pidOption) apply(options *nsOptions) {
options.pid = int(opt)
}
// Pid specify which process attached to for namespaces
func Pid(pid int) Option {
return pidOption(pid)
}
type procfsOption string
func (opt procfsOption) apply(options *nsOptions) {
if string(opt) != "" {
options.procfs = string(opt)
}
}
// Procfs specify host procfs, which is useful for using package in container that
// has bind host /proc into container or starts with host pid namespace
func Procfs(procfs string) Option {
return procfsOption(procfs)
}
type outputOption struct {
output io.Writer
}
func (opt outputOption) apply(options *nsOptions) {
options.output = opt.output
}
// Output specify output writer for execution results, only works for Command
func Output(output io.Writer) Option {
return outputOption{output}
}
type envsOption struct {
envs []string
}
func (opt *envsOption) apply(options *nsOptions) {
options.envs = opt.envs
}
func Envs(envs ...string) Option {
return &envsOption{envs}
}
type uidOption int
func (opt uidOption) apply(options *nsOptions) {
options.uid = int(opt)
}
func UID(uid int) Option {
return uidOption(uid)
}
type gidOption int
func (opt gidOption) apply(options *nsOptions) {
options.gid = int(opt)
}
func GID(gid int) Option {
return gidOption(gid)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。