diff --git a/cli/context/store/store.go b/cli/context/store/store.go index 97a2d93ea6..299bdb9a74 100644 --- a/cli/context/store/store.go +++ b/cli/context/store/store.go @@ -181,7 +181,7 @@ func (s *store) ResetEndpointTLSMaterial(contextName string, endpointName string } func (s *store) ListTLSFiles(name string) (map[string]EndpointFiles, error) { - res, err := s.tls.listContextData(contextdirOf(name)) + res, err := s.tls.listContextData(name) return res, patchErrContextName(err, name) } diff --git a/cli/context/store/tlsstore.go b/cli/context/store/tlsstore.go index 777c9c04f0..30620b3f97 100644 --- a/cli/context/store/tlsstore.go +++ b/cli/context/store/tlsstore.go @@ -62,7 +62,8 @@ func (s *tlsStore) removeAllContextData(name string) error { return os.RemoveAll(s.contextDir(contextdirOf(name))) } -func (s *tlsStore) listContextData(contextID contextdir) (map[string]EndpointFiles, error) { +func (s *tlsStore) listContextData(name string) (map[string]EndpointFiles, error) { + contextID := contextdirOf(name) epFSs, err := os.ReadDir(s.contextDir(contextID)) if err != nil { if os.IsNotExist(err) { diff --git a/cli/context/store/tlsstore_test.go b/cli/context/store/tlsstore_test.go index 3f6b6c4443..9c4c79ebda 100644 --- a/cli/context/store/tlsstore_test.go +++ b/cli/context/store/tlsstore_test.go @@ -49,7 +49,6 @@ func TestTlsListAndBatchRemove(t *testing.T) { } const contextName = "test-ctx" - contextID := contextdirOf(contextName) for name, files := range all { for _, file := range files { err := testee.createOrUpdate(contextName, name, file, []byte("data")) @@ -57,19 +56,19 @@ func TestTlsListAndBatchRemove(t *testing.T) { } } - resAll, err := testee.listContextData(contextID) + resAll, err := testee.listContextData(contextName) assert.NilError(t, err) assert.DeepEqual(t, resAll, all) err = testee.removeAllEndpointData(contextName, "ep3") assert.NilError(t, err) - resEp1ep2, err := testee.listContextData(contextID) + resEp1ep2, err := testee.listContextData(contextName) assert.NilError(t, err) assert.DeepEqual(t, resEp1ep2, ep1ep2) err = testee.removeAllContextData(contextName) assert.NilError(t, err) - resEmpty, err := testee.listContextData(contextID) + resEmpty, err := testee.listContextData(contextName) assert.NilError(t, err) assert.DeepEqual(t, resEmpty, map[string]EndpointFiles{}) }