Skip to content

Commit

Permalink
for #45 the delete was writing the path as the file contents
Browse files Browse the repository at this point in the history
  • Loading branch information
mlbiam committed Nov 28, 2023
1 parent ec5de30 commit 278b7ac
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions test/kind/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package kind
import (
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -96,7 +95,7 @@ func (k *Kind) Create() error {
return err
}

if err := ioutil.WriteFile(k.KubeConfigPath(), []byte(kubeconfigData), 0600); err != nil {
if err := os.WriteFile(k.KubeConfigPath(), []byte(kubeconfigData), 0600); err != nil {
return err
}

Expand Down Expand Up @@ -128,12 +127,20 @@ func (k *Kind) Create() error {
func DeleteCluster(name string) error {
provider := cluster.NewProvider()

f, err := os.CreateTemp("", name)

kubeconfig, err := provider.KubeConfig(clusterName, false)
if err != nil {
return err
}

return provider.Delete(clusterName, kubeconfig)
if _, err := f.Write([]byte(kubeconfig)); err != nil {
return err
}

f.Close()

return provider.Delete(clusterName, f.Name())
}

func (k *Kind) Destroy() error {
Expand Down

0 comments on commit 278b7ac

Please sign in to comment.