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 <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-09-28 22:21:31 +02:00
parent 951bb481c0
commit 09c94c1c21
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
2 changed files with 6 additions and 0 deletions

View File

@ -110,6 +110,9 @@ func (s *metadataStore) list() ([]Metadata, error) {
for _, dir := range ctxDirs { for _, dir := range ctxDirs {
c, err := s.getByID(contextdir(dir)) c, err := s.getByID(contextdir(dir))
if err != nil { if err != nil {
if os.IsNotExist(err) {
continue
}
return nil, errors.Wrap(err, "failed to read metadata") return nil, errors.Wrap(err, "failed to read metadata")
} }
res = append(res, c) res = append(res, c)

View File

@ -82,6 +82,9 @@ func (s *tlsStore) listContextData(name string) (map[string]EndpointFiles, error
for _, epFS := range epFSs { for _, epFS := range epFSs {
if epFS.IsDir() { if epFS.IsDir() {
fss, err := os.ReadDir(filepath.Join(contextDir, epFS.Name())) fss, err := os.ReadDir(filepath.Join(contextDir, epFS.Name()))
if os.IsNotExist(err) {
continue
}
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "failed to list TLS files for endpoint %s", epFS.Name()) return nil, errors.Wrapf(err, "failed to list TLS files for endpoint %s", epFS.Name())
} }