Skip to content

Commit

Permalink
fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
sukantoraymond committed Oct 15, 2024
1 parent f22c1fd commit c44c41b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
34 changes: 34 additions & 0 deletions cmd/nodecmd/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package nodecmd
import (
"errors"
"fmt"
"github.com/ava-labs/avalanche-cli/pkg/models"

Check failure on line 8 in cmd/nodecmd/destroy.go

View workflow job for this annotation

GitHub Actions / Lint

File is not `gofumpt`-ed (gofumpt)
"os"
"strings"

Check failure on line 10 in cmd/nodecmd/destroy.go

View workflow job for this annotation

GitHub Actions / Lint

File is not `gofumpt`-ed (gofumpt)

Expand Down Expand Up @@ -324,3 +325,36 @@ func getClusterMonitoringNode(clusterName string) (string, error) {
}
return clustersConfig.Clusters[clusterName].MonitoringInstance, nil
}

func checkCluster(clusterName string) error {
_, err := getClusterNodes(clusterName)
return err
}

func checkClusterExists(clusterName string) (bool, error) {
clustersConfig := models.ClustersConfig{}
if app.ClustersConfigExists() {
var err error
clustersConfig, err = app.LoadClustersConfig()
if err != nil {
return false, err
}
}
_, ok := clustersConfig.Clusters[clusterName]
return ok, nil
}

func getClusterNodes(clusterName string) ([]string, error) {
if exists, err := checkClusterExists(clusterName); err != nil || !exists {
return nil, fmt.Errorf("cluster %q not found", clusterName)
}
clustersConfig, err := app.LoadClustersConfig()
if err != nil {
return nil, err
}
clusterNodes := clustersConfig.Clusters[clusterName].Nodes
if len(clusterNodes) == 0 {
return nil, fmt.Errorf("no nodes found in cluster %s", clusterName)
}
return clusterNodes, nil
}
8 changes: 8 additions & 0 deletions cmd/nodecmd/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,3 +559,11 @@ func notImplementedForLocal(what string) error {
ux.Logger.PrintToUser("Unsupported cmd: %s is not supported by local clusters", logging.LightBlue.Wrap(what))
return nil
}

func getRPCEndpoint(endpoint string, blockchainID string) string {
return models.NewDevnetNetwork(endpoint, 0).BlockchainEndpoint(blockchainID)
}

func getWSEndpoint(endpoint string, blockchainID string) string {
return models.NewDevnetNetwork(endpoint, 0).BlockchainWSEndpoint(blockchainID)
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22.8

require (
github.com/ava-labs/apm v1.0.0
github.com/ava-labs/avalanche-network-runner v1.8.4-0.20241014184529-5bcdd0c507ec
github.com/ava-labs/avalanche-network-runner v1.8.4-0.20241014200823-e2da066cad54
github.com/ava-labs/avalanchego v1.12.0-initial-poc.5
github.com/ava-labs/awm-relayer v1.4.1-0.20241010130039-bceba83023b8
github.com/ava-labs/coreth v0.13.8
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/ava-labs/apm v1.0.0 h1:6FwozH67hEkbWVsOXNZGexBy5KLpNeYucN9zcFUHv+Q=
github.com/ava-labs/apm v1.0.0/go.mod h1:TJL7pTlZNvQatsQPsLUtDHApEwVZ/qS7iSNtRFU83mc=
github.com/ava-labs/avalanche-network-runner v1.8.4-0.20241014184529-5bcdd0c507ec h1:SPDvCcpYkG7kVDdogbW9tDYTYTIJkAeBzU4gAm3ZhXs=
github.com/ava-labs/avalanche-network-runner v1.8.4-0.20241014184529-5bcdd0c507ec/go.mod h1:l4QzFnujbyyyeq6oBQ4F6sw9TrTQCjD2V4vUd7ZBCCo=
github.com/ava-labs/avalanche-network-runner v1.8.4-0.20241014200823-e2da066cad54 h1:Hc06tSzeuQZTacGcrVLOnZjgKg1Cs655GT1Mmp9fCsU=
github.com/ava-labs/avalanche-network-runner v1.8.4-0.20241014200823-e2da066cad54/go.mod h1:ASWB/CKJm8wVZUBp3DY0AV8jTBLCs01kzQz9GGwtzi8=
github.com/ava-labs/avalanchego v1.12.0-initial-poc.5 h1:gW4xAqZNvkA4gP8M9yDyd7YUzuwfQbbCR+hgd1ztOto=
github.com/ava-labs/avalanchego v1.12.0-initial-poc.5/go.mod h1:qSHmog3wMVjo/ruIAQo0ppXAilyni07NIu5K88RyhWE=
github.com/ava-labs/awm-relayer v1.4.1-0.20241010130039-bceba83023b8 h1:M58jcqAG51RrKKVCfhAZpPqCFdkqRzahEgkFqQA5EME=
Expand Down

0 comments on commit c44c41b

Please sign in to comment.