Skip to content

Commit

Permalink
main: un-export container state consts to fix linting
Browse files Browse the repository at this point in the history
    utils_linux.go:395:2: exported: exported const CT_ACT_CREATE should have comment (or a comment on this block) or be unexported (revive)
        CT_ACT_CREATE CtAct = iota + 1
        ^
    utils_linux.go:396:2: var-naming: don't use ALL_CAPS in Go names; use CamelCase (revive)
        CT_ACT_RUN
        ^
    utils_linux.go:397:2: var-naming: don't use ALL_CAPS in Go names; use CamelCase (revive)
        CT_ACT_RESTORE
        ^

Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed Dec 2, 2021
1 parent 248bcb2 commit 0ebf2a4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion create.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ command(s) that get executed on start, edit the args parameter of the spec. See
if err := checkArgs(context, 1, exactArgs); err != nil {
return err
}
status, err := startContainer(context, CT_ACT_CREATE, nil)
status, err := startContainer(context, actCreate, nil)
if err == nil {
// exit with the container's exit status so any external supervisor
// is notified of the exit with the correct exit status.
Expand Down
2 changes: 1 addition & 1 deletion exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func execProcess(context *cli.Context) (int, error) {
consoleSocket: context.String("console-socket"),
detach: context.Bool("detach"),
pidFile: context.String("pid-file"),
action: CT_ACT_RUN,
action: actRun,
init: false,
preserveFDs: context.Int("preserve-fds"),
subCgroupPaths: cgPaths,
Expand Down
2 changes: 1 addition & 1 deletion restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ using the runc checkpoint command.`,
if err := setEmptyNsMask(context, options); err != nil {
return err
}
status, err := startContainer(context, CT_ACT_RESTORE, options)
status, err := startContainer(context, actRestore, options)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion run.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ command(s) that get executed on start, edit the args parameter of the spec. See
if err := checkArgs(context, 1, exactArgs); err != nil {
return err
}
status, err := startContainer(context, CT_ACT_RUN, nil)
status, err := startContainer(context, actRun, nil)
if err == nil {
// exit with the container's exit status so any external supervisor is
// notified of the exit with the correct exit status.
Expand Down
24 changes: 12 additions & 12 deletions utils_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ type runner struct {
pidFile string
consoleSocket string
container libcontainer.Container
action CtAct
action ctAct
notifySocket *notifySocket
criuOpts *libcontainer.CriuOpts
subCgroupPaths map[string]string
Expand Down Expand Up @@ -273,7 +273,7 @@ func (r *runner) run(config *specs.Process) (int, error) {
if err != nil {
return -1, err
}
detach := r.detach || (r.action == CT_ACT_CREATE)
detach := r.detach || (r.action == actCreate)
// Setting up IO is a two stage process. We need to modify process to deal
// with detaching containers, and then we get a tty after the container has
// started.
Expand All @@ -285,11 +285,11 @@ func (r *runner) run(config *specs.Process) (int, error) {
defer tty.Close()

switch r.action {
case CT_ACT_CREATE:
case actCreate:
err = r.container.Start(process)
case CT_ACT_RESTORE:
case actRestore:
err = r.container.Restore(process, r.criuOpts)
case CT_ACT_RUN:
case actRun:
err = r.container.Run(process)
default:
panic("Unknown action")
Expand Down Expand Up @@ -333,7 +333,7 @@ func (r *runner) terminate(p *libcontainer.Process) {
}

func (r *runner) checkTerminal(config *specs.Process) error {
detach := r.detach || (r.action == CT_ACT_CREATE)
detach := r.detach || (r.action == actCreate)
// Check command-line for sanity.
if detach && config.Terminal && r.consoleSocket == "" {
return errors.New("cannot allocate tty if runc will detach without setting console socket")
Expand Down Expand Up @@ -363,15 +363,15 @@ func validateProcessSpec(spec *specs.Process) error {
return nil
}

type CtAct uint8
type ctAct uint8

const (
CT_ACT_CREATE CtAct = iota + 1
CT_ACT_RUN
CT_ACT_RESTORE
actCreate ctAct = iota + 1 // Create container
actRun // Run container
actRestore // Restore container
)

func startContainer(context *cli.Context, action CtAct, criuOpts *libcontainer.CriuOpts) (int, error) {
func startContainer(context *cli.Context, action ctAct, criuOpts *libcontainer.CriuOpts) (int, error) {
if err := revisePidFile(context); err != nil {
return -1, err
}
Expand Down Expand Up @@ -399,7 +399,7 @@ func startContainer(context *cli.Context, action CtAct, criuOpts *libcontainer.C
if err := notifySocket.setupSocketDirectory(); err != nil {
return -1, err
}
if action == CT_ACT_RUN {
if action == actRun {
if err := notifySocket.bindSocket(); err != nil {
return -1, err
}
Expand Down

0 comments on commit 0ebf2a4

Please sign in to comment.