-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove remote cli dependency for CLI #2026
Conversation
# Conflicts: # cmd/nodecmd/wiz.go
cmd/nodecmd/wiz.go
Outdated
@@ -73,6 +73,7 @@ var ( | |||
deployTeleporterMessenger bool | |||
deployTeleporterRegistry bool | |||
replaceKeyPair bool | |||
depricatedRemoteCLIVersion string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets just delete this
} | ||
|
||
func (h *HostInstaller) GetArch() (string, string) { | ||
goArhBytes, err := h.Host.Command("go env GOARCH", nil, constants.SSHScriptTimeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can avoid depending on go binary for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point. agree
return err | ||
} | ||
if _, err := host.Command(fmt.Sprintf("/home/ubuntu/bin/avalanche subnet join %s %s --avalanchego-config /home/ubuntu/.avalanchego/configs/node.json --plugin-dir /home/ubuntu/.avalanchego/plugins --force-write", subnetName, networkFlag), nil, constants.SSHScriptTimeout); err != nil { | ||
bootstrapIDs, _ := utils.GetValueString(remoteAvagoConfFile, "bootstrap-ids") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should check for error here
return err | ||
} | ||
if _, err := host.Command(fmt.Sprintf("/home/ubuntu/bin/avalanche subnet join %s %s --avalanchego-config /home/ubuntu/.avalanchego/configs/node.json --plugin-dir /home/ubuntu/.avalanchego/plugins --force-write", subnetName, networkFlag), nil, constants.SSHScriptTimeout); err != nil { | ||
bootstrapIDs, _ := utils.GetValueString(remoteAvagoConfFile, "bootstrap-ids") | ||
bootstrapIPs, _ := utils.GetValueString(remoteAvagoConfFile, "bootstrap-ips") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
archiveFullPath := filepath.Join(tmpDir, archiveName) | ||
|
||
// download and install subnet evm | ||
if _, err := host.Command(fmt.Sprintf("%s %s -O %s", "busybox wget", installURL, archiveFullPath), nil, constants.SSHLongRunningScriptTimeout); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you have scripts for this on shell, eg upgradeSubnetEVM, pkg/ssh/shell/getNewSubnetEVMRelease.sh, why not using them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not having one .sh file for all of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it will increase size of scriptInputs
struct so I though we can get away without it as operation is straightforward
if err := host.MkdirAll(filepath.Dir(subnetConfigPath), constants.SSHDirOpsTimeout); err != nil { | ||
return err | ||
} | ||
if err := host.Upload(subnetConfigFile.Name(), subnetConfigPath, constants.SSHFileOpsTimeout); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have an upload that takes as input a slice of bytes, so we dont need to create tmp files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree. we should have another func for this
return nil, err | ||
} | ||
defer os.Remove(tmpFile.Name()) | ||
if err := host.Download(nodeJSONPath, tmpFile.Name(), constants.SSHFileOpsTimeout); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have a download that returns a byte slice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree. we should have another func for this
@@ -559,3 +559,11 @@ func Command(cmdLine string, params ...string) *exec.Cmd { | |||
c.Env = os.Environ() | |||
return c | |||
} | |||
|
|||
// GetValueString returns the value of a key in a map as a string. | |||
func GetValueString(data map[string]interface{}, key string) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we improve the name of the function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which one do you suggest ?
@@ -25,3 +25,14 @@ func ValidateJSON(path string) ([]byte, error) { | |||
|
|||
return contentBytes, nil | |||
} | |||
|
|||
// MergeJsonMaps merges two maps of type map[string]interface{} | |||
func MergeJSONMaps(a, b map[string]interface{}) map[string]interface{} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be maps.Copy be used instead of MergeJSONMaps?
sdk PR to follow
ref: ava-labs/avalanche-tooling-sdk-go#76