drone/cli/operations/hooks/update.go
Shubham Banthia c7df722c8a adding server side hook for update (#94)
* adding server side hook for update

* addressing comments

* update comments for command
2022-11-29 19:51:08 -08:00

43 lines
996 B
Go

package hooks
import (
"github.com/harness/gitness/client"
"github.com/rs/zerolog/log"
"gopkg.in/alecthomas/kingpin.v2"
)
type updateCommand struct {
client client.Client
branch string
oldCommit string
newCommit string
}
func (c *updateCommand) run(*kingpin.ParseContext) error {
// TODO: need to implement this method further to completely execute to hooks
log.Info().Msgf("This is the update hook, ref: %s, old commit sha: %s, new commit sha: %s",
c.branch, c.oldCommit, c.newCommit)
return nil
}
func registerUpdate(app *kingpin.CmdClause, client client.Client) {
c := &updateCommand{
client: client,
}
cmd := app.Command("update", "hook that is executed just before the ref is updated").
Action(c.run)
cmd.Arg("ref", "ref on which the hook is executed").
Required().
StringVar(&c.branch)
cmd.Arg("old-commit", "old commit sha").
Required().
StringVar(&c.oldCommit)
cmd.Arg("new-commit", "new commit sha").
Required().
StringVar(&c.newCommit)
}