runtime/v2/shim: strip path information from version output
I noticed that path information showed up in the version output: ./bin/containerd-shim-runc-v1 -v ./bin/containerd-shim-runc-v1: Version: v1.6.0-rc.1 Revision: ad771115b82a70cfd8018d72ae489c707e63de16.m Go version: go1.17.2 POSIX guidelines describes; https://www.gnu.org/prep/standards/html_node/_002d_002dversion.html#g_t_002d_002dversion > The program’s name should be a constant string; don’t compute it from argv[0]. > The idea is to state the standard or canonical name for the program, not its > file name. Unfortunately, this code is used by multiple binaries, so we can't fully remove the use of os.Args[0], but let's make a start and just remove the path info. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
c2cb589221
commit
b8cadf7539
@ -23,6 +23,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
@ -240,7 +241,7 @@ func RunManager(ctx context.Context, manager Manager, opts ...BinaryOpts) {
|
|||||||
func run(ctx context.Context, manager Manager, initFunc Init, name string, config Config) error {
|
func run(ctx context.Context, manager Manager, initFunc Init, name string, config Config) error {
|
||||||
parseFlags()
|
parseFlags()
|
||||||
if versionFlag {
|
if versionFlag {
|
||||||
fmt.Printf("%s:\n", os.Args[0])
|
fmt.Printf("%s:\n", filepath.Base(os.Args[0]))
|
||||||
fmt.Println(" Version: ", version.Version)
|
fmt.Println(" Version: ", version.Version)
|
||||||
fmt.Println(" Revision:", version.Revision)
|
fmt.Println(" Revision:", version.Revision)
|
||||||
fmt.Println(" Go version:", version.GoVersion)
|
fmt.Println(" Go version:", version.GoVersion)
|
||||||
|
Loading…
Reference in New Issue
Block a user