Skip to content
Permalink
Browse files

odo delete --all only deletes the config directory if its empty (#2311)

*  odo delete --all only deletes the config directory if its empty

* better v4 log message

* add a filesystem interface for better testing

* use stat from fs too

* tighter file interface

* add unit tests

* add more comments

* add afero based filesystem in testutils

* capitalize comments

* integrate the filesystem package in the config and its unit tests

- Add missing methods in the testutil's filesystem package
- minor refactoring in the config package
- use of the new filesystem package in the config package's unit tests

* resolve failing unit test

* resolve charlie's comment

* resolve linting error

* lint issue - 2

* add source to the original filesystem package

* resolve empty componentContext when not provided as flag
  • Loading branch information
girishramnani authored and openshift-merge-robot committed Nov 21, 2019
1 parent f899710 commit adf3006360abc5cb707d9a9f442669989272f4e5
Showing with 11,783 additions and 1,303 deletions.
  1. +16 −11 glide.lock
  2. +2 −0 glide.yaml
  3. +42 −5 pkg/config/config.go
  4. +85 −0 pkg/config/config_test.go
  5. +13 −4 pkg/odo/cli/component/delete.go
  6. +141 −0 pkg/testingutil/filesystem/default_fs.go
  7. +146 −0 pkg/testingutil/filesystem/fake_fs.go
  8. +59 −0 pkg/testingutil/filesystem/filesystem.go
  9. +94 −0 pkg/testingutil/filesystem/watcher.go
  10. +16 −5 pkg/util/file_indexer.go
  11. +11 −0 pkg/util/util.go
  12. +12 −0 tests/integration/component.go
  13. +1 −1 vendor/github.com/creack/pty/Dockerfile.riscv
  14. +4 −0 vendor/github.com/creack/pty/go.mod
  15. +1 −1 vendor/github.com/google/btree/btree.go
  16. +1 −1 vendor/github.com/mattn/go-isatty/go.mod
  17. +2 −0 vendor/github.com/mattn/go-isatty/go.sum
  18. +22 −0 vendor/github.com/mattn/go-isatty/isatty_plan9.go
  19. +12 −0 vendor/github.com/mattn/go-runewidth/.github/FUNDING.yml
  20. +2 −722 vendor/github.com/mattn/go-runewidth/runewidth.go
  21. +426 −0 vendor/github.com/mattn/go-runewidth/runewidth_table.go
  22. +10 −10 vendor/github.com/mattn/go-runewidth/runewidth_test.go
  23. +195 −0 vendor/github.com/mattn/go-runewidth/script/generate.go
  24. +21 −0 vendor/github.com/spf13/afero/.travis.yml
  25. +174 −0 vendor/github.com/spf13/afero/LICENSE.txt
  26. +452 −0 vendor/github.com/spf13/afero/README.md
  27. +108 −0 vendor/github.com/spf13/afero/afero.go
  28. +718 −0 vendor/github.com/spf13/afero/afero_test.go
  29. +15 −0 vendor/github.com/spf13/afero/appveyor.yml
  30. +180 −0 vendor/github.com/spf13/afero/basepath.go
  31. +190 −0 vendor/github.com/spf13/afero/basepath_test.go
  32. +290 −0 vendor/github.com/spf13/afero/cacheOnReadFs.go
  33. +507 −0 vendor/github.com/spf13/afero/composite_test.go
  34. +22 −0 vendor/github.com/spf13/afero/const_bsds.go
  35. +25 −0 vendor/github.com/spf13/afero/const_win_unix.go
  36. +293 −0 vendor/github.com/spf13/afero/copyOnWriteFs.go
  37. +62 −0 vendor/github.com/spf13/afero/copyOnWriteFs_test.go
  38. +3 −0 vendor/github.com/spf13/afero/go.mod
  39. +2 −0 vendor/github.com/spf13/afero/go.sum
  40. +110 −0 vendor/github.com/spf13/afero/httpFs.go
  41. +230 −0 vendor/github.com/spf13/afero/ioutil.go
  42. +112 −0 vendor/github.com/spf13/afero/ioutil_test.go
  43. +27 −0 vendor/github.com/spf13/afero/lstater.go
  44. +102 −0 vendor/github.com/spf13/afero/lstater_test.go
  45. +110 −0 vendor/github.com/spf13/afero/match.go
  46. +183 −0 vendor/github.com/spf13/afero/match_test.go
  47. +37 −0 vendor/github.com/spf13/afero/mem/dir.go
  48. +43 −0 vendor/github.com/spf13/afero/mem/dirmap.go
  49. +317 −0 vendor/github.com/spf13/afero/mem/file.go
  50. +154 −0 vendor/github.com/spf13/afero/mem/file_test.go
  51. +365 −0 vendor/github.com/spf13/afero/memmap.go
  52. +451 −0 vendor/github.com/spf13/afero/memmap_test.go
  53. +101 −0 vendor/github.com/spf13/afero/os.go
  54. +106 −0 vendor/github.com/spf13/afero/path.go
  55. +69 −0 vendor/github.com/spf13/afero/path_test.go
  56. +80 −0 vendor/github.com/spf13/afero/readonlyfs.go
  57. +214 −0 vendor/github.com/spf13/afero/regexpfs.go
  58. +96 −0 vendor/github.com/spf13/afero/ro_regexp_test.go
  59. +95 −0 vendor/github.com/spf13/afero/sftpfs/file.go
  60. +129 −0 vendor/github.com/spf13/afero/sftpfs/sftp.go
  61. +286 −0 vendor/github.com/spf13/afero/sftpfs/sftp_test_go
  62. +320 −0 vendor/github.com/spf13/afero/unionFile.go
  63. +330 −0 vendor/github.com/spf13/afero/util.go
  64. +450 −0 vendor/github.com/spf13/afero/util_test.go
  65. +1 −0 vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/apiserver.go
  66. +9 −1 vendor/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler.go
  67. +216 −0 vendor/k8s.io/apiextensions-apiserver/test/integration/limit_test.go
  68. +4 −3 vendor/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time_test.go
  69. +3 −3 vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time_test.go
  70. +20 −1 vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/json.go
  71. +170 −0 vendor/k8s.io/apimachinery/pkg/runtime/serializer/json/json_limit_test.go
  72. +402 −0 vendor/k8s.io/apimachinery/pkg/runtime/serializer/yaml/yaml_test.go
  73. +20 −8 vendor/k8s.io/apimachinery/pkg/util/json/json.go
  74. +2 −2 vendor/k8s.io/apimachinery/pkg/util/yaml/decoder_test.go
  75. +18 −0 vendor/k8s.io/apiserver/pkg/endpoints/handlers/patch.go
  76. +10 −12 vendor/k8s.io/apiserver/pkg/server/config.go
  77. +7 −7 vendor/k8s.io/client-go/Godeps/Godeps.json
  78. +0 −14 vendor/k8s.io/client-go/tools/cache/delta_fifo.go
  79. +27 −0 vendor/k8s.io/client-go/tools/cache/delta_fifo_test.go
  80. +34 −30 vendor/k8s.io/kubernetes/Godeps/Godeps.json
  81. +421 −222 vendor/k8s.io/kubernetes/Godeps/LICENSES
  82. +2 −2 vendor/k8s.io/kubernetes/cmd/kube-apiserver/app/options/options_test.go
  83. +3 −16 vendor/k8s.io/kubernetes/cmd/kubelet/app/server.go
  84. +2 −2 vendor/k8s.io/kubernetes/pkg/cloudprovider/providers/openstack/openstack_volumes.go
  85. +15 −14 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/cp.go
  86. +98 −62 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/cp_test.go
  87. +1 −1 ...o/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-apply-edit-last-applied-syntax-error/2.edited
  88. +1 −1 ...kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-apply-edit-last-applied-syntax-error/2.original
  89. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-apply-edit-last-applied/1.edited
  90. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-apply-edit-last-applied/1.original
  91. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-create-list-error/0.edited
  92. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-create-list-error/0.original
  93. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-create-list-error/2.edited
  94. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-create-list-error/2.original
  95. +2 −2 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-create-list-error/svc.yaml
  96. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-edit-error-reedit/1.edited
  97. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-edit-error-reedit/1.original
  98. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-edit-error-reedit/3.edited
  99. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-edit-error-reedit/3.original
  100. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-edit-output-patch/1.edited
  101. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-edit-output-patch/1.original
  102. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-immutable-name/1.edited
  103. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-immutable-name/1.original
  104. +2 −2 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-list-errors/2.edited
  105. +2 −2 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-list-errors/2.original
  106. +2 −2 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-list-errors/5.edited
  107. +2 −2 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-list-errors/5.original
  108. +2 −2 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-list-errors/8.edited
  109. +2 −2 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-list-errors/8.original
  110. +2 −2 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-list-record/2.edited
  111. +2 −2 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-list-record/2.original
  112. +2 −2 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-list/2.edited
  113. +2 −2 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-list/2.original
  114. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-no-op/1.edited
  115. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-no-op/1.original
  116. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-not-update-annotation/1.edited
  117. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-not-update-annotation/1.original
  118. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-repeat-error/1.edited
  119. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-repeat-error/1.original
  120. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-repeat-error/3.edited
  121. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-repeat-error/3.original
  122. +3 −3 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-schemaless-list/3.edited
  123. +3 −3 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-schemaless-list/3.original
  124. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-single-service/1.edited
  125. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-single-service/1.original
  126. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-syntax-error/1.edited
  127. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-syntax-error/1.original
  128. +2 −2 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-syntax-error/2.edited
  129. +2 −2 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-syntax-error/2.original
  130. +1 −1 .../k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-unknown-field-known-group-kind/1.edited
  131. +1 −1 ...8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-unknown-field-known-group-kind/1.original
  132. +1 −1 ...8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-unknown-version-known-group-kind/1.edited
  133. +1 −1 ....io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-unknown-version-known-group-kind/1.original
  134. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-update-annotation/1.edited
  135. +1 −1 vendor/k8s.io/kubernetes/pkg/kubectl/cmd/testdata/edit/testcase-update-annotation/1.original
  136. +9 −1 vendor/k8s.io/kubernetes/pkg/kubelet/kubelet_getters.go
  137. +153 −0 vendor/k8s.io/kubernetes/pkg/kubelet/kubelet_node_status_test.go
  138. +1 −0 vendor/k8s.io/kubernetes/pkg/util/node/BUILD
  139. +70 −2 vendor/k8s.io/kubernetes/pkg/util/node/node.go
  140. +1 −0 vendor/k8s.io/kubernetes/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/apiserver.go
  141. +9 −1 ....io/kubernetes/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler.go
  142. +1 −0 vendor/k8s.io/kubernetes/staging/src/k8s.io/apiextensions-apiserver/test/integration/BUILD
  143. +216 −0 vendor/k8s.io/kubernetes/staging/src/k8s.io/apiextensions-apiserver/test/integration/limit_test.go
  144. +4 −3 vendor/k8s.io/kubernetes/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time_test.go
  145. +3 −3 vendor/k8s.io/kubernetes/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/time_test.go
  146. +7 −1 vendor/k8s.io/kubernetes/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/json/BUILD
  147. +20 −1 vendor/k8s.io/kubernetes/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/json/json.go
  148. +170 −0 .../k8s.io/kubernetes/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/json/json_limit_test.go
  149. +12 −4 vendor/k8s.io/kubernetes/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/yaml/BUILD
  150. +402 −0 vendor/k8s.io/kubernetes/staging/src/k8s.io/apimachinery/pkg/runtime/serializer/yaml/yaml_test.go
  151. +20 −8 vendor/k8s.io/kubernetes/staging/src/k8s.io/apimachinery/pkg/util/json/json.go
  152. +2 −2 vendor/k8s.io/kubernetes/staging/src/k8s.io/apimachinery/pkg/util/yaml/decoder_test.go
  153. +18 −0 vendor/k8s.io/kubernetes/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/patch.go
  154. +10 −12 vendor/k8s.io/kubernetes/staging/src/k8s.io/apiserver/pkg/server/config.go
  155. +7 −7 vendor/k8s.io/kubernetes/staging/src/k8s.io/client-go/Godeps/Godeps.json
  156. +0 −14 vendor/k8s.io/kubernetes/staging/src/k8s.io/client-go/tools/cache/delta_fifo.go
  157. +27 −0 vendor/k8s.io/kubernetes/staging/src/k8s.io/client-go/tools/cache/delta_fifo_test.go
  158. +162 −8 vendor/k8s.io/kubernetes/test/integration/apiserver/max_request_body_bytes_test.go
  159. +17 −11 vendor/k8s.io/kubernetes/test/integration/master/synthetic_master_test.go

Some generated files are not rendered by default. Learn more.

@@ -62,3 +62,5 @@ import:
repo: https://github.com/openshift/gssapi.git
- package: github.com/kylelemons/godebug
version: fa7b53cdfc9105c70f134574002f406232921437
- package: github.com/spf13/afero
version: v1.2.2
@@ -2,12 +2,15 @@ package config

import (
"fmt"
"io"
"net/url"
"os"
"path/filepath"
"strconv"
"strings"

"github.com/openshift/odo/pkg/testingutil/filesystem"

"github.com/golang/glog"
"github.com/pkg/errors"

@@ -31,7 +34,7 @@ type ComponentStorageSettings struct {
Path string `yaml:"Path,omitempty"`
}

// componentSettings holds all component related information
// ComponentSettings holds all component related information
type ComponentSettings struct {
// The builder image to use
Type *string `yaml:"Type,omitempty"`
@@ -102,6 +105,7 @@ type proxyLocalConfig struct {
// serialize it.
type LocalConfigInfo struct {
Filename string `yaml:"FileName,omitempty"`
fs filesystem.Filesystem
LocalConfig `yaml:",omitempty"`
configFileExists bool
}
@@ -130,6 +134,10 @@ func New() (*LocalConfigInfo, error) {
// NewLocalConfigInfo gets the LocalConfigInfo from local config file and creates the local config file in case it's
// not present then it
func NewLocalConfigInfo(cfgDir string) (*LocalConfigInfo, error) {
return newLocalConfigInfo(cfgDir, filesystem.DefaultFs{})
}

func newLocalConfigInfo(cfgDir string, fs filesystem.Filesystem) (*LocalConfigInfo, error) {
configFile, err := getLocalConfigFile(cfgDir)
if err != nil {
return nil, errors.Wrap(err, "unable to get odo config file")
@@ -138,10 +146,11 @@ func NewLocalConfigInfo(cfgDir string) (*LocalConfigInfo, error) {
LocalConfig: NewLocalConfig(),
Filename: configFile,
configFileExists: true,
fs: fs,
}

// if the config file doesn't exist then we dont worry about it and return
if _, err = os.Stat(configFile); os.IsNotExist(err) {
if _, err = c.fs.Stat(configFile); os.IsNotExist(err) {
c.configFileExists = false
return &c, nil
}
@@ -260,9 +269,36 @@ func (lci *LocalConfigInfo) SetConfiguration(parameter string, value interface{}

}

// DeleteConfigDir Deletes the config directory with the config file
func (lci *LocalConfigInfo) DeleteConfigDir() error {
return os.RemoveAll(filepath.Dir(lci.Filename))
// DeleteConfigDirIfEmpty Deletes the config directory if its empty
func (lci *LocalConfigInfo) DeleteConfigDirIfEmpty() error {
configDir := filepath.Dir(lci.Filename)
_, err := lci.fs.Stat(configDir)
if os.IsNotExist(err) {
// If the config dir doesn't exist then we dont mind
return nil
} else if err != nil {
// Possible to not have permission to the dir
return err
}
f, err := lci.fs.Open(configDir)
if err != nil {
return err
}
defer f.Close()
_, err = f.Readdir(1)

// If directory is empty we can remove it
if err == io.EOF {
glog.V(4).Info("Deleting the config directory as well because its empty")

return lci.fs.Remove(configDir)
}
return err
}

// DeleteConfigFile deletes the odo-config.yaml file if it exists
func (lci *LocalConfigInfo) DeleteConfigFile() error {
return util.DeletePath(lci.Filename)
}

// IsSet uses reflection to get the parameter from the localconfig struct, currently
@@ -367,6 +403,7 @@ func (lci *LocalConfigInfo) writeToFile() error {
plc := newProxyLocalConfig()
plc.TypeMeta = lci.typeMeta
plc.ComponentSettings = lci.componentSettings

return util.WriteToFile(&plc, lci.Filename)
}

@@ -4,9 +4,12 @@ import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
"testing"

"github.com/openshift/odo/pkg/testingutil/filesystem"

"github.com/openshift/odo/pkg/util"
)

@@ -439,3 +442,85 @@ func TestGetOSSourcePath(t *testing.T) {
})
}
}

func TestDeleteConfigDirIfEmpty(t *testing.T) {

t.Run("empty config dir", func(t *testing.T) {
fs := filesystem.NewFakeFs()
configDir, err := fs.TempDir(os.TempDir(), "odo")
if err != nil {
t.Error(err)
}
lci, err := mockLocalConfigInfo(configDir, fs)
if err != nil {
t.Error(err)
}
odoDir := filepath.Join(configDir, ".odo")
if _, err = fs.Stat(odoDir); os.IsNotExist(err) {
t.Error("config directory doesn't exist")
}
err = lci.DeleteConfigDirIfEmpty()
if err != nil {
t.Error(err)
}

// read isExists
if _, err := fs.Stat(odoDir); !os.IsNotExist(err) {
t.Error("odo config directory exists even after deleting it")
}

})

t.Run("config dir with test file", func(t *testing.T) {
fs := filesystem.NewFakeFs()
configDir, err := fs.TempDir(os.TempDir(), "odo")

if err != nil {
t.Error(err)
}
lci, err := mockLocalConfigInfo(configDir, fs)
if err != nil {
t.Error(err)
}
odoDir := filepath.Join(configDir, ".odo")

file, err := fs.Create(filepath.Join(odoDir, "testfile"))
if err != nil {
t.Error(err)
}
_, err = file.Write([]byte("hello world"))
if err != nil {
t.Error(err)
}
file.Close()
if err != nil {
t.Fatal("error while setting up test file systems -", err.Error())
}

err = lci.DeleteConfigDirIfEmpty()
if err != nil {
t.Error(err)
}

if _, err := fs.Stat(odoDir); os.IsNotExist(err) {
t.Error("odo config directory doesn't exist even when it wasn't empty")
}

})

}

func mockLocalConfigInfo(configDir string, fs filesystem.Filesystem) (*LocalConfigInfo, error) {

lci := &LocalConfigInfo{
Filename: filepath.Join(configDir, ".odo", "config.yaml"),
fs: fs,
}
err := fs.MkdirAll(filepath.Join(configDir, ".odo"), os.ModePerm)
if err != nil {
return nil, err
}

return lci, nil

}
@@ -3,6 +3,8 @@ package component
import (
"fmt"

"github.com/openshift/odo/pkg/util"

"github.com/golang/glog"
"github.com/spf13/cobra"

@@ -45,6 +47,10 @@ func NewDeleteOptions() *DeleteOptions {
func (do *DeleteOptions) Complete(name string, cmd *cobra.Command, args []string) (err error) {
do.Context = genericclioptions.NewContext(cmd)
err = do.ComponentOptions.Complete(name, cmd, args)

if do.componentContext == "" {
do.componentContext = LocalDirectoryDefaultLocation
}
return
}

@@ -94,13 +100,16 @@ func (do *DeleteOptions) Run() (err error) {
if err != nil {
return err
}
if err = util.DeleteIndexFile(do.componentContext); err != nil {
return err
}

if !cfg.ConfigFileExists() {
return nil
// this checks if the config file exists or not
if err = cfg.DeleteConfigFile(); err != nil {
return err
}

err = cfg.DeleteConfigDir()
if err != nil {
if err = cfg.DeleteConfigDirIfEmpty(); err != nil {
return err
}

0 comments on commit adf3006

Please sign in to comment.
You can’t perform that action at this time.