2014-03-23 11:06:43 -07:00
|
|
|
package initialize
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"path"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/coreos/coreos-cloudinit/system"
|
|
|
|
)
|
|
|
|
|
|
|
|
type OEMRelease struct {
|
|
|
|
ID string `yaml:"id"`
|
|
|
|
Name string `yaml:"name"`
|
|
|
|
VersionID string `yaml:"version-id"`
|
|
|
|
HomeURL string `yaml:"home-url"`
|
|
|
|
BugReportURL string `yaml:"bug-report-url"`
|
|
|
|
}
|
|
|
|
|
2014-05-09 20:33:34 -07:00
|
|
|
func (oem OEMRelease) String() string {
|
2014-03-23 11:06:43 -07:00
|
|
|
fields := []string{
|
2014-04-07 09:56:57 -07:00
|
|
|
fmt.Sprintf("ID=%s", oem.ID),
|
|
|
|
fmt.Sprintf("VERSION_ID=%s", oem.VersionID),
|
2014-03-23 11:06:43 -07:00
|
|
|
fmt.Sprintf("NAME=%q", oem.Name),
|
|
|
|
fmt.Sprintf("HOME_URL=%q", oem.HomeURL),
|
|
|
|
fmt.Sprintf("BUG_REPORT_URL=%q", oem.BugReportURL),
|
|
|
|
}
|
|
|
|
|
|
|
|
return strings.Join(fields, "\n") + "\n"
|
|
|
|
}
|
|
|
|
|
2014-05-09 20:33:34 -07:00
|
|
|
func (oem OEMRelease) File(root string) (*system.File, error) {
|
|
|
|
if oem.ID == "" {
|
|
|
|
return nil, nil
|
2014-03-23 11:06:43 -07:00
|
|
|
}
|
|
|
|
|
2014-05-09 20:33:34 -07:00
|
|
|
return &system.File{
|
|
|
|
Path: path.Join("etc", "oem-release"),
|
|
|
|
RawFilePermissions: "0644",
|
|
|
|
Content: oem.String(),
|
|
|
|
}, nil
|
2014-03-23 11:06:43 -07:00
|
|
|
}
|