Skip to content

Commit

Permalink
run: Consolidate namespace options
Browse files Browse the repository at this point in the history
This change just consolidates all of the namespace validation/setting
logic into a single function and will return all of the resulting
options.

Signed-off-by: Danny Canter <danny@dcantah.dev>
  • Loading branch information
dcantah committed Dec 27, 2022
1 parent 359521e commit 17800d1
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions cmd/nerdctl/run_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,30 @@ func setPlatformOptions(
opts = append(opts, oci.WithRdt(rdtClass, "", ""))
}

nsOpts, err := generateNamespaceOpts(ctx, cmd, client, internalLabels)
if err != nil {
return nil, err
}
opts = append(opts, nsOpts...)

opts, err = setOOMScoreAdj(opts, cmd)
if err != nil {
return nil, err
}

return opts, nil
}

// Helper to validate the namespace options exposed via run and return the correct
// opts.
func generateNamespaceOpts(
ctx context.Context,
cmd *cobra.Command,
client *containerd.Client,
internalLabels *internalLabels,
) ([]oci.SpecOpts, error) {
var opts []oci.SpecOpts

// UTS
uts, err := cmd.Flags().GetString("uts")
if err != nil {
Expand Down Expand Up @@ -207,11 +231,6 @@ func setPlatformOptions(
internalLabels.pidContainer = pidLabel
opts = append(opts, pidOpts...)

opts, err = setOOMScoreAdj(opts, cmd)
if err != nil {
return nil, err
}

return opts, nil
}

Expand Down

0 comments on commit 17800d1

Please sign in to comment.