This improves the code in two ways: first, it makes the function name and the
return type match. Second, it avoids issues found by go vet converting
from uintptr to unsafe.Pointer without any obvious pointer math.
(See: https://pkg.go.dev/unsafe)
Technically, this is an API breaking change but this function is only
public to exchange the internal ceph structure between the rados and
rbd modules. This had the smallest delta and doesn't feel any more
hacky than what already existed in the code. If someone was using this
function externally then too bad.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Moving the errutil pkg to "internal/errutil" makes errutil private-like
and accessible to only other go-ceph packages. The functions it provided
were always meant to be used only by go-ceph, this just makes it more
official. This is a breaking change but it was only available to
outside users for 1 release and it is somewhat doubtful users outside
of go-ceph would have reached for these functions.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This is a minor cleanup that only stops the checker from complaining
rather than actually improving the documentation.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Create an object_iter.go from the Iter related functions that were
formerly in ioctx.go. This makes ioctx a little less of a giant wall of
code as well as making things easier to work on in the future.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This is a minor cleanup that only stops the checker from complaining
rather than actually improving the documentation.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Create an omap.go from the omap functions that were formerly in
ioctx.go. This makes ioctx a little less of a giant wall of code
as well as making things easier to work on in the future.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
RadosError-prefixes are not recommended, instead just Err as prefix is
used.
Also, errors are constants, not variables.
For existing users, backwards compatible constants are available. These
will need to be removed in a future go-ceph release.
Signed-off-by: Niels de Vos <ndevos@redhat.com>
The cephfs function ceph_create_from_rados requires the cluster_t
value, which is current private to the Conn type. Alias the cluster_t
type and allow other pkgs to get it if needed.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
The code path where the pools result buffer was increased in size
then re-fetched was not being tested. Test it.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Testfiy's assert and require libs have helpful functions for
checking values. Use them to reduce a bunch of boilerplate code in the
TestGetPoolByName function.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
A number of the error handling checks do not seem to need to check
for specific non-zero error returns so we should be able to
convert to getRadosError rather than a lot of boiler-plate.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
A number of the functions in rados do not use the simple error
conversion function where is obviously applies. Convert them to use it.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
There is no good reason why the internal error handling support should
be exposed outside the rados package. Make the function lower-cased and
thus private.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
When working on the previous rbd change it was determined that the
connection setup code would block forever if the ceph config was missing
or bad when running the tests. Adjust the connection setup in the rados
pkg such that the tests will not block forever.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Keeping the _test.go code in the same package allows for the testing
of private functions. AFAIK it is more conventional as well.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Release resources that are allocated while configuring the connection to
the cluster. rados_shutdown() should only be needed after a successful
call to rados_connect(), however if the connection has been configured
with non-default parameters, some of the parameters may be allocated
before connecting. rados_shutdown() will free the allocated resources,
even if there has not been a connection yet.
Note that the finalizers get executed during garbage collection, which
can be forced by calling runtime.GC() for testing.
Fixes: #109
Signed-off-by: Niels de Vos <ndevos@redhat.com>
- Use C errno constants in place of hardcoded ints
- Use type inference where possible (especially C.CString
- Don't explicitly specify zero values where value would be default anway
- Rewrap some unnecessarily wrapped short lines
- Use if/else one-liners where value is not needed afterwards
Signed-off-by: Daniel Swarbrick <daniel.swarbrick@gmail.com>