Skip to content

Commit

Permalink
add asset command functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ross96D committed Sep 3, 2024
1 parent 36f8a22 commit 096429a
Showing 1 changed file with 13 additions and 27 deletions.
40 changes: 13 additions & 27 deletions share/app_match.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,8 @@ type appUpdater struct {
// how do i know if i am on a failed state?
// if update aditional assets fail is a failed state?
state state

// cleanupFuncs []func()
}

// func (u *appUpdater) addCleanUpFn(fn func()) {
// if u.cleanupFuncs == nil {
// u.cleanupFuncs = make([]func(), 0)
// }
// u.cleanupFuncs = append(u.cleanupFuncs, fn)
// }

func (u appUpdater) seek(asset configuration.Asset) io.ReadCloser {
return u.data.Get(asset.Name)
}
Expand Down Expand Up @@ -152,6 +143,15 @@ func (u *appUpdater) updateAsset(v configuration.Asset) (fnCopy func() (err erro
}
}

if v.Command != nil {
cmd := exec.Command(v.Command.Command, v.Command.Args...)
output, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("%s cmd: %s %s %w", v.Name, cmd.String(), string(output), err)
}
log.Debug().Msgf("%s cmd: %s %s", v.Name, cmd.String(), string(output))
}

return nil
}

Expand All @@ -163,25 +163,11 @@ func (u appUpdater) RunPostAction() error {
return nil
}
cmd := exec.Command(u.app.Command.Command, u.app.Command.Args...)
log.Info().Msg("running post action " + cmd.String())
b, err := cmd.Output()
log.Debug().Msg("running post action " + cmd.String())
output, err := cmd.CombinedOutput()
if err != nil {
log.Error().Err(
fmt.Errorf(
"running post action %s with output %s. Error: %w",
cmd.String(),
string(b),
err,
),
).Send()
return err
return fmt.Errorf("postaction cmd: %s %s %w", cmd.String(), string(output), err)
}
log.Info().Str("command output", string(b)).Send()
log.Debug().Msgf("postaction cmd: %s %s", cmd.String(), string(output))
return nil
}

// func (u appUpdater) CleanUp() {
// for _, f := range u.cleanupFuncs {
// f()
// }
// }

0 comments on commit 096429a

Please sign in to comment.