cli/context/store: removeAllEndpointData(): accept name instead of ID

This allows callers to just pass the name, and handle the conversion to ID and
path internally.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-09-28 17:36:21 +02:00
parent 42e275eaf6
commit c3eb116f9c
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
3 changed files with 4 additions and 4 deletions

View File

@ -168,7 +168,7 @@ func (s *store) ResetTLSMaterial(name string, data *ContextTLSData) error {
func (s *store) ResetEndpointTLSMaterial(contextName string, endpointName string, data *EndpointTLSData) error {
id := contextdirOf(contextName)
if err := s.tls.removeAllEndpointData(id, endpointName); err != nil {
if err := s.tls.removeAllEndpointData(contextName, endpointName); err != nil {
return patchErrContextName(err, contextName)
}
if data == nil {

View File

@ -51,8 +51,8 @@ func (s *tlsStore) remove(contextID contextdir, endpointName, filename string) e
return err
}
func (s *tlsStore) removeAllEndpointData(contextID contextdir, endpointName string) error {
return os.RemoveAll(s.endpointDir(contextID, endpointName))
func (s *tlsStore) removeAllEndpointData(name, endpointName string) error {
return os.RemoveAll(s.endpointDir(contextdirOf(name), endpointName))
}
func (s *tlsStore) removeAllContextData(name string) error {

View File

@ -62,7 +62,7 @@ func TestTlsListAndBatchRemove(t *testing.T) {
assert.NilError(t, err)
assert.DeepEqual(t, resAll, all)
err = testee.removeAllEndpointData(contextID, "ep3")
err = testee.removeAllEndpointData(contextName, "ep3")
assert.NilError(t, err)
resEp1ep2, err := testee.listContextData(contextID)
assert.NilError(t, err)