35 lines
761 B
Go
35 lines
761 B
Go
package cloudinit
|
|
|
|
import (
|
|
"os"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
type UserData struct {
|
|
Hostname string `yaml:"hostname"`
|
|
ManageEtcHosts bool `yaml:"manage_etc_hosts"`
|
|
FQDN string `yaml:"fqdn"`
|
|
User string `yaml:"user"`
|
|
Password string `yaml:"password"`
|
|
Chpasswd Chpasswd `yaml:"chpasswd"`
|
|
Users []string `yaml:"users"`
|
|
PackageUpgrade bool `yaml:"package_upgrade"`
|
|
}
|
|
type Chpasswd struct {
|
|
Expire bool `yaml:"expire"`
|
|
}
|
|
|
|
func (u *UserData) Load(cloudInitDrive string) error {
|
|
data, err := os.ReadFile(cloudInitDrive + "USER_DATA")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Unmarshal the YAML data into the Config struct
|
|
err = yaml.Unmarshal(data, &u)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|