Skip to content

Commit

Permalink
revert subdomain feature
Browse files Browse the repository at this point in the history
  • Loading branch information
rawdaGastan committed Jun 13, 2024
1 parent 85c621c commit 42a4d1f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 31 deletions.
6 changes: 1 addition & 5 deletions grid-cli/internal/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"fmt"
"net"
"strings"

"github.com/pkg/errors"
"github.com/rs/zerolog/log"
Expand Down Expand Up @@ -110,10 +109,7 @@ func DeployGatewayName(ctx context.Context, t deployer.TFPluginClient, gateway w
return workloads.GatewayNameProxy{}, errors.Wrapf(err, "failed to deploy gateway on node %d", gateway.NodeID)
}

subdomains := strings.Split(gateway.Name, ".")
contractName := subdomains[len(subdomains)-1]

return t.State.LoadGatewayNameFromGrid(ctx, gateway.NodeID, contractName, strings.ReplaceAll(gateway.Name, ".", "_"))
return t.State.LoadGatewayNameFromGrid(ctx, gateway.NodeID, gateway.Name, gateway.Name)
}

// DeployGatewayFQDN deploys a gateway fqdn
Expand Down
25 changes: 3 additions & 22 deletions grid-client/deployer/gateway_name_deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ package deployer
import (
"context"
"fmt"
"strings"

"github.com/pkg/errors"
substrate "github.com/threefoldtech/tfchain/clients/tfchain-client-go"
client "github.com/threefoldtech/tfgrid-sdk-go/grid-client/node"
"github.com/threefoldtech/tfgrid-sdk-go/grid-client/workloads"
"github.com/threefoldtech/zos/pkg/gridtypes"
Expand Down Expand Up @@ -73,26 +71,9 @@ func (d *GatewayNameDeployer) Deploy(ctx context.Context, gw *workloads.GatewayN
}

if gw.NameContractID == 0 {
createNameContract := true

subdomains := strings.Split(gw.Name, ".")
contractName := subdomains[len(subdomains)-1]

if len(subdomains) >= 2 { // if we have a given subdomain of the name (subdomain.name) check if the name exists
contractID, err := d.tfPluginClient.SubstrateConn.GetContractIDByNameRegistration(contractName)
if err != nil && err != substrate.ErrNotFound {
return err
}
if contractID > 0 {
createNameContract = false
}
}

if createNameContract {
gw.NameContractID, err = d.tfPluginClient.SubstrateConn.CreateNameContract(d.tfPluginClient.Identity, contractName)
if err != nil {
return err
}
gw.NameContractID, err = d.tfPluginClient.SubstrateConn.CreateNameContract(d.tfPluginClient.Identity, gw.Name)
if err != nil {
return err
}
}

Expand Down
7 changes: 3 additions & 4 deletions grid-client/workloads/gateway_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package workloads

import (
"encoding/json"
"strings"

"github.com/pkg/errors"
"github.com/threefoldtech/zos/pkg/gridtypes"
Expand Down Expand Up @@ -76,7 +75,7 @@ func (g *GatewayNameProxy) ZosWorkload() gridtypes.Workload {
return gridtypes.Workload{
Version: 0,
Type: zos.GatewayNameProxyType,
Name: gridtypes.Name(strings.ReplaceAll(g.Name, ".", "_")),
Name: gridtypes.Name(g.Name),
// REVISE: whether description should be set here
Data: gridtypes.MustMarshal(zos.GatewayNameProxy{
GatewayBase: zos.GatewayBase{
Expand All @@ -92,12 +91,12 @@ func (g *GatewayNameProxy) ZosWorkload() gridtypes.Workload {
// GenerateMetadata generates gateway deployment metadata
func (g *GatewayNameProxy) GenerateMetadata() (string, error) {
if len(g.SolutionType) == 0 {
g.SolutionType = strings.ReplaceAll(g.Name, ".", "_")
g.SolutionType = g.Name
}

deploymentData := DeploymentData{
Version: Version,
Name: strings.ReplaceAll(g.Name, ".", "_"),
Name: g.Name,
Type: "Gateway Name",
ProjectName: g.SolutionType,
}
Expand Down

0 comments on commit 42a4d1f

Please sign in to comment.