mirror of https://github.com/ceph/go-ceph
cephfs: add function ParseDefaultConfigEnv to set ceph config from env
Similar to the rados function of the same name, ParseDefaultConfigEnv uses the environment to configure the cephfs mount. Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
parent
c34501fc6a
commit
7dea1f728f
|
@ -92,6 +92,19 @@ func (mount *MountInfo) ParseConfigArgv(argv []string) error {
|
|||
return getError(ret)
|
||||
}
|
||||
|
||||
// ParseDefaultConfigEnv configures the mount from the default Ceph
|
||||
// environment variable CEPH_ARGS.
|
||||
//
|
||||
// Implements:
|
||||
// int ceph_conf_parse_env(struct ceph_mount_info *cmount, const char *var);
|
||||
func (mount *MountInfo) ParseDefaultConfigEnv() error {
|
||||
if err := mount.validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
ret := C.ceph_conf_parse_env(mount.mount, nil)
|
||||
return getError(ret)
|
||||
}
|
||||
|
||||
// SetConfigOption sets the value of the configuration option identified by
|
||||
// the given name.
|
||||
//
|
||||
|
|
|
@ -299,6 +299,26 @@ func TestParseConfigArgv(t *testing.T) {
|
|||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestParseDefaultConfigEnv(t *testing.T) {
|
||||
mount, err := CreateMount()
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, mount)
|
||||
defer func() { assert.NoError(t, mount.Release()) }()
|
||||
|
||||
origVal, err := mount.GetConfigOption("log_file")
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = os.Setenv("CEPH_ARGS", "--log_file /dev/null")
|
||||
assert.NoError(t, err)
|
||||
err = mount.ParseDefaultConfigEnv()
|
||||
assert.NoError(t, err)
|
||||
|
||||
currVal, err := mount.GetConfigOption("log_file")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "/dev/null", currVal)
|
||||
assert.NotEqual(t, "/dev/null", origVal)
|
||||
}
|
||||
|
||||
func TestValidate(t *testing.T) {
|
||||
mount, err := CreateMount()
|
||||
assert.NoError(t, err)
|
||||
|
|
Loading…
Reference in New Issue