mirror of
https://github.com/rancher/os.git
synced 2025-09-02 15:24:32 +00:00
make golang files to pass the latest go lints
- use constructors with named fields - fix logf statements
This commit is contained in:
committed by
Olli Janatuinen
parent
6fd46ddee4
commit
6cde287f87
@@ -146,7 +146,7 @@ func installAction(c *cli.Context) error {
|
|||||||
partition := c.String("partition")
|
partition := c.String("partition")
|
||||||
statedir := c.String("statedir")
|
statedir := c.String("statedir")
|
||||||
if statedir != "" && installType != "noformat" {
|
if statedir != "" && installType != "noformat" {
|
||||||
log.Fatal("--statedir %s requires --type noformat", statedir)
|
log.Fatalf("--statedir %s requires --type noformat", statedir)
|
||||||
}
|
}
|
||||||
if installType != "noformat" &&
|
if installType != "noformat" &&
|
||||||
installType != "raid" &&
|
installType != "raid" &&
|
||||||
@@ -531,7 +531,7 @@ func layDownOS(image, installType, cloudConfig, device, partition, statedir, kap
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Debugf("upgrading - %s, %s, %s, %s", device, baseName, diskType)
|
log.Debugf("upgrading - %s, %s, %s", device, baseName, diskType)
|
||||||
// TODO: detect pv-grub, and don't kill it with syslinux
|
// TODO: detect pv-grub, and don't kill it with syslinux
|
||||||
upgradeBootloader(device, baseName, diskType)
|
upgradeBootloader(device, baseName, diskType)
|
||||||
default:
|
default:
|
||||||
@@ -553,7 +553,13 @@ func layDownOS(image, installType, cloudConfig, device, partition, statedir, kap
|
|||||||
Timeout: 0,
|
Timeout: 0,
|
||||||
Fallback: 0, // need to be conditional on there being a 'rollback'?
|
Fallback: 0, // need to be conditional on there being a 'rollback'?
|
||||||
Entries: []install.MenuEntry{
|
Entries: []install.MenuEntry{
|
||||||
install.MenuEntry{"BurmillaOS-current", config.BootDir, VERSION, kernelArgs, kappend},
|
install.MenuEntry{
|
||||||
|
Name: "BurmillaOS-current",
|
||||||
|
BootDir: config.BootDir,
|
||||||
|
Version: VERSION,
|
||||||
|
KernelArgs: kernelArgs,
|
||||||
|
Append: kappend,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
install.PvGrubConfig(menu)
|
install.PvGrubConfig(menu)
|
||||||
|
@@ -43,29 +43,29 @@ func MainInit() {
|
|||||||
|
|
||||||
func RunInit() error {
|
func RunInit() error {
|
||||||
initFuncs := config.CfgFuncs{
|
initFuncs := config.CfgFuncs{
|
||||||
{"set env", env.Init},
|
{Name: "set env", Func: env.Init},
|
||||||
{"preparefs", prepare.FS},
|
{Name: "preparefs", Func: prepare.FS},
|
||||||
{"save init cmdline", prepare.SaveCmdline},
|
{Name: "save init cmdline", Func: prepare.SaveCmdline},
|
||||||
{"mount OEM", fsmount.MountOem},
|
{Name: "mount OEM", Func: fsmount.MountOem},
|
||||||
{"debug save cfg", debug.PrintAndLoadConfig},
|
{Name: "debug save cfg", Func: debug.PrintAndLoadConfig},
|
||||||
{"load modules", modules.LoadModules},
|
{Name: "load modules", Func: modules.LoadModules},
|
||||||
{"recovery console", recovery.LoadRecoveryConsole},
|
{Name: "recovery console", Func: recovery.LoadRecoveryConsole},
|
||||||
{"b2d env", b2d.B2D},
|
{Name: "b2d env", Func: b2d.B2D},
|
||||||
{"mount STATE and bootstrap", fsmount.MountStateAndBootstrap},
|
{Name: "mount STATE and bootstrap", Func: fsmount.MountStateAndBootstrap},
|
||||||
{"cloud-init", cloudinit.CloudInit},
|
{Name: "cloud-init", Func: cloudinit.CloudInit},
|
||||||
{"read cfg and log files", configfiles.ReadConfigFiles},
|
{Name: "read cfg and log files", Func: configfiles.ReadConfigFiles},
|
||||||
{"switchroot", switchroot.SwitchRoot},
|
{Name: "switchroot", Func: switchroot.SwitchRoot},
|
||||||
{"mount OEM2", fsmount.MountOem},
|
{Name: "mount OEM2", Func: fsmount.MountOem},
|
||||||
{"mount BOOT", fsmount.MountBoot},
|
{Name: "mount BOOT", Func: fsmount.MountBoot},
|
||||||
{"write cfg and log files", configfiles.WriteConfigFiles},
|
{Name: "write cfg and log files", Func: configfiles.WriteConfigFiles},
|
||||||
{"b2d Env", b2d.Env},
|
{Name: "b2d Env", Func: b2d.Env},
|
||||||
{"hypervisor tools", hypervisor.Tools},
|
{Name: "hypervisor tools", Func: hypervisor.Tools},
|
||||||
{"preparefs2", prepare.FS},
|
{Name: "preparefs2", Func: prepare.FS},
|
||||||
{"load modules2", modules.LoadModules},
|
{Name: "load modules2", Func: modules.LoadModules},
|
||||||
{"set proxy env", env.Proxy},
|
{Name: "set proxy env", Func: env.Proxy},
|
||||||
{"init SELinux", selinux.Initialize},
|
{Name: "init SELinux", Func: selinux.Initialize},
|
||||||
{"setupSharedRoot", sharedroot.Setup},
|
{Name: "setupSharedRoot", Func: sharedroot.Setup},
|
||||||
{"sysinit", sysinit.RunSysInit},
|
{Name: "sysinit", Func: sysinit.RunSysInit},
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg, err := config.ChainCfgFuncs(nil, initFuncs)
|
cfg, err := config.ChainCfgFuncs(nil, initFuncs)
|
||||||
|
@@ -32,7 +32,7 @@ func (t *HTTPClient) GetRetry(url string) ([]byte, error) {
|
|||||||
if val, ok := t.Resources[url]; ok {
|
if val, ok := t.Resources[url]; ok {
|
||||||
return []byte(val), nil
|
return []byte(val), nil
|
||||||
}
|
}
|
||||||
return nil, pkg.ErrNotFound{fmt.Errorf("not found: %q", url)}
|
return nil, pkg.ErrNotFound{Err: fmt.Errorf("not found: %q", url)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *HTTPClient) Get(url string) ([]byte, error) {
|
func (t *HTTPClient) Get(url string) ([]byte, error) {
|
||||||
|
@@ -32,8 +32,8 @@ func Bootstrap(cfg *config.CloudConfig) error {
|
|||||||
|
|
||||||
_, err = config.ChainCfgFuncs(cfg,
|
_, err = config.ChainCfgFuncs(cfg,
|
||||||
[]config.CfgFuncData{
|
[]config.CfgFuncData{
|
||||||
{"bootstrap loadImages", sysinit.LoadBootstrapImages},
|
{Name: "bootstrap loadImages", Func: sysinit.LoadBootstrapImages},
|
||||||
{"bootstrap Services", bootstrapServices},
|
{Name: "bootstrap Services", Func: bootstrapServices},
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@@ -113,8 +113,8 @@ func runCloudInitServices(cfg *config.CloudConfig) error {
|
|||||||
|
|
||||||
_, err = config.ChainCfgFuncs(cfg,
|
_, err = config.ChainCfgFuncs(cfg,
|
||||||
[]config.CfgFuncData{
|
[]config.CfgFuncData{
|
||||||
{"cloudinit loadImages", sysinit.LoadBootstrapImages},
|
{Name: "cloudinit loadImages", Func: sysinit.LoadBootstrapImages},
|
||||||
{"cloudinit Services", runCloudInitServiceSet},
|
{Name: "cloudinit Services", Func: runCloudInitServiceSet},
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@@ -89,8 +89,8 @@ func Recovery(initFailure error) {
|
|||||||
|
|
||||||
_, err = config.ChainCfgFuncs(&recoveryConfig,
|
_, err = config.ChainCfgFuncs(&recoveryConfig,
|
||||||
[]config.CfgFuncData{
|
[]config.CfgFuncData{
|
||||||
{"loadSystemImages", sysinit.LoadBootstrapImages},
|
{Name: "loadSystemImages", Func: sysinit.LoadBootstrapImages},
|
||||||
{"recovery console", recoveryServices},
|
{Name: "recovery console", Func: recoveryServices},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
@@ -92,7 +92,7 @@ func getPseudoRandomGenerator(haAddr []byte) (*rand.Source, error) {
|
|||||||
func getLinkAddrs(link netlink.Link) ([]netlink.Addr, error) {
|
func getLinkAddrs(link netlink.Link) ([]netlink.Addr, error) {
|
||||||
addrs, err := netlink.AddrList(link, nl.FAMILY_ALL)
|
addrs, err := netlink.AddrList(link, nl.FAMILY_ALL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error fetching existing ip on interface, %s", err)
|
log.Errorf("Error fetching existing ip on interface, %s", err)
|
||||||
err = nil // atm, we ignore this, as the link may not have one?
|
err = nil // atm, we ignore this, as the link may not have one?
|
||||||
}
|
}
|
||||||
return addrs, err
|
return addrs, err
|
||||||
|
@@ -101,8 +101,8 @@ func SysInit() error {
|
|||||||
|
|
||||||
_, err := config.ChainCfgFuncs(cfg,
|
_, err := config.ChainCfgFuncs(cfg,
|
||||||
config.CfgFuncs{
|
config.CfgFuncs{
|
||||||
{"loadSystemImages", LoadSystemImages},
|
{Name: "loadSystemImages", Func: LoadSystemImages},
|
||||||
{"start project", func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
{Name: "start project", Func: func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||||
p, err := compose.GetProject(cfg, false, true)
|
p, err := compose.GetProject(cfg, false, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cfg, err
|
return cfg, err
|
||||||
@@ -114,11 +114,11 @@ func SysInit() error {
|
|||||||
Log: cfg.Rancher.Log,
|
Log: cfg.Rancher.Log,
|
||||||
})
|
})
|
||||||
}},
|
}},
|
||||||
{"sync", func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
{Name: "sync", Func: func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||||
syscall.Sync()
|
syscall.Sync()
|
||||||
return cfg, nil
|
return cfg, nil
|
||||||
}},
|
}},
|
||||||
{"banner", func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
{Name: "banner", Func: func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||||
log.Infof("BurmillaOS %s started", config.Version)
|
log.Infof("BurmillaOS %s started", config.Version)
|
||||||
return cfg, nil
|
return cfg, nil
|
||||||
}}})
|
}}})
|
||||||
|
Reference in New Issue
Block a user