File tree Expand file tree Collapse file tree 1 file changed +6
-15
lines changed Expand file tree Collapse file tree 1 file changed +6
-15
lines changed Original file line number Diff line number Diff line change 6
6
"path/filepath"
7
7
8
8
ecv1beta1 "github.com/replicatedhq/embedded-cluster/kinds/apis/v1beta1"
9
+ "github.com/replicatedhq/embedded-cluster/pkg/helpers"
9
10
"github.com/sirupsen/logrus"
10
11
"sigs.k8s.io/yaml"
11
12
)
@@ -27,22 +28,12 @@ func Get() *ecv1beta1.RuntimeConfigSpec {
27
28
}
28
29
29
30
func Cleanup () {
30
- emptyTmpDir ()
31
- }
32
-
33
- func emptyTmpDir () {
34
31
tmpDir := EmbeddedClusterTmpSubDir ()
35
- entries , err := os .ReadDir (tmpDir )
36
- if err != nil {
37
- logrus .Errorf ("error reading %s tmp dir: %v" , tmpDir , err )
38
- return
39
- }
40
-
41
- for _ , entry := range entries {
42
- path := filepath .Join (tmpDir , entry .Name ())
43
- if err := os .RemoveAll (path ); err != nil {
44
- logrus .Errorf ("error removing item %s: %s" , path , err )
45
- }
32
+ // We should not delete the tmp dir, rather we should empty its contents leaving
33
+ // it in place. This is because commands such as `kubectl edit <resource>`
34
+ // will create files in the tmp dir
35
+ if err := helpers .RemoveAll (tmpDir ); err != nil {
36
+ logrus .Errorf ("error removing %s dir: %s" , tmpDir , err )
46
37
}
47
38
}
48
39
You can’t perform that action at this time.
0 commit comments