Remove remaining extraneous 'Result' RPC-related struct types
This commit is contained in:
parent
06a345ecd1
commit
038a28bb02
@ -43,13 +43,12 @@ var subCmdHostCreate = subCmd{
|
||||
return errors.New("--hostname is required")
|
||||
}
|
||||
|
||||
res, err := ctx.daemonRPC.CreateHost(ctx, daemon.CreateHostRequest{
|
||||
HostName: hostName.V,
|
||||
Opts: daemon.CreateHostOpts{
|
||||
res, err := ctx.daemonRPC.CreateHost(
|
||||
ctx, hostName.V, daemon.CreateHostOpts{
|
||||
IP: ip.V,
|
||||
CanCreateHosts: *canCreateHosts,
|
||||
},
|
||||
})
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("calling CreateHost: %w", err)
|
||||
}
|
||||
@ -117,9 +116,7 @@ var subCmdHostRemove = subCmd{
|
||||
return errors.New("--hostname is required")
|
||||
}
|
||||
|
||||
_, err := ctx.daemonRPC.RemoveHost(ctx, daemon.RemoveHostRequest{
|
||||
HostName: hostName.V,
|
||||
})
|
||||
_, err := ctx.daemonRPC.RemoveHost(ctx, hostName.V)
|
||||
if err != nil {
|
||||
return fmt.Errorf("calling RemoveHost: %w", err)
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"isle/daemon"
|
||||
"isle/jsonutil"
|
||||
"isle/nebula"
|
||||
"os"
|
||||
@ -48,16 +47,13 @@ var subCmdNebulaCreateCert = subCmd{
|
||||
}
|
||||
|
||||
res, err := ctx.daemonRPC.CreateNebulaCertificate(
|
||||
ctx, daemon.CreateNebulaCertificateRequest{
|
||||
HostName: hostName.V,
|
||||
HostEncryptingPublicKey: hostPub,
|
||||
},
|
||||
ctx, hostName.V, hostPub,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("calling CreateNebulaCertificate: %w", err)
|
||||
}
|
||||
|
||||
nebulaHostCertPEM, err := res.HostNebulaCertifcate.Unwrap().MarshalToPEM()
|
||||
nebulaHostCertPEM, err := res.HostNebulaCertificate.Unwrap().MarshalToPEM()
|
||||
if err != nil {
|
||||
return fmt.Errorf("marshaling cert to PEM: %w", err)
|
||||
}
|
||||
|
@ -22,22 +22,24 @@ func RPCFromClient(client jsonrpc2.Client) RPC {
|
||||
return &rpcClient{client}
|
||||
}
|
||||
|
||||
func (c *rpcClient) CreateHost(ctx context.Context, req CreateHostRequest) (c2 CreateHostResult, err error) {
|
||||
func (c *rpcClient) CreateHost(ctx context.Context, hostName nebula.HostName, opts CreateHostOpts) (c2 CreateHostResult, err error) {
|
||||
err = c.client.Call(
|
||||
ctx,
|
||||
&c2,
|
||||
"CreateHost",
|
||||
req,
|
||||
hostName,
|
||||
opts,
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *rpcClient) CreateNebulaCertificate(ctx context.Context, req CreateNebulaCertificateRequest) (c2 CreateNebulaCertificateResult, err error) {
|
||||
func (c *rpcClient) CreateNebulaCertificate(ctx context.Context, hostName nebula.HostName, hostEncryptingPublicKey nebula.EncryptingPublicKey) (c2 CreateNebulaCertificateResult, err error) {
|
||||
err = c.client.Call(
|
||||
ctx,
|
||||
&c2,
|
||||
"CreateNebulaCertificate",
|
||||
req,
|
||||
hostName,
|
||||
hostEncryptingPublicKey,
|
||||
)
|
||||
return
|
||||
}
|
||||
@ -94,13 +96,13 @@ func (c *rpcClient) JoinNetwork(ctx context.Context, req JoiningBootstrap) (st1
|
||||
return
|
||||
}
|
||||
|
||||
func (c *rpcClient) RemoveHost(ctx context.Context, req RemoveHostRequest) (st1 struct {
|
||||
func (c *rpcClient) RemoveHost(ctx context.Context, hostName nebula.HostName) (st1 struct {
|
||||
}, err error) {
|
||||
err = c.client.Call(
|
||||
ctx,
|
||||
&st1,
|
||||
"RemoveHost",
|
||||
req,
|
||||
hostName,
|
||||
)
|
||||
return
|
||||
}
|
||||
|
@ -16,40 +16,15 @@ type GetHostsResult struct {
|
||||
Hosts []bootstrap.Host
|
||||
}
|
||||
|
||||
// RemoveHostRequest contains the arguments to the RemoveHost RPC method.
|
||||
//
|
||||
// All fields are required.
|
||||
type RemoveHostRequest struct {
|
||||
HostName nebula.HostName
|
||||
}
|
||||
|
||||
// CreateHostRequest contains the arguments to the
|
||||
// CreateHost RPC method.
|
||||
//
|
||||
// All fields are required.
|
||||
type CreateHostRequest struct {
|
||||
HostName nebula.HostName
|
||||
Opts CreateHostOpts
|
||||
}
|
||||
|
||||
// CreateHostResult wraps the results from the CreateHost RPC method.
|
||||
type CreateHostResult struct {
|
||||
JoiningBootstrap JoiningBootstrap
|
||||
}
|
||||
|
||||
// CreateNebulaCertificateRequest contains the arguments to the
|
||||
// CreateNebulaCertificate RPC method.
|
||||
//
|
||||
// All fields are required.
|
||||
type CreateNebulaCertificateRequest struct {
|
||||
HostName nebula.HostName
|
||||
HostEncryptingPublicKey nebula.EncryptingPublicKey
|
||||
}
|
||||
|
||||
// CreateNebulaCertificateResult wraps the results from the
|
||||
// CreateNebulaCertificate RPC method.
|
||||
type CreateNebulaCertificateResult struct {
|
||||
HostNebulaCertifcate nebula.Certificate
|
||||
HostNebulaCertificate nebula.Certificate
|
||||
}
|
||||
|
||||
// RPC exposes all RPC methods which are available to be called over the RPC
|
||||
@ -98,14 +73,14 @@ type RPC interface {
|
||||
|
||||
// RemoveHost passes the call through to the Daemon method of the same name.
|
||||
RemoveHost(
|
||||
ctx context.Context, req RemoveHostRequest,
|
||||
ctx context.Context, hostName nebula.HostName,
|
||||
) (
|
||||
struct{}, error,
|
||||
)
|
||||
|
||||
// CreateHost passes the call through to the Daemon method of the same name.
|
||||
CreateHost(
|
||||
ctx context.Context, req CreateHostRequest,
|
||||
ctx context.Context, hostName nebula.HostName, opts CreateHostOpts,
|
||||
) (
|
||||
CreateHostResult, error,
|
||||
)
|
||||
@ -113,7 +88,9 @@ type RPC interface {
|
||||
// CreateNebulaCertificate passes the call through to the Daemon method of
|
||||
// the same name.
|
||||
CreateNebulaCertificate(
|
||||
ctx context.Context, req CreateNebulaCertificateRequest,
|
||||
ctx context.Context,
|
||||
hostName nebula.HostName,
|
||||
hostEncryptingPublicKey nebula.EncryptingPublicKey,
|
||||
) (
|
||||
CreateNebulaCertificateResult, error,
|
||||
)
|
||||
@ -188,21 +165,19 @@ func (r *rpcImpl) GetNebulaCAPublicCredentials(
|
||||
}
|
||||
|
||||
func (r *rpcImpl) RemoveHost(
|
||||
ctx context.Context, req RemoveHostRequest,
|
||||
ctx context.Context, hostName nebula.HostName,
|
||||
) (
|
||||
struct{}, error,
|
||||
) {
|
||||
return struct{}{}, r.daemon.RemoveHost(ctx, req.HostName)
|
||||
return struct{}{}, r.daemon.RemoveHost(ctx, hostName)
|
||||
}
|
||||
|
||||
func (r *rpcImpl) CreateHost(
|
||||
ctx context.Context, req CreateHostRequest,
|
||||
ctx context.Context, hostName nebula.HostName, opts CreateHostOpts,
|
||||
) (
|
||||
CreateHostResult, error,
|
||||
) {
|
||||
joiningBootstrap, err := r.daemon.CreateHost(
|
||||
ctx, req.HostName, req.Opts,
|
||||
)
|
||||
joiningBootstrap, err := r.daemon.CreateHost(ctx, hostName, opts)
|
||||
if err != nil {
|
||||
return CreateHostResult{}, err
|
||||
}
|
||||
@ -211,18 +186,18 @@ func (r *rpcImpl) CreateHost(
|
||||
}
|
||||
|
||||
func (r *rpcImpl) CreateNebulaCertificate(
|
||||
ctx context.Context, req CreateNebulaCertificateRequest,
|
||||
ctx context.Context,
|
||||
hostName nebula.HostName,
|
||||
hostEncryptingPublicKey nebula.EncryptingPublicKey,
|
||||
) (
|
||||
CreateNebulaCertificateResult, error,
|
||||
) {
|
||||
cert, err := r.daemon.CreateNebulaCertificate(
|
||||
ctx, req.HostName, req.HostEncryptingPublicKey,
|
||||
ctx, hostName, hostEncryptingPublicKey,
|
||||
)
|
||||
if err != nil {
|
||||
return CreateNebulaCertificateResult{}, err
|
||||
}
|
||||
|
||||
return CreateNebulaCertificateResult{
|
||||
HostNebulaCertifcate: cert,
|
||||
}, nil
|
||||
return CreateNebulaCertificateResult{HostNebulaCertificate: cert}, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user