mirror of https://github.com/docker/cli.git
cli/context/store: remove(): 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:
parent
0bcdff2571
commit
712cc9a1c7
|
@ -44,8 +44,10 @@ func (s *tlsStore) getData(name, endpointName, filename string) ([]byte, error)
|
||||||
return data, nil
|
return data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *tlsStore) remove(contextID contextdir, endpointName, filename string) error {
|
// remove removes a TLS data from an endpoint
|
||||||
err := os.Remove(s.filePath(contextID, endpointName, filename))
|
// TODO(thaJeztah) tlsStore.remove() is not used anywhere outside of tests; should we use removeAllEndpointData() only?
|
||||||
|
func (s *tlsStore) remove(name, endpointName, filename string) error {
|
||||||
|
err := os.Remove(s.filePath(contextdirOf(name), endpointName, filename))
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ func TestTlsCreateUpdateGetRemove(t *testing.T) {
|
||||||
testee := tlsStore{root: t.TempDir()}
|
testee := tlsStore{root: t.TempDir()}
|
||||||
|
|
||||||
const contextName = "test-ctx"
|
const contextName = "test-ctx"
|
||||||
contextID := contextdirOf(contextName)
|
|
||||||
|
|
||||||
_, err := testee.getData(contextName, "test-ep", "test-data")
|
_, err := testee.getData(contextName, "test-ep", "test-data")
|
||||||
assert.Equal(t, true, IsErrTLSDataDoesNotExist(err))
|
assert.Equal(t, true, IsErrTLSDataDoesNotExist(err))
|
||||||
|
@ -26,9 +25,9 @@ func TestTlsCreateUpdateGetRemove(t *testing.T) {
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.Equal(t, string(data), "data2")
|
assert.Equal(t, string(data), "data2")
|
||||||
|
|
||||||
err = testee.remove(contextID, "test-ep", "test-data")
|
err = testee.remove(contextName, "test-ep", "test-data")
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
err = testee.remove(contextID, "test-ep", "test-data")
|
err = testee.remove(contextName, "test-ep", "test-data")
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
_, err = testee.getData(contextName, "test-ep", "test-data")
|
_, err = testee.getData(contextName, "test-ep", "test-data")
|
||||||
|
|
Loading…
Reference in New Issue