// Package admin deals with the parsing and creation of admin.yml files. package admin import ( "isle/garage" "isle/nebula" "io" "gopkg.in/yaml.v3" ) // 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 { ID string `yaml:"id"` Name string `yaml:"name"` Domain string `yaml:"domain"` } // Admin is used for accessing all information contained within an admin.yml. type Admin struct { CreationParams CreationParams `yaml:"creation_params"` Nebula struct { CACredentials nebula.CACredentials `yaml:"ca_credentials"` } `yaml:"nebula"` Garage struct { RPCSecret string `yaml:"rpc_secret"` GlobalBucketS3APICredentials garage.S3APICredentials `yaml:"global_bucket_s3_api_credentials"` } `yaml:"garage"` } // FromReader reads an admin.yml from the given io.Reader. func FromReader(r io.Reader) (Admin, error) { var a Admin err := yaml.NewDecoder(r).Decode(&a) return a, err } // WriteTo writes the Admin as an admin.yml to the given io.Writer. func (a Admin) WriteTo(into io.Writer) error { return yaml.NewEncoder(into).Encode(a) }