mirror of
https://github.com/kairos-io/immucore.git
synced 2025-09-02 07:05:27 +00:00
more
more logging run as dry-run print version remove nouser opt Signed-off-by: Itxaka <itxaka@spectrocloud.com>
This commit is contained in:
@@ -62,7 +62,7 @@ build-immucore:
|
|||||||
COPY main.go /work
|
COPY main.go /work
|
||||||
COPY --dir internal /work
|
COPY --dir internal /work
|
||||||
COPY --dir pkg /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
|
SAVE ARTIFACT /work/immucore AS LOCAL build/immucore-$VERSION
|
||||||
|
|
||||||
build-dracut:
|
build-dracut:
|
||||||
|
@@ -29,8 +29,8 @@ oem_label=$(getarg rd.cos.oemlabel=)
|
|||||||
echo "After=sysroot.mount"
|
echo "After=sysroot.mount"
|
||||||
echo "[Service]"
|
echo "[Service]"
|
||||||
echo "Type=oneshot"
|
echo "Type=oneshot"
|
||||||
echo "RemainAfterExit=no"
|
echo "RemainAfterExit=yes"
|
||||||
echo "ExecStart=/usr/bin/immucore start"
|
echo "ExecStart=/usr/bin/immucore start --dry-run"
|
||||||
} > "$GENERATOR_DIR"/immucore.service
|
} > "$GENERATOR_DIR"/immucore.service
|
||||||
|
|
||||||
|
|
||||||
|
34
internal/version/version.go
Normal file
34
internal/version/version.go
Normal 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
|
||||||
|
}
|
3
main.go
3
main.go
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/kairos-io/immucore/internal/version"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/kairos-io/immucore/internal/cmd"
|
"github.com/kairos-io/immucore/internal/cmd"
|
||||||
@@ -24,6 +25,8 @@ func main() {
|
|||||||
Commands: cmd.Commands,
|
Commands: cmd.Commands,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println(version.Get())
|
||||||
|
|
||||||
err := app.Run(os.Args)
|
err := app.Run(os.Args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
@@ -203,8 +203,11 @@ func (s *State) Register(g *herd.Graph) error {
|
|||||||
func(ctx context.Context) error {
|
func(ctx context.Context) error {
|
||||||
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}).With().Caller().Logger()
|
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))
|
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)
|
_, err := utils.SH(cmd)
|
||||||
|
if err != nil {
|
||||||
|
log.Logger.Debug().Err(err).Msg("")
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
@@ -238,14 +241,14 @@ func (s *State) Register(g *herd.Graph) error {
|
|||||||
s.MountOP(
|
s.MountOP(
|
||||||
fmt.Sprintf("/dev/disk/by-label/%s", s.TargetLabel),
|
fmt.Sprintf("/dev/disk/by-label/%s", s.TargetLabel),
|
||||||
s.Rootdir,
|
s.Rootdir,
|
||||||
"ext2", // are images always ext2?
|
"ext4", // are images always ext2?
|
||||||
[]string{
|
[]string{
|
||||||
"ro", // or rw
|
"ro", // or rw
|
||||||
"suid",
|
"suid",
|
||||||
"dev",
|
"dev",
|
||||||
"exec",
|
"exec",
|
||||||
"auto",
|
"auto",
|
||||||
"nouser",
|
//"nouser",
|
||||||
"async",
|
"async",
|
||||||
}, 60*time.Second),
|
}, 60*time.Second),
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user