Skip to content

Commit

Permalink
Merge pull request #4 from ava-labs/node-init
Browse files Browse the repository at this point in the history
node init
  • Loading branch information
arturrez authored May 28, 2024
2 parents 2da2a9a + 41739ee commit 4029c91
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 0 deletions.
56 changes: 56 additions & 0 deletions node/cloud.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (C) 2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package node

type CloudParams struct {
CommonParams
AWSParams
GCPParams
}

type CommonParams struct {
// Region to use for the node
Region string

// Image to use for the node
Image string

// Instance type to use for the node
InstanceType string

// Static IP to use for the node
StaticIP string
}

// AWS Paramsific configuration
type AWSParams struct {
// AWS profile to use for the node
Profile string

// AWS volume size in GB
VolumeSize int

// AWS volume type
VolumeType string

// AWS volume IOPS
VolumeIOPS int

// AWS volume throughput
VolumeThroughput int

// AWS security group to use for the node
SecurityGroup string
}

type GCPParams struct {
// GCP project to use for the node
Project string

// GCP credentials to use for the node
Credentials string

// GCP network label to use for the node
Network string
}
10 changes: 10 additions & 0 deletions node/create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (C) 2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package node

// Create creates a new node.
// If wait is true, this function will block until the node is ready.
func Create(CloudParams CloudParams, waitForSSH bool) (Node, error) {

Check failure on line 8 in node/create.go

View workflow job for this annotation

GitHub Actions / Lint

captLocal: `CloudParams' should not be capitalized (gocritic)
return Node{}, nil
}
9 changes: 9 additions & 0 deletions node/destroy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (C) 2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package node

// Destroy destroys a node.
func Destroy(node Node) error {

Check warning on line 7 in node/destroy.go

View workflow job for this annotation

GitHub Actions / Lint

unused-parameter: parameter 'node' seems to be unused, consider removing or renaming it as _ (revive)
return nil
}
9 changes: 9 additions & 0 deletions node/exec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (C) 2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package node

// Exec executes a command on a node.
func Exec(node Node, cmd string) error {

Check warning on line 7 in node/exec.go

View workflow job for this annotation

GitHub Actions / Lint

unused-parameter: parameter 'node' seems to be unused, consider removing or renaming it as _ (revive)
return nil
}
16 changes: 16 additions & 0 deletions node/net.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (C) 2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package node

import "net"

// Connect returns the connection to the node.
func Connect(node Node) (*net.Conn, error) {

Check warning on line 9 in node/net.go

View workflow job for this annotation

GitHub Actions / Lint

unused-parameter: parameter 'node' seems to be unused, consider removing or renaming it as _ (revive)
return nil, nil
}

// Post sends a POST request to the node at the specified path with the provided body.
func Post(node Node, path string, body string) error {

Check warning on line 14 in node/net.go

View workflow job for this annotation

GitHub Actions / Lint

unused-parameter: parameter 'node' seems to be unused, consider removing or renaming it as _ (revive)
return nil
}
39 changes: 39 additions & 0 deletions node/node.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (C) 2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package node

// SSHConfig contains the configuration for connecting to a node over SSH
type SSHConfig struct {
// Username to use when connecting to the node
user string

Check failure on line 9 in node/node.go

View workflow job for this annotation

GitHub Actions / Lint

field `user` is unused (unused)

// Path to the private key to use when connecting to the node
// If this is empty, the SSH agent will be used
KeyPath string

// Parameters to pass to the ssh command.
// See man ssh_config(5) for more information
// By defalult it's StrictHostKeyChecking=no
Params map[string]string // additional parameters to pass to the ssh command
}

type Node struct {
// ID of the node
ID string

// IP address of the node
IP string

// SSH configuration for the node
SSHConfig SSHConfig

// Cloud configuration for the node
Cloud SupportedCloud

// CloudConfig is the cloud specific configuration for the node
CloudConfig interface{}

// Roles of the node
Roles []SupportedRole
}
22 changes: 22 additions & 0 deletions node/supported.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (C) 2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package node

type SupportedCloud int

const (
AWSCloud SupportedCloud = iota
GCPCloud
Docker // fake Cloud used for E2E tests
)

type SupportedRole int

const (
Validator SupportedRole = iota
API
AWMRelayer
)

// LoadTest and Monitor nodes are not supported yet

0 comments on commit 4029c91

Please sign in to comment.