mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-26 00:51:11 +02:00
refactor(osctl): use UserHomeDir to detect user home directory (#749)
Signed-off-by: Andrew Rynhard <andrew@andrewrynhard.com>
This commit is contained in:
parent
9ed45f7090
commit
1f36f0e7df
@ -63,7 +63,7 @@ ARG SHA
|
||||
ARG TAG
|
||||
ARG VERSION_PKG="github.com/talos-systems/talos/internal/pkg/version"
|
||||
WORKDIR /src/cmd/osctl
|
||||
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -a -ldflags "-s -w -linkmode external -extldflags \"-static\" -X ${VERSION_PKG}.Name=Client -X ${VERSION_PKG}.SHA=${SHA} -X ${VERSION_PKG}.Tag=${TAG}" -o /osctl-linux-amd64
|
||||
RUN GOOS=linux GOARCH=amd64 go build -a -ldflags "-s -w -linkmode external -extldflags \"-static\" -X ${VERSION_PKG}.Name=Client -X ${VERSION_PKG}.SHA=${SHA} -X ${VERSION_PKG}.Tag=${TAG}" -o /osctl-linux-amd64
|
||||
RUN chmod +x /osctl-linux-amd64
|
||||
|
||||
FROM scratch AS osctl-linux-amd64
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"os/user"
|
||||
"path"
|
||||
"syscall"
|
||||
|
||||
@ -83,11 +82,11 @@ func Execute() {
|
||||
ok bool
|
||||
)
|
||||
if defaultTalosConfig, ok = os.LookupEnv(constants.TalosConfigEnvVar); !ok {
|
||||
u, err := user.Current()
|
||||
home, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defaultTalosConfig = path.Join(u.HomeDir, ".talos", "config")
|
||||
defaultTalosConfig = path.Join(home, ".talos", "config")
|
||||
}
|
||||
rootCmd.PersistentFlags().StringVar(&talosconfig, "talosconfig", defaultTalosConfig, "The path to the Talos configuration file")
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user