Skip to content

Commit 45256e1

Browse files
committed
generate: Set process.args to an empty array if it was nil
Before this commit: $ ocitools generate --template <(echo '{}') $ grep args config.json "args": null, With this commit: $ grep args config.json "args": [], That's still not a particularly useful value for the process arguments, but it complies with the specs "array of strings" typing [1] and is closer to a non-empty array that would be useful. [1]: https://github.com/opencontainers/runtime-spec/blob/dbce512cec0cd0774b236980ec18a4f6a91bc77e/config.md#process-configuration Signed-off-by: W. Trevor King <[email protected]>
1 parent f59e581 commit 45256e1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

generate.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ func modify(spec *rspec.Spec, context *cli.Context) error {
130130
spec.Hostname = context.String("hostname")
131131
spec.Process.User.UID = uint32(context.Int("uid"))
132132
spec.Process.User.GID = uint32(context.Int("gid"))
133+
if spec.Process.Args == nil {
134+
spec.Process.Args = make([]string, 0)
135+
}
133136
spec.Process.SelinuxLabel = context.String("selinux-label")
134137
spec.Linux.MountLabel = context.String("mount-label")
135138
spec.Platform.OS = context.String("os")

0 commit comments

Comments
 (0)