From 09c94c1c21cb2ed02d347934de85b6163dc62ddf Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 28 Sep 2022 22:21:31 +0200 Subject: [PATCH] cli/context/store: List(): don't interrupt listing for not-found errors There's no reason to stop listing contexts if a context does not exist while iterating over the directories, Signed-off-by: Sebastiaan van Stijn --- cli/context/store/metadatastore.go | 3 +++ cli/context/store/tlsstore.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/cli/context/store/metadatastore.go b/cli/context/store/metadatastore.go index 42edc8a786..5222897f39 100644 --- a/cli/context/store/metadatastore.go +++ b/cli/context/store/metadatastore.go @@ -110,6 +110,9 @@ func (s *metadataStore) list() ([]Metadata, error) { for _, dir := range ctxDirs { c, err := s.getByID(contextdir(dir)) if err != nil { + if os.IsNotExist(err) { + continue + } return nil, errors.Wrap(err, "failed to read metadata") } res = append(res, c) diff --git a/cli/context/store/tlsstore.go b/cli/context/store/tlsstore.go index 9992481405..dbd1649b99 100644 --- a/cli/context/store/tlsstore.go +++ b/cli/context/store/tlsstore.go @@ -82,6 +82,9 @@ func (s *tlsStore) listContextData(name string) (map[string]EndpointFiles, error for _, epFS := range epFSs { if epFS.IsDir() { fss, err := os.ReadDir(filepath.Join(contextDir, epFS.Name())) + if os.IsNotExist(err) { + continue + } if err != nil { return nil, errors.Wrapf(err, "failed to list TLS files for endpoint %s", epFS.Name()) }