Skip to content

Commit

Permalink
fix: delete k0s contents
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianKramm committed Dec 12, 2023
1 parent 2d06691 commit c269447
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/k0s/k0s.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"

"github.com/ghodss/yaml"
Expand All @@ -20,7 +21,16 @@ type k0sCommand struct {
Args []string `json:"args,omitempty"`
}

const runDir = "/run/k0s"

func StartK0S(ctx context.Context) error {
// make sure we delete the contents of /run/k0s
dirEntries, _ := os.ReadDir(runDir)
for _, entry := range dirEntries {
_ = os.RemoveAll(filepath.Join(runDir, entry.Name()))
}

// start k0s binary
reader, writer, err := os.Pipe()
if err != nil {
return err
Expand Down

0 comments on commit c269447

Please sign in to comment.