Skip to content

Commit 6137c97

Browse files
committed
move handlers package
1 parent 044cb85 commit 6137c97

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

pkg/api/deployment.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@ import (
44
"context"
55
"errors"
66

7+
"github.com/threefoldtech/tfgrid-sdk-go/messenger"
78
"github.com/threefoldtech/zosbase/pkg/gridtypes"
89
)
910

1011
func (a *API) DeploymentDeployHandler(ctx context.Context, deployment gridtypes.Deployment) error {
11-
twinID, ok := ctx.Value("twin_id").(uint32)
12+
twinID, ok := ctx.Value(messenger.TwinIdContextKey).(uint32)
1213
if !ok {
1314
return errors.New("could not get twin_id from context")
1415
}
1516
return a.provisionStub.CreateOrUpdate(ctx, twinID, deployment, false)
1617
}
1718

1819
func (a *API) DeploymentUpdateHandler(ctx context.Context, deployment gridtypes.Deployment) error {
19-
twinID, ok := ctx.Value("twin_id").(uint32)
20+
twinID, ok := ctx.Value(messenger.TwinIdContextKey).(uint32)
2021
if !ok {
2122
return errors.New("could not get twin_id from context")
2223
}
@@ -28,23 +29,23 @@ func (a *API) DeploymentDeleteHandler(ctx context.Context, contractID uint64) er
2829
}
2930

3031
func (a *API) DeploymentGetHandler(ctx context.Context, contractID uint64) (gridtypes.Deployment, error) {
31-
twinID, ok := ctx.Value("twin_id").(uint32)
32+
twinID, ok := ctx.Value(messenger.TwinIdContextKey).(uint32)
3233
if !ok {
3334
return gridtypes.Deployment{}, errors.New("could not get twin_id from context")
3435
}
3536
return a.provisionStub.Get(ctx, twinID, contractID)
3637
}
3738

3839
func (a *API) DeploymentListHandler(ctx context.Context) ([]gridtypes.Deployment, error) {
39-
twinID, ok := ctx.Value("twin_id").(uint32)
40+
twinID, ok := ctx.Value(messenger.TwinIdContextKey).(uint32)
4041
if !ok {
4142
return nil, errors.New("could not get twin_id from context")
4243
}
4344
return a.provisionStub.List(ctx, twinID)
4445
}
4546

4647
func (a *API) DeploymentChangesHandler(ctx context.Context, contractID uint64) ([]gridtypes.Workload, error) {
47-
twinID, ok := ctx.Value("twin_id").(uint32)
48+
twinID, ok := ctx.Value(messenger.TwinIdContextKey).(uint32)
4849
if !ok {
4950
return nil, errors.New("could not get twin_id from context")
5051
}

pkg/handlers/handlers.go renamed to pkg/api/jsonrpc/handlers.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package handlers
1+
package jsonrpc
22

33
import (
44
"context"
@@ -10,7 +10,6 @@ import (
1010
"github.com/threefoldtech/zosbase/pkg/gridtypes"
1111
)
1212

13-
// TODO: review the api again, rename the pkg rpcapi
1413
type RpcHandler struct {
1514
api *api.API
1615
}
@@ -43,20 +42,20 @@ func RegisterHandlers(s *messenger.JSONRPCServer, r *RpcHandler) {
4342
s.RegisterHandler("network.interfaces", r.handleNetworkInterfaces)
4443
s.RegisterHandler("network.set_public_nic", r.handleAdminSetPublicNIC)
4544
s.RegisterHandler("network.get_public_nic", r.handleAdminGetPublicNIC)
46-
// s.RegisterHandler("network.admin.interfaces", r.handleAdminInterfaces)
45+
s.RegisterHandler("network.admin.interfaces", r.handleAdminInterfaces)
4746

4847
s.RegisterHandler("deployment.deploy", r.handleDeploymentDeploy)
4948
s.RegisterHandler("deployment.update", r.handleDeploymentUpdate)
5049
s.RegisterHandler("deployment.get", r.handleDeploymentGet)
5150
s.RegisterHandler("deployment.list", r.handleDeploymentList)
5251
s.RegisterHandler("deployment.changes", r.handleDeploymentChanges)
53-
// s.RegisterHandler("deployment.delete", r.handleDeploymentDelete)
52+
s.RegisterHandler("deployment.delete", r.handleDeploymentDelete)
5453

5554
s.RegisterHandler("gpu.list", r.handleGpuList)
5655
s.RegisterHandler("storage.pools", r.handleStoragePools)
5756
s.RegisterHandler("statistics", r.handleStatistics)
5857
s.RegisterHandler("location.get", r.handleLocationGet)
59-
// s.RegisterHandler("vm.logs", r.handleVmLogs)
58+
s.RegisterHandler("vm.logs", r.handleVmLogs)
6059

6160
}
6261

0 commit comments

Comments
 (0)