more logging
run as dry-run
print version
remove nouser opt

Signed-off-by: Itxaka <itxaka@spectrocloud.com>
This commit is contained in:
Itxaka
2023-02-06 17:24:50 +01:00
parent b071573758
commit 7d539b63f4
5 changed files with 46 additions and 6 deletions

View File

@@ -62,7 +62,7 @@ build-immucore:
COPY main.go /work
COPY --dir internal /work
COPY --dir pkg /work
RUN CGO_ENABLED=0 go build -o immucore -ldflags "-X main.Version=$VERSION"
RUN CGO_ENABLED=0 go build -o immucore -ldflags "-X internal/version.Version=$VERSION"
SAVE ARTIFACT /work/immucore AS LOCAL build/immucore-$VERSION
build-dracut:

View File

@@ -29,8 +29,8 @@ oem_label=$(getarg rd.cos.oemlabel=)
echo "After=sysroot.mount"
echo "[Service]"
echo "Type=oneshot"
echo "RemainAfterExit=no"
echo "ExecStart=/usr/bin/immucore start"
echo "RemainAfterExit=yes"
echo "ExecStart=/usr/bin/immucore start --dry-run"
} > "$GENERATOR_DIR"/immucore.service

View File

@@ -0,0 +1,34 @@
package version
import "runtime"
var (
version = "v0.0.1"
// gitCommit is the git sha1
gitCommit = ""
)
func GetVersion() string {
return version
}
// BuildInfo describes the compiled time information.
type BuildInfo struct {
// Version is the current semver.
Version string `json:"version,omitempty"`
// GitCommit is the git sha1.
GitCommit string `json:"git_commit,omitempty"`
// GoVersion is the version of the Go compiler used.
GoVersion string `json:"go_version,omitempty"`
}
// Get returns build info
func Get() BuildInfo {
v := BuildInfo{
Version: GetVersion(),
GitCommit: gitCommit,
GoVersion: runtime.Version(),
}
return v
}

View File

@@ -2,6 +2,7 @@ package main
import (
"fmt"
"github.com/kairos-io/immucore/internal/version"
"os"
"github.com/kairos-io/immucore/internal/cmd"
@@ -24,6 +25,8 @@ func main() {
Commands: cmd.Commands,
}
fmt.Println(version.Get())
err := app.Run(os.Args)
if err != nil {
fmt.Println(err)

View File

@@ -203,8 +203,11 @@ func (s *State) Register(g *herd.Graph) error {
func(ctx context.Context) error {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}).With().Caller().Logger()
cmd := fmt.Sprintf("losetup --show -f %s", s.path("/run/initramfs/cos-state", s.TargetImage))
log.Logger.Debug().Str("targetImage", s.TargetImage).Str("fullcmd", cmd).Msg("Mounting image")
log.Logger.Debug().Str("targetImage", s.TargetImage).Str("path", s.Rootdir).Str("fullcmd", cmd).Msg("Mounting image")
_, err := utils.SH(cmd)
if err != nil {
log.Logger.Debug().Err(err).Msg("")
}
return err
},
))
@@ -238,14 +241,14 @@ func (s *State) Register(g *herd.Graph) error {
s.MountOP(
fmt.Sprintf("/dev/disk/by-label/%s", s.TargetLabel),
s.Rootdir,
"ext2", // are images always ext2?
"ext4", // are images always ext2?
[]string{
"ro", // or rw
"suid",
"dev",
"exec",
"auto",
"nouser",
//"nouser",
"async",
}, 60*time.Second),
),