1
0
mirror of https://github.com/kairos-io/immucore.git synced 2025-05-06 15:18:06 +00:00

Bump lint and fix issues ()

This commit is contained in:
Itxaka 2024-03-18 14:38:57 +01:00 committed by GitHub
parent 1720e4b22f
commit 572002fb38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 20 additions and 20 deletions

View File

@ -3,7 +3,7 @@ VERSION 0.6
ARG OSBUILDER_VERSION=v0.200.7 ARG OSBUILDER_VERSION=v0.200.7
ARG OSBUILDER_IMAGE=quay.io/kairos/osbuilder-tools:$OSBUILDER_VERSION ARG OSBUILDER_IMAGE=quay.io/kairos/osbuilder-tools:$OSBUILDER_VERSION
# renovate: datasource=docker depName=golangci/golangci-lint # renovate: datasource=docker depName=golangci/golangci-lint
ARG GOLINT_VERSION=v1.55.2 ARG GOLINT_VERSION=v1.56.2
# renovate: datasource=docker depName=golang # renovate: datasource=docker depName=golang
ARG GO_VERSION=1.20-bookworm ARG GO_VERSION=1.20-bookworm

View File

@ -173,7 +173,7 @@ func GetState() string {
retry.Delay(1*time.Second), retry.Delay(1*time.Second),
retry.Attempts(10), retry.Attempts(10),
retry.DelayType(retry.FixedDelay), retry.DelayType(retry.FixedDelay),
retry.OnRetry(func(n uint, err error) { retry.OnRetry(func(n uint, _ error) {
Log.Debug().Uint("try", n).Msg("Cannot get state label, retrying") Log.Debug().Uint("try", n).Msg("Cannot get state label, retrying")
}), }),
) )

View File

@ -81,7 +81,7 @@ func main() {
{ {
Name: "version", Name: "version",
Usage: "version", Usage: "version",
Action: func(c *cli.Context) error { Action: func(_ *cli.Context) error {
utils.SetLogger() utils.SetLogger()
v := version.Get() v := version.Get()
utils.Log.Info().Str("commit", v.GitCommit).Str("compiled with", v.GoVersion).Str("version", v.Version).Msg("Immucore") utils.Log.Info().Str("commit", v.GitCommit).Str("compiled with", v.GoVersion).Str("version", v.Version).Msg("Immucore")

View File

@ -56,7 +56,7 @@ func (s *State) MountRootDagStep(g *herd.Graph) error {
err = g.Add(cnst.OpDiscoverState, err = g.Add(cnst.OpDiscoverState,
herd.WithDeps(cnst.OpMountState), herd.WithDeps(cnst.OpMountState),
herd.WithCallback( herd.WithCallback(
func(ctx context.Context) error { func(_ context.Context) error {
// Check if loop device is mounted already // Check if loop device is mounted already
if internalUtils.IsMounted(s.TargetDevice) { if internalUtils.IsMounted(s.TargetDevice) {
internalUtils.Log.Debug().Str("targetImage", s.TargetImage).Str("path", s.Rootdir).Str("TargetDevice", s.TargetDevice).Msg("Not mounting loop, already mounted") internalUtils.Log.Debug().Str("targetImage", s.TargetImage).Str("path", s.Rootdir).Str("TargetDevice", s.TargetDevice).Msg("Not mounting loop, already mounted")
@ -117,7 +117,7 @@ func (s *State) InitramfsStageDagStep(g *herd.Graph, opts ...herd.OpOption) erro
func (s *State) LoadEnvLayoutDagStep(g *herd.Graph, opts ...herd.OpOption) error { func (s *State) LoadEnvLayoutDagStep(g *herd.Graph, opts ...herd.OpOption) error {
return g.Add(cnst.OpLoadConfig, return g.Add(cnst.OpLoadConfig,
append(opts, herd.WithDeps(cnst.OpRootfsHook), append(opts, herd.WithDeps(cnst.OpRootfsHook),
herd.WithCallback(func(ctx context.Context) error { herd.WithCallback(func(_ context.Context) error {
if s.CustomMounts == nil { if s.CustomMounts == nil {
s.CustomMounts = map[string]string{} s.CustomMounts = map[string]string{}
} }
@ -210,7 +210,7 @@ func (s *State) MountBaseOverlayDagStep(g *herd.Graph, opts ...herd.OpOption) er
return g.Add(cnst.OpMountBaseOverlay, return g.Add(cnst.OpMountBaseOverlay,
append(opts, herd.WithDeps(cnst.OpLoadConfig), append(opts, herd.WithDeps(cnst.OpLoadConfig),
herd.WithCallback( herd.WithCallback(
func(ctx context.Context) error { func(_ context.Context) error {
op, err := baseOverlay(Overlay{ op, err := baseOverlay(Overlay{
Base: "/run/overlay", Base: "/run/overlay",
BackingBase: s.OverlayBase, BackingBase: s.OverlayBase,
@ -240,7 +240,7 @@ func (s *State) MountCustomOverlayDagStep(g *herd.Graph, opts ...herd.OpOption)
return g.Add(cnst.OpOverlayMount, return g.Add(cnst.OpOverlayMount,
append(opts, herd.WithDeps(cnst.OpLoadConfig, cnst.OpMountBaseOverlay), append(opts, herd.WithDeps(cnst.OpLoadConfig, cnst.OpMountBaseOverlay),
herd.WithCallback( herd.WithCallback(
func(ctx context.Context) error { func(_ context.Context) error {
var multierr *multierror.Error var multierr *multierror.Error
internalUtils.Log.Debug().Strs("dirs", s.OverlayDirs).Msg("Mounting overlays") internalUtils.Log.Debug().Strs("dirs", s.OverlayDirs).Msg("Mounting overlays")
for _, p := range s.OverlayDirs { for _, p := range s.OverlayDirs {
@ -306,7 +306,7 @@ func (s *State) MountCustomBindsDagStep(g *herd.Graph, opts ...herd.OpOption) er
return g.Add(cnst.OpMountBind, return g.Add(cnst.OpMountBind,
append(opts, herd.WithDeps(cnst.OpOverlayMount, cnst.OpCustomMounts, cnst.OpLoadConfig), append(opts, herd.WithDeps(cnst.OpOverlayMount, cnst.OpCustomMounts, cnst.OpLoadConfig),
herd.WithCallback( herd.WithCallback(
func(ctx context.Context) error { func(_ context.Context) error {
var err *multierror.Error var err *multierror.Error
internalUtils.Log.Debug().Strs("mounts", s.BindMounts).Msg("Mounting binds") internalUtils.Log.Debug().Strs("mounts", s.BindMounts).Msg("Mounting binds")
@ -346,7 +346,7 @@ func (s *State) WriteFstabDagStep(g *herd.Graph) error {
func (s *State) WriteSentinelDagStep(g *herd.Graph, deps ...string) error { func (s *State) WriteSentinelDagStep(g *herd.Graph, deps ...string) error {
return g.Add(cnst.OpSentinel, return g.Add(cnst.OpSentinel,
herd.WithDeps(deps...), herd.WithDeps(deps...),
herd.WithCallback(func(ctx context.Context) error { herd.WithCallback(func(_ context.Context) error {
var sentinel string var sentinel string
internalUtils.Log.Debug().Msg("Will now create /run/cos is not exists") internalUtils.Log.Debug().Msg("Will now create /run/cos is not exists")
@ -420,7 +420,7 @@ func (s *State) UKIMountBaseSystem(g *herd.Graph) error {
return g.Add( return g.Add(
cnst.OpUkiBaseMounts, cnst.OpUkiBaseMounts,
herd.WithCallback( herd.WithCallback(
func(ctx context.Context) error { func(_ context.Context) error {
var err error var err error
mounts := []mount{ mounts := []mount{
{ {
@ -557,7 +557,7 @@ func (s *State) UKIMountBaseSystem(g *herd.Graph) error {
func (s *State) UKIRemountRootRODagStep(g *herd.Graph) error { func (s *State) UKIRemountRootRODagStep(g *herd.Graph) error {
return g.Add(cnst.OpRemountRootRO, return g.Add(cnst.OpRemountRootRO,
herd.WithDeps(cnst.OpRootfsHook), herd.WithDeps(cnst.OpRootfsHook),
herd.WithCallback(func(ctx context.Context) error { herd.WithCallback(func(_ context.Context) error {
// Create the /sysroot dir before remounting as RO // Create the /sysroot dir before remounting as RO
err := os.MkdirAll(s.path(cnst.UkiSysrootDir), 0755) err := os.MkdirAll(s.path(cnst.UkiSysrootDir), 0755)
if err != nil { if err != nil {
@ -574,7 +574,7 @@ func (s *State) UKIRemountRootRODagStep(g *herd.Graph) error {
func (s *State) UKIUdevDaemon(g *herd.Graph) error { func (s *State) UKIUdevDaemon(g *herd.Graph) error {
return g.Add(cnst.OpUkiUdev, return g.Add(cnst.OpUkiUdev,
herd.WithDeps(cnst.OpUkiBaseMounts, cnst.OpUkiKernelModules), herd.WithDeps(cnst.OpUkiBaseMounts, cnst.OpUkiKernelModules),
herd.WithCallback(func(ctx context.Context) error { herd.WithCallback(func(_ context.Context) error {
// Should probably figure out other udevd binaries.... // Should probably figure out other udevd binaries....
var udevBin string var udevBin string
if _, err := os.Stat("/usr/lib/systemd/systemd-udevd"); !os.IsNotExist(err) { if _, err := os.Stat("/usr/lib/systemd/systemd-udevd"); !os.IsNotExist(err) {
@ -611,7 +611,7 @@ func (s *State) UKIUdevDaemon(g *herd.Graph) error {
func (s *State) LoadKernelModules(g *herd.Graph) error { func (s *State) LoadKernelModules(g *herd.Graph) error {
return g.Add(cnst.OpUkiKernelModules, return g.Add(cnst.OpUkiKernelModules,
herd.WithDeps(cnst.OpUkiBaseMounts), herd.WithDeps(cnst.OpUkiBaseMounts),
herd.WithCallback(func(ctx context.Context) error { herd.WithCallback(func(_ context.Context) error {
drivers, err := kdetect.ProbeKernelModules("") drivers, err := kdetect.ProbeKernelModules("")
if err != nil { if err != nil {
internalUtils.Log.Err(err).Msg("Detecting needed modules") internalUtils.Log.Err(err).Msg("Detecting needed modules")
@ -666,7 +666,7 @@ func (s *State) WaitForSysrootDagStep(g *herd.Graph) error {
// LVMActivation will try to activate lvm volumes/groups on the system. // LVMActivation will try to activate lvm volumes/groups on the system.
func (s *State) LVMActivation(g *herd.Graph) error { func (s *State) LVMActivation(g *herd.Graph) error {
return g.Add(cnst.OpLvmActivate, herd.WithCallback(func(ctx context.Context) error { return g.Add(cnst.OpLvmActivate, herd.WithCallback(func(_ context.Context) error {
return internalUtils.ActivateLVM() return internalUtils.ActivateLVM()
})) }))
} }
@ -674,7 +674,7 @@ func (s *State) LVMActivation(g *herd.Graph) error {
// RunKcrypt will run the UnlockAll method of kcrypt to unlock the encrypted partitions // RunKcrypt will run the UnlockAll method of kcrypt to unlock the encrypted partitions
// Requires sysroot to be mounted as the kcrypt-challenger binary is not injected in the initramfs. // Requires sysroot to be mounted as the kcrypt-challenger binary is not injected in the initramfs.
func (s *State) RunKcrypt(g *herd.Graph, opts ...herd.OpOption) error { func (s *State) RunKcrypt(g *herd.Graph, opts ...herd.OpOption) error {
return g.Add(cnst.OpKcryptUnlock, append(opts, herd.WithCallback(func(ctx context.Context) error { return g.Add(cnst.OpKcryptUnlock, append(opts, herd.WithCallback(func(_ context.Context) error {
internalUtils.Log.Debug().Msg("Unlocking with kcrypt") internalUtils.Log.Debug().Msg("Unlocking with kcrypt")
return kcrypt.UnlockAllWithLogger(false, internalUtils.Log) return kcrypt.UnlockAllWithLogger(false, internalUtils.Log)
}))...) }))...)
@ -684,7 +684,7 @@ func (s *State) RunKcrypt(g *herd.Graph, opts ...herd.OpOption) error {
// we inspect the uuid of the partition directly to know which label to use for the key // we inspect the uuid of the partition directly to know which label to use for the key
// As those old installs have an old agent the only way to do it is during the first boot after the upgrade to the newest immucore. // As those old installs have an old agent the only way to do it is during the first boot after the upgrade to the newest immucore.
func (s *State) RunKcryptUpgrade(g *herd.Graph, opts ...herd.OpOption) error { func (s *State) RunKcryptUpgrade(g *herd.Graph, opts ...herd.OpOption) error {
return g.Add(cnst.OpKcryptUpgrade, append(opts, herd.WithCallback(func(ctx context.Context) error { return g.Add(cnst.OpKcryptUpgrade, append(opts, herd.WithCallback(func(_ context.Context) error {
return internalUtils.UpgradeKcryptPartitions() return internalUtils.UpgradeKcryptPartitions()
}))...) }))...)
} }
@ -746,7 +746,7 @@ func (s *State) MountESPPartition(g *herd.Graph, opts ...herd.OpOption) error {
} }
func (s *State) UKIUnlock(g *herd.Graph, opts ...herd.OpOption) error { func (s *State) UKIUnlock(g *herd.Graph, opts ...herd.OpOption) error {
return g.Add(cnst.OpUkiKcrypt, append(opts, herd.WithCallback(func(ctx context.Context) error { return g.Add(cnst.OpUkiKcrypt, append(opts, herd.WithCallback(func(_ context.Context) error {
// Set full path on uki to get all the binaries // Set full path on uki to get all the binaries
if !state.EfiBootFromInstall(internalUtils.Log) { if !state.EfiBootFromInstall(internalUtils.Log) {
internalUtils.Log.Debug().Msg("Not unlocking disks as we think we are booting from removable media") internalUtils.Log.Debug().Msg("Not unlocking disks as we think we are booting from removable media")
@ -761,7 +761,7 @@ func (s *State) UKIUnlock(g *herd.Graph, opts ...herd.OpOption) error {
// MountLiveCd tries to mount the livecd if we are booting from one into /run/initramfs/live // MountLiveCd tries to mount the livecd if we are booting from one into /run/initramfs/live
// to mimic the same behavior as the livecd on non-uki boot. // to mimic the same behavior as the livecd on non-uki boot.
func (s *State) MountLiveCd(g *herd.Graph, opts ...herd.OpOption) error { func (s *State) MountLiveCd(g *herd.Graph, opts ...herd.OpOption) error {
return g.Add(cnst.OpUkiMountLivecd, append(opts, herd.WithCallback(func(ctx context.Context) error { return g.Add(cnst.OpUkiMountLivecd, append(opts, herd.WithCallback(func(_ context.Context) error {
// If we are booting from Install Media // If we are booting from Install Media
if state.EfiBootFromInstall(internalUtils.Log) { if state.EfiBootFromInstall(internalUtils.Log) {
internalUtils.Log.Debug().Msg("Not mounting livecd as we think we are booting from removable media") internalUtils.Log.Debug().Msg("Not mounting livecd as we think we are booting from removable media")
@ -848,7 +848,7 @@ func (s *State) UKIBootInitDagStep(g *herd.Graph) error {
return g.Add(cnst.OpUkiInit, return g.Add(cnst.OpUkiInit,
herd.WeakDeps, herd.WeakDeps,
herd.WithWeakDeps(cnst.OpRemountRootRO, cnst.OpRootfsHook, cnst.OpInitramfsHook, cnst.OpWriteFstab), herd.WithWeakDeps(cnst.OpRemountRootRO, cnst.OpRootfsHook, cnst.OpInitramfsHook, cnst.OpWriteFstab),
herd.WithCallback(func(ctx context.Context) error { herd.WithCallback(func(_ context.Context) error {
var err error var err error
output, err := internalUtils.CommandWithPath("/usr/lib/systemd/systemd-pcrphase --graceful leave-initrd") output, err := internalUtils.CommandWithPath("/usr/lib/systemd/systemd-pcrphase --graceful leave-initrd")

View File

@ -85,7 +85,7 @@ func (s *State) WriteFstab(fstabFile string) func(context.Context) error {
// RunStageOp runs elemental run-stage stage. If its rootfs its special as it needs som symlinks // RunStageOp runs elemental run-stage stage. If its rootfs its special as it needs som symlinks
// If its uki we don't symlink as we already have everything in the sysroot. // If its uki we don't symlink as we already have everything in the sysroot.
func (s *State) RunStageOp(stage string) func(context.Context) error { func (s *State) RunStageOp(stage string) func(context.Context) error {
return func(ctx context.Context) error { return func(_ context.Context) error {
switch stage { switch stage {
case "rootfs": case "rootfs":
if !internalUtils.IsUKI() { if !internalUtils.IsUKI() {