af7c8dde32
The `bootstrap/creator` package is gone, almost as quickly as it arrived. The `Bootstrap` type is now able to write its own tgz file, and the two places where bootstrap files are being created pull the data down to do so and create the `Bootstrap` structs directly. The structure of the bootstrap file itself has been changed, now there's just a single `hosts` directory which contains files which are yaml encodings of the `Host` type, rather than having it be split into `nebula` and `garage` directories. This makes creating bootstrap files a lot easier.
48 lines
981 B
Go
48 lines
981 B
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"
|
|
)
|
|
|
|
// 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
|
|
}
|