Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
shimv2: Add a "--version" cli option
Browse files Browse the repository at this point in the history
All components should support a `--version` option to allow clear
identification of the version of the component being used.

Note that the build changes are required to allow the shim binary to
access the golang code generated by the build
(such as the `version` variable).

Fixes: #2886.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
  • Loading branch information
jodh-intel committed Aug 19, 2020
1 parent ad78c6f commit 9bb8e36
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ clean:
$(GENERATED_FILES) \
$(NETMON_TARGET) \
$(SHIMV2) \
$(SHIMV2_DIR)/$(notdir $(GENERATED_CONFIG)) \
$(TARGET) \
.git-commit .git-commit.tmp

Expand Down
12 changes: 11 additions & 1 deletion cli/containerd-shim-kata-v2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,25 @@
package main

import (
"fmt"
"os"

"github.com/containerd/containerd/runtime/v2/shim"
"github.com/kata-containers/runtime/containerd-shim-v2"
)

const shimID = "io.containerd.kata.v2"

func shimConfig(config *shim.Config) {
config.NoReaper = true
config.NoSubreaper = true
}

func main() {
shim.Run("io.containerd.kata.v2", containerdshim.New, shimConfig)
if len(os.Args) == 2 && os.Args[1] == "--version" {
fmt.Printf("%s containerd shim: id: %q, version: %s, commit: %v\n", project, shimID, version, commit)
os.Exit(0)
}

shim.Run(shimID, containerdshim.New, shimConfig)
}

0 comments on commit 9bb8e36

Please sign in to comment.