Skip to content

Commit

Permalink
removes submodules
Browse files Browse the repository at this point in the history
Signed-off-by: Ashraf Fouda <[email protected]>
  • Loading branch information
ashraffouda committed Jan 30, 2023
1 parent ed3177d commit bff3cac
Show file tree
Hide file tree
Showing 29 changed files with 233 additions and 870 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ example.tf
terraform.tfplan
terraform.tfstate
**/.terraform/*
**/.terraform*
bin/
dist/
modules-dev/
Expand All @@ -24,7 +25,7 @@ website/node_modules
*.iml
*.test
*.iml

state.json
website/vendor

# Test exclusions
Expand Down
12 changes: 0 additions & 12 deletions .gitmodules

This file was deleted.

11 changes: 4 additions & 7 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
GOPATH=$(shell go env GOPATH)

default: submodules build-dev
default: build-dev

# Run acceptance tests
.PHONY: testacc build docs

submodules:
git submodule init
git submodule update

build-dev:
go get
Expand All @@ -19,13 +16,13 @@ build-dev:
docs:
go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs

testacc: submodules
testacc:
TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m

unittests: submodules
unittests:
go test -v ./...

integrationtests: submodules
integrationtests:
go test -v ./tests/... -p 1 --tags=integration

tests: unittests integrationtests
Expand Down
18 changes: 3 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ require (
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.8.1
github.com/threefoldtech/go-rmb v0.2.2
github.com/threefoldtech/substrate-client v0.0.0-20230103083438-c6d86a2e6338
github.com/threefoldtech/substrate-client-main v0.0.1
github.com/threefoldtech/substrate-client-qa v0.0.1
github.com/threefoldtech/substrate-client-test v0.0.1
github.com/threefoldtech/zos v0.5.6-0.20230103093557-d9c7fe2b92e7
github.com/threefoldtech/substrate-client v0.0.0-20220927111941-026e0cf92661
github.com/threefoldtech/zos v0.5.6-0.20221018094127-d678e483dcc4
golang.org/x/net v0.3.0 // indirect
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20210803171230-4253848d036c
)
Expand All @@ -28,7 +25,6 @@ require (
github.com/goombaio/namegenerator v0.0.0-20181006234301-989e774b106e
github.com/hashicorp/go-multierror v1.1.1
github.com/threefoldtech/grid_proxy_server v1.6.6
github.com/threefoldtech/substrate-client-dev v0.0.1
github.com/vedhavyas/go-subkey v1.0.3
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa
)
Expand Down Expand Up @@ -135,12 +131,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.5 => github.com/threefoldtech/go-substrate-rpc-client/v4 v4.0.6-0.20230102154731-7c633b7d3c71

replace github.com/threefoldtech/substrate-client-dev v0.0.1 => ./pkg/substrates/substrate-dev

replace github.com/threefoldtech/substrate-client-test v0.0.1 => ./pkg/substrates/substrate-test

replace github.com/threefoldtech/substrate-client-qa v0.0.1 => ./pkg/substrates/substrate-qa

replace github.com/threefoldtech/substrate-client-main v0.0.1 => ./pkg/substrates/substrate-main
replace github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.5 => github.com/threefoldtech/go-substrate-rpc-client/v4 v4.0.6-0.20220927094755-0f0d22c73cc7
13 changes: 5 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -879,14 +879,12 @@ github.com/lestrrat-go/pdebug/v3 v3.0.1/go.mod h1:za+m+Ve24yCxTEhR59N7UlnJomWwCi
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lxn/walk v0.0.0-20210112085537-c389da54e794/go.mod h1:E23UucZGqpuUANJooIbHWCufXvOcT6E7Stq81gU+CSQ=
github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk=
github.com/machinebox/graphql v0.2.2/go.mod h1:F+kbVMHuwrQ5tYgU9JXlnskM8nOaFxCAEolaQybkjWA=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho=
github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
Expand Down Expand Up @@ -1221,17 +1219,16 @@ github.com/threefoldtech/0-fs v1.3.1-0.20201203163303-d963de9adea7/go.mod h1:OPP
github.com/threefoldtech/go-rmb v0.1.11-0.20220224131627-825c23c921d3/go.mod h1:iTDlnSja/nUsQ9XyrpOhm8hwvPMooeh80+tGC9TYCV0=
github.com/threefoldtech/go-rmb v0.2.2 h1:BfLavyRbZ818xtXGf7VbI4u+a691bILfLSt5GR3IDBc=
github.com/threefoldtech/go-rmb v0.2.2/go.mod h1:/ZQY/0xUqgHKMNVillCDi/XJ5zwHlDhFOJd/sYreaY4=
github.com/threefoldtech/go-substrate-rpc-client/v4 v4.0.6-0.20230102154731-7c633b7d3c71 h1:vvoXPRI10quMOEXHKcakKhBZe+TlLXhNsh1wwX4cyk4=
github.com/threefoldtech/go-substrate-rpc-client/v4 v4.0.6-0.20230102154731-7c633b7d3c71/go.mod h1:5g1oM4Zu3BOaLpsKQ+O8PAv2kNuq+kPcA1VzFbsSqxE=
github.com/threefoldtech/go-substrate-rpc-client/v4 v4.0.6-0.20220927094755-0f0d22c73cc7 h1:X4wbo5/Wm7eYBu2oYXr/C93wvwXDSrDXBrRk+Ywuk0s=
github.com/threefoldtech/go-substrate-rpc-client/v4 v4.0.6-0.20220927094755-0f0d22c73cc7/go.mod h1:5g1oM4Zu3BOaLpsKQ+O8PAv2kNuq+kPcA1VzFbsSqxE=
github.com/threefoldtech/grid_proxy_server v1.6.6 h1:NL/iKUx7wk1GHN7WjahtU4GSAGK/PsGOrzBksdx1xe4=
github.com/threefoldtech/grid_proxy_server v1.6.6/go.mod h1:CCj6+Y+8juSCp+FCtaYa1rZAYFAc+vrX3Mh+dzoc4m8=
github.com/threefoldtech/substrate-client v0.0.0-20220224131248-f56a2e9fa1d4/go.mod h1:Lpsz7gVNSdbWD8erfVh1AZv2wnProc7g/QHJiYp5lP8=
github.com/threefoldtech/substrate-client v0.0.0-20220927111941-026e0cf92661 h1:97p/xt7jRmsydqFbJ1XgpPUJKWfbHzTc5K6B3a6Lep8=
github.com/threefoldtech/substrate-client v0.0.0-20220927111941-026e0cf92661/go.mod h1:U8sNNYpXyxEKuLUm4jTacuWu43vU0iu2l+K8GXIcbLo=
github.com/threefoldtech/substrate-client v0.0.0-20230103083438-c6d86a2e6338 h1:944udPn3N1Nwx0qYWeZJTlvurPMuKyhcCRXJcRA8/pE=
github.com/threefoldtech/substrate-client v0.0.0-20230103083438-c6d86a2e6338/go.mod h1:ys/GJLeLmNX8E36UFMeR0yZC5Lo4PufYtfwsVX8H/AM=
github.com/threefoldtech/zbus v1.0.0/go.mod h1:E/v/xEvG/l6z/Oj0aDkuSUXFm/1RVJkhKBwDTAIdsHo=
github.com/threefoldtech/zos v0.5.6-0.20230103093557-d9c7fe2b92e7 h1:wGArjIhGbiMK55jCbj08/sxvzKHjxyphglvPCfOtWGE=
github.com/threefoldtech/zos v0.5.6-0.20230103093557-d9c7fe2b92e7/go.mod h1:BhZ2qsjBpl0LZPirBOWtPFF013HPmN/BN6PivDyK6zo=
github.com/threefoldtech/zos v0.5.6-0.20221018094127-d678e483dcc4 h1:5FzG/oSHJsLiA9w9VIiQVpM/DYcTVQlsu2e4xn0xQuA=
github.com/threefoldtech/zos v0.5.6-0.20221018094127-d678e483dcc4/go.mod h1:QcGh1EcWGn8un1zEd3Rfr7202WBbVG0F/+Zik3HeAvA=
github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
github.com/tinylib/msgp v1.1.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg=
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/mocks/manager_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions internal/provider/mocks/substrate_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 14 additions & 13 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/pkg/errors"
proxy "github.com/threefoldtech/grid_proxy_server/pkg/client"
"github.com/threefoldtech/substrate-client"
client "github.com/threefoldtech/terraform-provider-grid/internal/node"
"github.com/threefoldtech/terraform-provider-grid/pkg/state"
"github.com/threefoldtech/terraform-provider-grid/pkg/subi"
Expand All @@ -30,12 +31,12 @@ var (
"qa": "https://gridproxy.qa.grid.tf/",
"main": "https://gridproxy.grid.tf/",
}
SubstrateVersion = map[string]func(url ...string) subi.Manager{
"dev": subi.NewDevManager,
"qa": subi.NewQAManager,
"test": subi.NewTestManager,
"main": subi.NewMMainanager,
}
// SubstrateVersion = map[string]func(url ...string) subi.Manager{
// "dev": subi.NewDevManager,
// "qa": subi.NewQAManager,
// "test": subi.NewTestManager,
// "main": subi.NewMMainanager,
// }
)

func init() {
Expand Down Expand Up @@ -137,7 +138,7 @@ type apiClient struct {
rmb rmb.Client
substrateConn subi.SubstrateExt
manager subi.Manager
identity subi.Identity
identity substrate.Identity
state state.StateI
}

Expand All @@ -149,11 +150,11 @@ func providerConfigure(st state.StateI) (func(ctx context.Context, d *schema.Res
apiClient := apiClient{}
apiClient.mnemonics = d.Get("mnemonics").(string)
key_type := d.Get("key_type").(string)
var identity subi.Identity
var identity substrate.Identity
if key_type == "ed25519" {
identity, err = subi.NewIdentityFromEd25519Phrase(string(apiClient.mnemonics))
identity, err = substrate.NewIdentityFromEd25519Phrase(string(apiClient.mnemonics))
} else if key_type == "sr25519" {
identity, err = subi.NewIdentityFromSr25519Phrase(string(apiClient.mnemonics))
identity, err = substrate.NewIdentityFromSr25519Phrase(string(apiClient.mnemonics))
} else {
err = errors.New("key_type must be one of ed25519 and sr25519")
}
Expand Down Expand Up @@ -181,7 +182,7 @@ func providerConfigure(st state.StateI) (func(ctx context.Context, d *schema.Res
rmb_proxy_url = passed_rmb_proxy_url
}
log.Printf("substrate url: %s %s\n", apiClient.substrate_url, substrate_url)
apiClient.manager = SubstrateVersion[network](apiClient.substrate_url)
apiClient.manager = subi.NewManager(apiClient.substrate_url)
sub, err := apiClient.manager.SubstrateExt()
if err != nil {
return nil, diag.FromErr(errors.Wrap(err, "couldn't get substrate client"))
Expand All @@ -198,7 +199,7 @@ func providerConfigure(st state.StateI) (func(ctx context.Context, d *schema.Res
}
pub := sk.Public()
twin, err := sub.GetTwinByPubKey(pub)
if err != nil && errors.Is(err, subi.ErrNotFound) {
if err != nil && errors.Is(err, substrate.ErrNotFound) {
return nil, diag.Errorf("no twin associated with the accound with the given mnemonics")
}
if err != nil {
Expand All @@ -210,7 +211,7 @@ func providerConfigure(st state.StateI) (func(ctx context.Context, d *schema.Res
verify_reply := d.Get("verify_reply").(bool)
cl, err = client.NewProxyBus(rmb_proxy_url, apiClient.twin_id, apiClient.substrateConn, identity, verify_reply)
} else {
cl, err = rmb.NewRMBClient(apiClient.rmb_redis_url)
cl, err = rmb.NewClient(apiClient.rmb_redis_url)
}
if err != nil {
return nil, diag.FromErr(errors.Wrap(err, "couldn't create rmb client"))
Expand Down
5 changes: 3 additions & 2 deletions internal/provider/resource_k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/pkg/errors"
"github.com/threefoldtech/substrate-client"
client "github.com/threefoldtech/terraform-provider-grid/internal/node"
"github.com/threefoldtech/terraform-provider-grid/pkg/deployer"
"github.com/threefoldtech/terraform-provider-grid/pkg/state"
Expand Down Expand Up @@ -414,7 +415,7 @@ func (k *K8sDeployer) invalidateBrokenAttributes(sub subi.SubstrateExt) error {
validNodes := make(map[uint32]struct{})
for node, contractID := range k.NodeDeploymentID {
contract, err := sub.GetContract(contractID)
if (err == nil && !contract.IsCreated()) || errors.Is(err, subi.ErrNotFound) {
if (err == nil && !contract.State.IsCreated) || errors.Is(err, substrate.ErrNotFound) {
delete(k.NodeDeploymentID, node)
delete(k.NodesIPRange, node)
} else if err != nil {
Expand Down Expand Up @@ -805,7 +806,7 @@ func (k *K8sDeployer) removeDeletedContracts(ctx context.Context, sub subi.Subst
if err != nil {
return errors.Wrap(err, "failed to get deployments")
}
if !cont.IsDeleted() {
if !cont.State.IsDeleted {
nodeDeploymentID[nodeID] = deploymentID
}
}
Expand Down
3 changes: 2 additions & 1 deletion internal/provider/resource_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/pkg/errors"
"github.com/threefoldtech/substrate-client"
client "github.com/threefoldtech/terraform-provider-grid/internal/node"
"github.com/threefoldtech/terraform-provider-grid/pkg/deployer"
"github.com/threefoldtech/terraform-provider-grid/pkg/state"
Expand Down Expand Up @@ -221,7 +222,7 @@ func (k *NetworkDeployer) invalidateBrokenAttributes(sub subi.SubstrateExt) erro

for node, contractID := range k.NodeDeploymentID {
contract, err := sub.GetContract(contractID)
if (err == nil && !contract.IsCreated()) || errors.Is(err, subi.ErrNotFound) {
if (err == nil && !contract.State.IsCreated) || errors.Is(err, substrate.ErrNotFound) {
delete(k.NodeDeploymentID, node)
delete(k.NodesIPRange, node)
delete(k.Keys, node)
Expand Down
Loading

0 comments on commit bff3cac

Please sign in to comment.