1
0
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:
Lonnie Liu
2021-02-15 09:13:14 -08:00
committed by Olli Janatuinen
parent 6fd46ddee4
commit 6cde287f87
8 changed files with 44 additions and 38 deletions

View File

@@ -146,7 +146,7 @@ func installAction(c *cli.Context) error {
partition := c.String("partition")
statedir := c.String("statedir")
if statedir != "" && installType != "noformat" {
log.Fatal("--statedir %s requires --type noformat", statedir)
log.Fatalf("--statedir %s requires --type noformat", statedir)
}
if installType != "noformat" &&
installType != "raid" &&
@@ -531,7 +531,7 @@ func layDownOS(image, installType, cloudConfig, device, partition, statedir, kap
if err != nil {
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
upgradeBootloader(device, baseName, diskType)
default:
@@ -553,7 +553,13 @@ func layDownOS(image, installType, cloudConfig, device, partition, statedir, kap
Timeout: 0,
Fallback: 0, // need to be conditional on there being a 'rollback'?
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)

View File

@@ -43,29 +43,29 @@ func MainInit() {
func RunInit() error {
initFuncs := config.CfgFuncs{
{"set env", env.Init},
{"preparefs", prepare.FS},
{"save init cmdline", prepare.SaveCmdline},
{"mount OEM", fsmount.MountOem},
{"debug save cfg", debug.PrintAndLoadConfig},
{"load modules", modules.LoadModules},
{"recovery console", recovery.LoadRecoveryConsole},
{"b2d env", b2d.B2D},
{"mount STATE and bootstrap", fsmount.MountStateAndBootstrap},
{"cloud-init", cloudinit.CloudInit},
{"read cfg and log files", configfiles.ReadConfigFiles},
{"switchroot", switchroot.SwitchRoot},
{"mount OEM2", fsmount.MountOem},
{"mount BOOT", fsmount.MountBoot},
{"write cfg and log files", configfiles.WriteConfigFiles},
{"b2d Env", b2d.Env},
{"hypervisor tools", hypervisor.Tools},
{"preparefs2", prepare.FS},
{"load modules2", modules.LoadModules},
{"set proxy env", env.Proxy},
{"init SELinux", selinux.Initialize},
{"setupSharedRoot", sharedroot.Setup},
{"sysinit", sysinit.RunSysInit},
{Name: "set env", Func: env.Init},
{Name: "preparefs", Func: prepare.FS},
{Name: "save init cmdline", Func: prepare.SaveCmdline},
{Name: "mount OEM", Func: fsmount.MountOem},
{Name: "debug save cfg", Func: debug.PrintAndLoadConfig},
{Name: "load modules", Func: modules.LoadModules},
{Name: "recovery console", Func: recovery.LoadRecoveryConsole},
{Name: "b2d env", Func: b2d.B2D},
{Name: "mount STATE and bootstrap", Func: fsmount.MountStateAndBootstrap},
{Name: "cloud-init", Func: cloudinit.CloudInit},
{Name: "read cfg and log files", Func: configfiles.ReadConfigFiles},
{Name: "switchroot", Func: switchroot.SwitchRoot},
{Name: "mount OEM2", Func: fsmount.MountOem},
{Name: "mount BOOT", Func: fsmount.MountBoot},
{Name: "write cfg and log files", Func: configfiles.WriteConfigFiles},
{Name: "b2d Env", Func: b2d.Env},
{Name: "hypervisor tools", Func: hypervisor.Tools},
{Name: "preparefs2", Func: prepare.FS},
{Name: "load modules2", Func: modules.LoadModules},
{Name: "set proxy env", Func: env.Proxy},
{Name: "init SELinux", Func: selinux.Initialize},
{Name: "setupSharedRoot", Func: sharedroot.Setup},
{Name: "sysinit", Func: sysinit.RunSysInit},
}
cfg, err := config.ChainCfgFuncs(nil, initFuncs)

View File

@@ -32,7 +32,7 @@ func (t *HTTPClient) GetRetry(url string) ([]byte, error) {
if val, ok := t.Resources[url]; ok {
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) {

View File

@@ -32,8 +32,8 @@ func Bootstrap(cfg *config.CloudConfig) error {
_, err = config.ChainCfgFuncs(cfg,
[]config.CfgFuncData{
{"bootstrap loadImages", sysinit.LoadBootstrapImages},
{"bootstrap Services", bootstrapServices},
{Name: "bootstrap loadImages", Func: sysinit.LoadBootstrapImages},
{Name: "bootstrap Services", Func: bootstrapServices},
})
return err
}

View File

@@ -113,8 +113,8 @@ func runCloudInitServices(cfg *config.CloudConfig) error {
_, err = config.ChainCfgFuncs(cfg,
[]config.CfgFuncData{
{"cloudinit loadImages", sysinit.LoadBootstrapImages},
{"cloudinit Services", runCloudInitServiceSet},
{Name: "cloudinit loadImages", Func: sysinit.LoadBootstrapImages},
{Name: "cloudinit Services", Func: runCloudInitServiceSet},
})
return err
}

View File

@@ -89,8 +89,8 @@ func Recovery(initFailure error) {
_, err = config.ChainCfgFuncs(&recoveryConfig,
[]config.CfgFuncData{
{"loadSystemImages", sysinit.LoadBootstrapImages},
{"recovery console", recoveryServices},
{Name: "loadSystemImages", Func: sysinit.LoadBootstrapImages},
{Name: "recovery console", Func: recoveryServices},
})
if err != nil {
log.Fatal(err)

View File

@@ -92,7 +92,7 @@ func getPseudoRandomGenerator(haAddr []byte) (*rand.Source, error) {
func getLinkAddrs(link netlink.Link) ([]netlink.Addr, error) {
addrs, err := netlink.AddrList(link, nl.FAMILY_ALL)
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?
}
return addrs, err

View File

@@ -101,8 +101,8 @@ func SysInit() error {
_, err := config.ChainCfgFuncs(cfg,
config.CfgFuncs{
{"loadSystemImages", LoadSystemImages},
{"start project", func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
{Name: "loadSystemImages", Func: LoadSystemImages},
{Name: "start project", Func: func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
p, err := compose.GetProject(cfg, false, true)
if err != nil {
return cfg, err
@@ -114,11 +114,11 @@ func SysInit() error {
Log: cfg.Rancher.Log,
})
}},
{"sync", func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
{Name: "sync", Func: func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
syscall.Sync()
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)
return cfg, nil
}}})