Pass variables to hooks

Is it possible to pass variables from the pipeline to hooks?

The docs mention

This can be useful to do things such as perform a security scan on an image, run database migrations on a deploy, etc

If I wanted to do something that targets the image we’ve just built in the build step, is there a way for that image name/tag to be passed in? Could gitrefpretty() be used in a string?

Are there any other functions like gitrefpretty() available? If so are they documented somewhere?

I’m considering something like this - is there any variable or function I can use to get the image name in the hook command? If not, can gitrefpretty() be used there? Or could I use it in a string

app "waypoint-up" {
    build {
        use "docker" {}
        registry {
            use "docker" {
                image = "hashicorp/wpmini"
                tag = gitrefpretty()
            }
         }

         # get image name example
         hook {
            when = "after"
            command = ["./integration-test.sh", imagenamepretty()]
        }     

         # gitrefpretty() example
         hook {
            when = "after"
            command = ["./integration-test.sh", "hashicorp/wpmini:${gitrefpretty()}"]
        }     

      }

@evanphx made a PR (still pending) that will lead to official function documentation. In the meantime, checkout this file for a list of functions.

I noticed when building the hooks documentation and examples that context about the event that caused the hook such as environment variables etc were not available. I suspect it’s very likely that enhancing the metadata that is available when executing hooks will enhance their capability significantly. This is probably deserving of an issue to track it if you’d like to file one.