Skip to content

Commit

Permalink
action: move and inline LogStart() further up
Browse files Browse the repository at this point in the history
Currently each action starts with LogStart(), adding some annoying
duplication. In addition we have a LogStart(), whereas there's no
end/stop equivalent.

Instead add the on-line log.Print() wihtin the debos action loop, just
prior to calling Run(). The same file deals with all the other pretty
logging.

v2: Drop pacman/pacstrap hunks
v3: Resolve pack_action conflict

Signed-off-by: Emil Velikov <[email protected]>
  • Loading branch information
evelikov-work authored and evelikov committed Jul 18, 2023
1 parent 6bcd275 commit ed7ad3f
Show file tree
Hide file tree
Showing 17 changed files with 3 additions and 22 deletions.
5 changes: 0 additions & 5 deletions action.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package debos
import (
"bytes"
"github.com/go-debos/fakemachine"
"log"
)

type DebosState int
Expand Down Expand Up @@ -75,10 +74,6 @@ type BaseAction struct {
Description string
}

func (b *BaseAction) LogStart() {
log.Printf("==== %s ====\n", b)
}

func (b *BaseAction) Verify(context *DebosContext) error { return nil }
func (b *BaseAction) PreMachine(context *DebosContext,
m *fakemachine.Machine,
Expand Down
1 change: 0 additions & 1 deletion actions/apt_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func NewAptAction() *AptAction {
}

func (apt *AptAction) Run(context *debos.DebosContext) error {
apt.LogStart()
aptOptions := []string{"apt-get", "-y"}

if !apt.Recommends {
Expand Down
1 change: 0 additions & 1 deletion actions/debootstrap_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ func (d *DebootstrapAction) isLikelyOldSuite() bool {
}

func (d *DebootstrapAction) Run(context *debos.DebosContext) error {
d.LogStart()
cmdline := []string{"debootstrap"}

if d.MergedUsr {
Expand Down
1 change: 0 additions & 1 deletion actions/download_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ func (d *DownloadAction) Verify(context *debos.DebosContext) error {

func (d *DownloadAction) Run(context *debos.DebosContext) error {
var filename string
d.LogStart()

url, err := d.validateUrl()
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion actions/filesystem_deploy_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ func (fd *FilesystemDeployAction) setupKernelCmdline(context *debos.DebosContext
}

func (fd *FilesystemDeployAction) Run(context *debos.DebosContext) error {
fd.LogStart()
/* Copying files is actually silly hafd, one has to keep permissions, ACL's
* extended attribute, misc, other. Leave it to cp...
*/
Expand Down
1 change: 0 additions & 1 deletion actions/image_partition_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,6 @@ func (i *ImagePartitionAction) PreNoMachine(context *debos.DebosContext) error {
}

func (i ImagePartitionAction) Run(context *debos.DebosContext) error {
i.LogStart()

/* On certain disk device events udev will call the BLKRRPART ioctl to
* re-read the partition table. This will cause the partition devices
Expand Down
1 change: 0 additions & 1 deletion actions/ostree_commit_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func emptyDir(dir string) {
}

func (ot *OstreeCommitAction) Run(context *debos.DebosContext) error {
ot.LogStart()
repoPath := path.Join(context.Artifactdir, ot.Repository)

emptyDir(path.Join(context.Rootdir, "dev"))
Expand Down
1 change: 0 additions & 1 deletion actions/ostree_deploy_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ func (ot *OstreeDeployAction) setupFSTab(deployment *ostree.Deployment, context
}

func (ot *OstreeDeployAction) Run(context *debos.DebosContext) error {
ot.LogStart()

// This is to handle cases there we didn't partition an image
if len(context.ImageMntDir) != 0 {
Expand Down
1 change: 0 additions & 1 deletion actions/overlay_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func (overlay *OverlayAction) Verify(context *debos.DebosContext) error {
}

func (overlay *OverlayAction) Run(context *debos.DebosContext) error {
overlay.LogStart()
origin := context.RecipeDir

//Trying to get a filename from exports first
Expand Down
1 change: 0 additions & 1 deletion actions/pack_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func (pf *PackAction) Verify(context *debos.DebosContext) error {
}

func (pf *PackAction) Run(context *debos.DebosContext) error {
pf.LogStart()
usePigz := false
if pf.Compression == "gz" {
if _,err := exec.LookPath("pigz"); err == nil {
Expand Down
2 changes: 0 additions & 2 deletions actions/pacman_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ type PacmanAction struct {
}

func (p *PacmanAction) Run(context *debos.DebosContext) error {
p.LogStart()

pacmanOptions := []string{"pacman", "-Syu", "--noconfirm"}
pacmanOptions = append(pacmanOptions, p.Packages...)

Expand Down
2 changes: 0 additions & 2 deletions actions/pacstrap_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ func (d *PacstrapAction) PreMachine(context *debos.DebosContext, m *fakemachine.
}

func (d *PacstrapAction) Run(context *debos.DebosContext) error {
d.LogStart()

files := map[string]string{
"/etc/pacman.conf": d.Config,
"/etc/pacman.d/mirrorlist": d.Mirror,
Expand Down
1 change: 0 additions & 1 deletion actions/raw_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ func (raw *RawAction) Verify(context *debos.DebosContext) error {
}

func (raw *RawAction) Run(context *debos.DebosContext) error {
raw.LogStart()
origin, found := context.Origin(raw.Origin)
if !found {
return fmt.Errorf("Origin `%s` doesn't exist\n", raw.Origin)
Expand Down
3 changes: 2 additions & 1 deletion actions/recipe_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ package actions
import (
"errors"
"fmt"
"log"
"os"
"path/filepath"
"github.com/go-debos/debos"
Expand Down Expand Up @@ -114,9 +115,9 @@ func (recipe *RecipeAction) PreNoMachine(context *debos.DebosContext) error {
}

func (recipe *RecipeAction) Run(context *debos.DebosContext) error {
recipe.LogStart()

for _, a := range recipe.Actions.Actions {
log.Printf("==== %s ====\n", a)
if err := a.Run(&recipe.context); err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion actions/run_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func (run *RunAction) PreMachine(context *debos.DebosContext, m *fakemachine.Mac
}

func (run *RunAction) doRun(context debos.DebosContext) error {
run.LogStart()
var cmdline []string
var label string
var cmd debos.Command
Expand Down
1 change: 0 additions & 1 deletion actions/unpack_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func (pf *UnpackAction) Verify(context *debos.DebosContext) error {
}

func (pf *UnpackAction) Run(context *debos.DebosContext) error {
pf.LogStart()
var origin string

if len(pf.Origin) > 0 {
Expand Down
1 change: 1 addition & 0 deletions cmd/debos/debos.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func checkError(context *debos.DebosContext, err error, a debos.Action, stage st

func do_run(r actions.Recipe, context *debos.DebosContext) int {
for _, a := range r.Actions {
log.Printf("==== %s ====\n", a)
err := a.Run(context)

// This does not stop the call of stacked Cleanup methods for other Actions
Expand Down

0 comments on commit ed7ad3f

Please sign in to comment.