49 lines
1.0 KiB
Go
49 lines
1.0 KiB
Go
|
package bootstrap
|
||
|
|
||
|
import (
|
||
|
"cryptic-net/garage"
|
||
|
)
|
||
|
|
||
|
// Paths within the bootstrap FS related to garage.
|
||
|
const (
|
||
|
GarageGlobalBucketKeyYmlPath = "garage/global-bucket-key.yml"
|
||
|
GarageRPCSecretPath = "garage/rpc-secret.txt"
|
||
|
GarageHostsDirPath = "garage/hosts"
|
||
|
)
|
||
|
|
||
|
// GaragePeers returns a Peer for each known garage instance in the network.
|
||
|
func (b Bootstrap) GaragePeers() []garage.Peer {
|
||
|
|
||
|
var peers []garage.Peer
|
||
|
|
||
|
for _, host := range b.Hosts {
|
||
|
|
||
|
if host.Garage == nil {
|
||
|
continue
|
||
|
}
|
||
|
|
||
|
for _, instance := range host.Garage.Instances {
|
||
|
|
||
|
peer := garage.Peer{
|
||
|
IP: host.Nebula.IP,
|
||
|
RPCPort: instance.RPCPort,
|
||
|
S3APIPort: instance.S3APIPort,
|
||
|
}
|
||
|
|
||
|
peers = append(peers, peer)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return peers
|
||
|
}
|
||
|
|
||
|
// GarageRPCPeerAddrs returns the full RPC peer address for each known garage
|
||
|
// instance in the network.
|
||
|
func (b Bootstrap) GarageRPCPeerAddrs() []string {
|
||
|
var addrs []string
|
||
|
for _, peer := range b.GaragePeers() {
|
||
|
addrs = append(addrs, peer.RPCPeerAddr())
|
||
|
}
|
||
|
return addrs
|
||
|
}
|