mirror of
https://github.com/tendermint/tendermint.git
synced 2026-04-28 19:36:57 +00:00
implement read ifd from file
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
)
|
||||
|
||||
// InfrastructureData contains the relevant information for a set of existing
|
||||
@@ -42,3 +44,13 @@ func NewDockerInfrastructureData(m Manifest) (InfrastructureData, error) {
|
||||
}
|
||||
return ifd, nil
|
||||
}
|
||||
|
||||
func InfrastructureDataFromFile(p string) (InfrastructureData, error) {
|
||||
ifd := InfrastructureData{}
|
||||
b, err := os.ReadFile(p)
|
||||
err = json.Unmarshal(b, &ifd)
|
||||
if err != nil {
|
||||
return InfrastructureData{}, err
|
||||
}
|
||||
return ifd, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
@@ -59,6 +60,15 @@ func NewCLI() *CLI {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case "digital-ocean":
|
||||
p, err := cmd.Flags().GetString("infrastructure-data")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if p == "" {
|
||||
return errors.New("'--infrastructure-data' must be set when using the 'digital-ocean' infrastructure-type")
|
||||
}
|
||||
ifd, err = e2e.InfrastructureDataFromFile(p)
|
||||
// TODO(williambanfield): add a section that implements the 'digital-ocean' infrastructure-type
|
||||
default:
|
||||
return fmt.Errorf("unknown infrastructure type '%s'", t)
|
||||
|
||||
Reference in New Issue
Block a user