2022-11-02 13:02:21 +00:00
|
|
|
// Package admin deals with the parsing and creation of admin.yml files.
|
2022-10-16 14:39:05 +00:00
|
|
|
package admin
|
|
|
|
|
|
|
|
import (
|
2023-08-05 21:53:17 +00:00
|
|
|
"isle/garage"
|
|
|
|
"isle/nebula"
|
2022-10-16 14:39:05 +00:00
|
|
|
"io"
|
|
|
|
|
|
|
|
"gopkg.in/yaml.v3"
|
|
|
|
)
|
|
|
|
|
2022-10-16 15:05:05 +00:00
|
|
|
// CreationParams are general parameters used when creating a new network. These
|
|
|
|
// are available to all hosts within the network via their bootstrap files.
|
|
|
|
type CreationParams struct {
|
2022-10-16 20:17:26 +00:00
|
|
|
ID string `yaml:"id"`
|
2022-11-05 11:34:49 +00:00
|
|
|
Name string `yaml:"name"`
|
2022-10-16 20:17:26 +00:00
|
|
|
Domain string `yaml:"domain"`
|
2022-10-16 15:05:05 +00:00
|
|
|
}
|
|
|
|
|
2022-11-02 13:02:21 +00:00
|
|
|
// Admin is used for accessing all information contained within an admin.yml.
|
2022-10-16 14:39:05 +00:00
|
|
|
type Admin struct {
|
2022-11-02 13:02:21 +00:00
|
|
|
CreationParams CreationParams `yaml:"creation_params"`
|
2022-10-16 14:39:05 +00:00
|
|
|
|
2022-11-02 13:02:21 +00:00
|
|
|
Nebula struct {
|
|
|
|
CACredentials nebula.CACredentials `yaml:"ca_credentials"`
|
|
|
|
} `yaml:"nebula"`
|
2022-10-16 14:39:05 +00:00
|
|
|
|
2022-11-02 13:02:21 +00:00
|
|
|
Garage struct {
|
|
|
|
RPCSecret string `yaml:"rpc_secret"`
|
|
|
|
GlobalBucketS3APICredentials garage.S3APICredentials `yaml:"global_bucket_s3_api_credentials"`
|
|
|
|
} `yaml:"garage"`
|
2022-10-16 14:39:05 +00:00
|
|
|
}
|
|
|
|
|
2022-11-02 13:02:21 +00:00
|
|
|
// FromReader reads an admin.yml from the given io.Reader.
|
2022-10-16 14:39:05 +00:00
|
|
|
func FromReader(r io.Reader) (Admin, error) {
|
2022-11-02 13:02:21 +00:00
|
|
|
var a Admin
|
|
|
|
err := yaml.NewDecoder(r).Decode(&a)
|
|
|
|
return a, err
|
2022-10-16 14:39:05 +00:00
|
|
|
}
|
|
|
|
|
2022-11-02 13:02:21 +00:00
|
|
|
// WriteTo writes the Admin as an admin.yml to the given io.Writer.
|
2022-10-16 14:39:05 +00:00
|
|
|
func (a Admin) WriteTo(into io.Writer) error {
|
2022-11-02 13:02:21 +00:00
|
|
|
return yaml.NewEncoder(into).Encode(a)
|
2022-10-16 14:39:05 +00:00
|
|
|
}
|