Execute a command in the container, and return a new snapshot of the container state after execution.
(args []string, opts ...ContainerWithExecOpts)
| 3046 | |
| 3047 | // Execute a command in the container, and return a new snapshot of the container state after execution. |
| 3048 | func (r *Container) WithExec(args []string, opts ...ContainerWithExecOpts) *Container { |
| 3049 | q := r.query.Select("withExec") |
| 3050 | for i := len(opts) - 1; i >= 0; i-- { |
| 3051 | // `useEntrypoint` optional argument |
| 3052 | if !querybuilder.IsZeroValue(opts[i].UseEntrypoint) { |
| 3053 | q = q.Arg("useEntrypoint", opts[i].UseEntrypoint) |
| 3054 | } |
| 3055 | // `stdin` optional argument |
| 3056 | if !querybuilder.IsZeroValue(opts[i].Stdin) { |
| 3057 | q = q.Arg("stdin", opts[i].Stdin) |
| 3058 | } |
| 3059 | // `redirectStdin` optional argument |
| 3060 | if !querybuilder.IsZeroValue(opts[i].RedirectStdin) { |
| 3061 | q = q.Arg("redirectStdin", opts[i].RedirectStdin) |
| 3062 | } |
| 3063 | // `redirectStdout` optional argument |
| 3064 | if !querybuilder.IsZeroValue(opts[i].RedirectStdout) { |
| 3065 | q = q.Arg("redirectStdout", opts[i].RedirectStdout) |
| 3066 | } |
| 3067 | // `redirectStderr` optional argument |
| 3068 | if !querybuilder.IsZeroValue(opts[i].RedirectStderr) { |
| 3069 | q = q.Arg("redirectStderr", opts[i].RedirectStderr) |
| 3070 | } |
| 3071 | // `expect` optional argument |
| 3072 | if !querybuilder.IsZeroValue(opts[i].Expect) { |
| 3073 | q = q.Arg("expect", opts[i].Expect) |
| 3074 | } |
| 3075 | // `experimentalPrivilegedNesting` optional argument |
| 3076 | if !querybuilder.IsZeroValue(opts[i].ExperimentalPrivilegedNesting) { |
| 3077 | q = q.Arg("experimentalPrivilegedNesting", opts[i].ExperimentalPrivilegedNesting) |
| 3078 | } |
| 3079 | // `insecureRootCapabilities` optional argument |
| 3080 | if !querybuilder.IsZeroValue(opts[i].InsecureRootCapabilities) { |
| 3081 | q = q.Arg("insecureRootCapabilities", opts[i].InsecureRootCapabilities) |
| 3082 | } |
| 3083 | // `expand` optional argument |
| 3084 | if !querybuilder.IsZeroValue(opts[i].Expand) { |
| 3085 | q = q.Arg("expand", opts[i].Expand) |
| 3086 | } |
| 3087 | // `noInit` optional argument |
| 3088 | if !querybuilder.IsZeroValue(opts[i].NoInit) { |
| 3089 | q = q.Arg("noInit", opts[i].NoInit) |
| 3090 | } |
| 3091 | } |
| 3092 | q = q.Arg("args", args) |
| 3093 | |
| 3094 | return &Container{ |
| 3095 | query: q, |
| 3096 | } |
| 3097 | } |
| 3098 | |
| 3099 | // ContainerWithExposedPortOpts contains options for Container.WithExposedPort |
| 3100 | type ContainerWithExposedPortOpts struct { |
no test coverage detected