Skip to content

Commit 107a819

Browse files
committed
more fixing
Signed-off-by: Kimmo Lehto <[email protected]>
1 parent 4cbf11b commit 107a819

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

configurer/windows/windows.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package windows
22

33
import (
4+
"fmt"
5+
46
"github.com/k0sproject/k0sctl/configurer"
57
"github.com/k0sproject/rig"
8+
"github.com/k0sproject/rig/exec"
69
"github.com/k0sproject/rig/os"
710
"github.com/k0sproject/rig/os/registry"
11+
ps "github.com/k0sproject/rig/pkg/powershell"
812
)
913

1014
// Windows provides OS support for Windows systems
@@ -25,3 +29,12 @@ func init() {
2529
},
2630
)
2731
}
32+
33+
func (c *Windows) WriteFile(h os.Host, path, content, mode string) error {
34+
err := h.Exec(ps.Cmd(fmt.Sprintf(`$Input | Out-File -FilePath %s`, ps.DoubleQuotePath(path))), exec.Stdin(content), exec.RedactString(content))
35+
if err != nil {
36+
return fmt.Errorf("failed to write to file %s: %w", path, err)
37+
}
38+
39+
return nil
40+
}

phase/install_workers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ func (p *InstallWorkers) Run(ctx context.Context) error {
150150
return p.parallelDo(ctx, p.hosts, func(_ context.Context, h *cluster.Host) error {
151151
tokenPath := h.K0sJoinTokenPath()
152152
err := p.Wet(h, fmt.Sprintf("write k0s join token to %s", tokenPath), func() error {
153-
if err := h.SudoFsys().MkDirAll(h.K0sDataDir(), 0o700); err != nil {
154-
log.Warnf("%s: failed to create k0s data dir %s: %v", h, h.K0sDataDir(), err)
153+
if err := h.SudoFsys().MkDirAll(h.Configurer.Dir(tokenPath), 0o700); err != nil {
154+
log.Warnf("%s: failed to create k0s config dir %s: %v", h, h.K0sDataDir(), err)
155155
}
156156
log.Infof("%s: writing join token to %s", h, tokenPath)
157157
return h.Configurer.WriteFile(h, tokenPath, h.Metadata.K0sTokenData.Token, "0600")

0 commit comments

Comments
 (0)