Skip to content

Commit 3d95463

Browse files
committed
remove types of zos4
1 parent ab7b1ed commit 3d95463

File tree

6 files changed

+12
-133
lines changed

6 files changed

+12
-133
lines changed

go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,3 @@ require (
164164
)
165165

166166
replace github.com/docker/distribution v2.7.1+incompatible => github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible
167-
168-
replace github.com/threefoldtech/zosbase => ../zosbase

pkg/registrar_gateway.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
substrateTypes "github.com/centrifuge/go-substrate-rpc-client/v4/types"
77
substrate "github.com/threefoldtech/tfchain/clients/tfchain-client-go"
88
"github.com/threefoldtech/tfgrid4-sdk-go/node-registrar/client"
9-
"github.com/threefoldtech/zos4/pkg/types"
109
"github.com/threefoldtech/zosbase/pkg"
1110
)
1211

@@ -18,11 +17,11 @@ type RegistrarGateway interface {
1817
GetTwin(id uint64) (client.Account, error)
1918
GetTwinByPubKey(pk []byte) (uint64, error)
2019

21-
CreateNode(node types.UpdateNodeRequest) (uint64, error)
20+
CreateNode(node client.Node) (uint64, error)
2221
GetNode(id uint64) (client.Node, error)
2322
GetNodes(farmID uint64) ([]uint64, error)
2423
GetNodeByTwinID(twin uint64) (client.Node, error)
25-
UpdateNode(node types.UpdateNodeRequest) error
24+
UpdateNode(node client.Node) error
2625
UpdateNodeUptimeV2(uptime time.Duration, timestamp time.Time) (err error)
2726

2827
GetFarm(id uint64) (client.Farm, error)

pkg/registrar_gateway/registrar_gateway.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"github.com/threefoldtech/zbus"
1818
zos4Pkg "github.com/threefoldtech/zos4/pkg"
1919
"github.com/threefoldtech/zos4/pkg/stubs"
20-
"github.com/threefoldtech/zos4/pkg/types"
2120
"github.com/threefoldtech/zosbase/pkg"
2221
"github.com/threefoldtech/zosbase/pkg/environment"
2322
)
@@ -62,7 +61,7 @@ func (r *registrarGateway) GetZosVersion() (client.ZosVersion, error) {
6261
return r.registrarClient.GetZosVersion()
6362
}
6463

65-
func (r *registrarGateway) CreateNode(node types.UpdateNodeRequest) (uint64, error) {
64+
func (r *registrarGateway) CreateNode(node client.Node) (uint64, error) {
6665
log.Debug().
6766
Str("method", "CreateNode").
6867
Uint32("farm_id", uint32(node.FarmID)).
@@ -162,7 +161,7 @@ func (r *registrarGateway) GetTwinByPubKey(pk []byte) (result uint64, err error)
162161
return account.TwinID, err
163162
}
164163

165-
func (r *registrarGateway) UpdateNode(node types.UpdateNodeRequest) error {
164+
func (r *registrarGateway) UpdateNode(node client.Node) error {
166165
log.Debug().
167166
Str("method", "UpdateNode").
168167
Uint64("twin_id", node.TwinID).

pkg/registrar_light/register.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/threefoldtech/tfgrid4-sdk-go/node-registrar/client"
1313
"github.com/threefoldtech/zbus"
1414
zos4Stubs "github.com/threefoldtech/zos4/pkg/stubs"
15-
"github.com/threefoldtech/zos4/pkg/types"
1615
"github.com/threefoldtech/zosbase/pkg/environment"
1716
"github.com/threefoldtech/zosbase/pkg/geoip"
1817
gridtypes "github.com/threefoldtech/zosbase/pkg/gridtypes"
@@ -158,22 +157,11 @@ func registerNode(
158157
SerialNumber: serial,
159158
}
160159

161-
req := types.UpdateNodeRequest{
162-
TwinID: real.TwinID,
163-
FarmID: real.FarmID,
164-
Resources: real.Resources,
165-
Location: real.Location,
166-
Interfaces: real.Interfaces,
167-
SecureBoot: real.SecureBoot,
168-
Virtualized: real.Virtualized,
169-
SerialNumber: real.SerialNumber,
170-
}
171-
172160
node, regErr := registrarGateway.GetNodeByTwinID(ctx, twinID)
173161
nodeID = node.NodeID
174162
if regErr != nil {
175163
if strings.Contains(regErr.Error(), client.ErrorNodeNotFround.Error()) {
176-
nodeID, err = registrarGateway.CreateNode(ctx, req)
164+
nodeID, err = registrarGateway.CreateNode(ctx, real)
177165
if err != nil {
178166
return 0, 0, errors.Wrap(err, "failed to create node on registrar")
179167
}
@@ -202,7 +190,7 @@ func registerNode(
202190

203191
if !reflect.DeepEqual(real, onRegistrar) {
204192
log.Debug().Msgf("node data have changed, issuing an update node real: %+v\nonRegistrar: %+v", real, onRegistrar)
205-
err := registrarGateway.UpdateNode(ctx, req)
193+
err := registrarGateway.UpdateNode(ctx, real)
206194
if err != nil {
207195
return 0, 0, errors.Wrapf(err, "failed to update node data with id: %d", nodeID)
208196
}

pkg/stubs/registrar-gateway.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ package stubs
66

77
import (
88
"context"
9-
types1 "github.com/centrifuge/go-substrate-rpc-client/v4/types"
9+
types "github.com/centrifuge/go-substrate-rpc-client/v4/types"
1010
tfchainclientgo "github.com/threefoldtech/tfchain/clients/tfchain-client-go"
1111
client "github.com/threefoldtech/tfgrid4-sdk-go/node-registrar/client"
1212
zbus "github.com/threefoldtech/zbus"
13-
types "github.com/threefoldtech/zos4/pkg/types"
1413
pkg "github.com/threefoldtech/zosbase/pkg"
1514
"time"
1615
)
@@ -32,7 +31,7 @@ func NewRegistrarGatewayStub(client zbus.Client) *RegistrarGatewayStub {
3231
}
3332
}
3433

35-
func (s *RegistrarGatewayStub) CreateNode(ctx context.Context, arg0 types.UpdateNodeRequest) (ret0 uint64, ret1 error) {
34+
func (s *RegistrarGatewayStub) CreateNode(ctx context.Context, arg0 client.Node) (ret0 uint64, ret1 error) {
3635
args := []interface{}{arg0}
3736
result, err := s.client.RequestContext(ctx, s.module, s.object, "CreateNode", args...)
3837
if err != nil {
@@ -168,7 +167,7 @@ func (s *RegistrarGatewayStub) GetNodeByTwinID(ctx context.Context, arg0 uint64)
168167
return
169168
}
170169

171-
func (s *RegistrarGatewayStub) GetNodeContracts(ctx context.Context, arg0 uint32) (ret0 []types1.U64, ret1 error) {
170+
func (s *RegistrarGatewayStub) GetNodeContracts(ctx context.Context, arg0 uint32) (ret0 []types.U64, ret1 error) {
172171
args := []interface{}{arg0}
173172
result, err := s.client.RequestContext(ctx, s.module, s.object, "GetNodeContracts", args...)
174173
if err != nil {
@@ -304,7 +303,7 @@ func (s *RegistrarGatewayStub) GetZosVersion(ctx context.Context) (ret0 client.Z
304303
return
305304
}
306305

307-
func (s *RegistrarGatewayStub) Report(ctx context.Context, arg0 []tfchainclientgo.NruConsumption) (ret0 types1.Hash, ret1 error) {
306+
func (s *RegistrarGatewayStub) Report(ctx context.Context, arg0 []tfchainclientgo.NruConsumption) (ret0 types.Hash, ret1 error) {
308307
args := []interface{}{arg0}
309308
result, err := s.client.RequestContext(ctx, s.module, s.object, "Report", args...)
310309
if err != nil {
@@ -339,7 +338,7 @@ func (s *RegistrarGatewayStub) SetContractConsumption(ctx context.Context, arg0
339338
return
340339
}
341340

342-
func (s *RegistrarGatewayStub) SetNodePowerState(ctx context.Context, arg0 bool) (ret0 types1.Hash, ret1 error) {
341+
func (s *RegistrarGatewayStub) SetNodePowerState(ctx context.Context, arg0 bool) (ret0 types.Hash, ret1 error) {
343342
args := []interface{}{arg0}
344343
result, err := s.client.RequestContext(ctx, s.module, s.object, "SetNodePowerState", args...)
345344
if err != nil {
@@ -356,7 +355,7 @@ func (s *RegistrarGatewayStub) SetNodePowerState(ctx context.Context, arg0 bool)
356355
return
357356
}
358357

359-
func (s *RegistrarGatewayStub) UpdateNode(ctx context.Context, arg0 types.UpdateNodeRequest) (ret0 error) {
358+
func (s *RegistrarGatewayStub) UpdateNode(ctx context.Context, arg0 client.Node) (ret0 error) {
360359
args := []interface{}{arg0}
361360
result, err := s.client.RequestContext(ctx, s.module, s.object, "UpdateNode", args...)
362361
if err != nil {

pkg/types/types.go

Lines changed: 0 additions & 104 deletions
This file was deleted.

0 commit comments

Comments
 (0)