Add GetConfig method to Network
This commit is contained in:
parent
9e9e98584f
commit
bbae88ab4b
@ -9,6 +9,7 @@ package daemon
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"isle/bootstrap"
|
"isle/bootstrap"
|
||||||
|
"isle/daemon/daecommon"
|
||||||
"isle/daemon/jsonrpc2"
|
"isle/daemon/jsonrpc2"
|
||||||
"isle/daemon/network"
|
"isle/daemon/network"
|
||||||
"isle/nebula"
|
"isle/nebula"
|
||||||
@ -59,6 +60,15 @@ func (c *rpcClient) CreateNetwork(ctx context.Context, name string, domain strin
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *rpcClient) GetConfig(ctx context.Context) (n1 daecommon.NetworkConfig, err error) {
|
||||||
|
err = c.client.Call(
|
||||||
|
ctx,
|
||||||
|
&n1,
|
||||||
|
"GetConfig",
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (c *rpcClient) GetGarageClientParams(ctx context.Context) (g1 network.GarageClientParams, err error) {
|
func (c *rpcClient) GetGarageClientParams(ctx context.Context) (g1 network.GarageClientParams, err error) {
|
||||||
err = c.client.Call(
|
err = c.client.Call(
|
||||||
ctx,
|
ctx,
|
||||||
|
@ -439,6 +439,24 @@ func (d *Daemon) CreateNebulaCertificate(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Daemon) GetConfig(
|
||||||
|
ctx context.Context,
|
||||||
|
) (
|
||||||
|
daecommon.NetworkConfig, error,
|
||||||
|
) {
|
||||||
|
return withNetwork(
|
||||||
|
ctx,
|
||||||
|
d,
|
||||||
|
func(
|
||||||
|
ctx context.Context, n network.Network,
|
||||||
|
) (
|
||||||
|
daecommon.NetworkConfig, error,
|
||||||
|
) {
|
||||||
|
return n.GetConfig(ctx)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// Shutdown blocks until all resources held or created by the daemon,
|
// Shutdown blocks until all resources held or created by the daemon,
|
||||||
// including child processes it has started, have been cleaned up.
|
// including child processes it has started, have been cleaned up.
|
||||||
//
|
//
|
||||||
|
@ -110,6 +110,9 @@ type RPC interface {
|
|||||||
) (
|
) (
|
||||||
nebula.Certificate, error,
|
nebula.Certificate, error,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GetConfig returns the configuration currently in use.
|
||||||
|
GetConfig(context.Context) (daecommon.NetworkConfig, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Network manages membership in a single micropelago network. Each Network
|
// Network manages membership in a single micropelago network. Each Network
|
||||||
@ -880,6 +883,10 @@ func (n *network) CreateNebulaCertificate(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *network) GetConfig(context.Context) (daecommon.NetworkConfig, error) {
|
||||||
|
return n.networkConfig, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (n *network) GetNetworkCreationParams(
|
func (n *network) GetNetworkCreationParams(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
) (
|
) (
|
||||||
|
@ -82,3 +82,25 @@ func TestJoin(t *testing.T) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNetwork_GetConfig(t *testing.T) {
|
||||||
|
var (
|
||||||
|
h = newIntegrationHarness(t)
|
||||||
|
network = h.createNetwork(t, "primus", nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
config, err := network.GetConfig(h.ctx)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(config, network.networkConfig) {
|
||||||
|
t.Fatalf(
|
||||||
|
"Config doesn't match the one used to create the Network\n"+
|
||||||
|
"exp: %+v\n"+
|
||||||
|
"got: %+v",
|
||||||
|
config,
|
||||||
|
network.networkConfig,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user