mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-23 16:24:19 +01:00
shimv2: Add a "--version" cli option
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: #307. Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
@@ -553,14 +553,16 @@ define MAKE_KERNEL_VIRTIOFS_NAME
|
||||
$(if $(findstring uncompressed,$1),vmlinux-virtiofs.container,vmlinuz-virtiofs.container)
|
||||
endef
|
||||
|
||||
GENERATED_CONFIG = $(abspath $(CLI_DIR)/config-generated.go)
|
||||
|
||||
GENERATED_FILES += $(CLI_DIR)/config-generated.go
|
||||
GENERATED_FILES += $(GENERATED_CONFIG)
|
||||
GENERATED_FILES += pkg/katautils/config-settings.go
|
||||
|
||||
$(TARGET_OUTPUT): $(SOURCES) $(GENERATED_FILES) $(MAKEFILE_LIST) | show-summary
|
||||
$(QUIET_BUILD)(cd $(CLI_DIR) && go build $(KATA_LDFLAGS) $(BUILDFLAGS) -o $@ .)
|
||||
|
||||
$(SHIMV2_OUTPUT): $(SOURCES) $(GENERATED_FILES) $(MAKEFILE_LIST)
|
||||
$(QUIET_BUILD)(cd $(SHIMV2_DIR)/ && ln -fs $(GENERATED_CONFIG))
|
||||
$(QUIET_BUILD)(cd $(SHIMV2_DIR)/ && go build $(KATA_LDFLAGS) $(BUILDFLAGS) -o $@ .)
|
||||
|
||||
.PHONY: \
|
||||
@@ -710,6 +712,7 @@ clean:
|
||||
$(GENERATED_FILES) \
|
||||
$(NETMON_TARGET) \
|
||||
$(SHIMV2) \
|
||||
$(SHIMV2_DIR)/$(notdir $(GENERATED_CONFIG)) \
|
||||
$(TARGET) \
|
||||
.git-commit .git-commit.tmp
|
||||
|
||||
|
||||
@@ -6,15 +6,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/containerd/containerd/runtime/v2/shim"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/containerd-shim-v2"
|
||||
)
|
||||
|
||||
const shim_id = "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, shim_id, version, commit)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
shim.Run(shim_id, containerdshim.New, shimConfig)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user