File tree Expand file tree Collapse file tree 3 files changed +15
-4
lines changed
pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 44 "bytes"
55 "context"
66 "fmt"
7- "path/filepath "
7+ gopath "path"
88 "time"
99
1010 "github.com/k0sproject/dig"
@@ -241,7 +241,7 @@ func (p *ConfigureK0s) configureK0s(h *cluster.Host) error {
241241
242242 log .Infof ("%s: installing new configuration" , h )
243243 configPath := h .K0sConfigPath ()
244- configDir := filepath .Dir (configPath )
244+ configDir := gopath .Dir (configPath )
245245
246246 if ! h .Configurer .FileExist (h , configDir ) {
247247 if err := h .Execf (`install -d 0750 -o root -g root "%s"` , configDir , exec .Sudo (h )); err != nil {
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ package cluster
33import (
44 "fmt"
55 gos "os"
6- "path/filepath "
6+ gopath "path"
77 "regexp"
88 "strconv"
99 "strings"
@@ -371,13 +371,17 @@ func (h *Host) K0sServiceName() string {
371371 }
372372}
373373
374+ func (h * Host ) k0sBinaryPathDir () string {
375+ return gopath .Dir (h .Configurer .K0sBinaryPath ())
376+ }
377+
374378// InstallK0sBinary installs the k0s binary from the provided file path to K0sBinaryPath
375379func (h * Host ) InstallK0sBinary (path string ) error {
376380 if ! h .Configurer .FileExist (h , path ) {
377381 return fmt .Errorf ("k0s binary tempfile not found" )
378382 }
379383
380- dir := filepath . Dir ( h . Configurer . K0sBinaryPath () )
384+ dir := h . k0sBinaryPathDir ( )
381385 if err := h .Execf (`install -m 0755 -o root -g root -d "%s"` , dir , exec .Sudo (h )); err != nil {
382386 return fmt .Errorf ("create k0s binary dir: %w" , err )
383387 }
Original file line number Diff line number Diff line change @@ -134,3 +134,10 @@ func TestValidation(t *testing.T) {
134134 require .ErrorContains (t , h .Validate (), "unbalanced quotes" )
135135 })
136136}
137+
138+ func TestBinaryPath (t * testing.T ) {
139+ h := Host {}
140+ h .Configurer = & mockconfigurer {}
141+ h .Configurer .SetPath ("K0sBinaryPath" , "/foo/bar/k0s" )
142+ require .Equal (t , "/foo/bar" , h .k0sBinaryPathDir ())
143+ }
You can’t perform that action at this time.
0 commit comments