Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions bake/hclparser/stdlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ var stdlibFunctions = []funcDef{
// value in a list.
func indexOfFunc() function.Function {
return function.New(&function.Spec{
Description: `Finds the element index for a given value in a list.`,
Params: []function.Parameter{
{
Name: "list",
Expand Down Expand Up @@ -177,6 +178,7 @@ func indexOfFunc() function.Function {
// basenameFunc constructs a function that returns the last element of a path.
func basenameFunc() function.Function {
return function.New(&function.Spec{
Description: `Returns the last element of a path.`,
Params: []function.Parameter{
{
Name: "path",
Expand All @@ -194,6 +196,7 @@ func basenameFunc() function.Function {
// dirnameFunc constructs a function that returns the directory of a path.
func dirnameFunc() function.Function {
return function.New(&function.Spec{
Description: `Returns the directory of a path.`,
Params: []function.Parameter{
{
Name: "path",
Expand All @@ -212,6 +215,7 @@ func dirnameFunc() function.Function {
// leaving only characters that are valid for a Bake target name.
func sanitizeFunc() function.Function {
return function.New(&function.Spec{
Description: `Replaces all non-alphanumeric characters with a underscore, leaving only characters that are valid for a Bake target name.`,
Params: []function.Parameter{
{
Name: "name",
Expand Down Expand Up @@ -240,8 +244,9 @@ func sanitizeFunc() function.Function {
// This function was imported from terraform's datetime utilities.
func timestampFunc() function.Function {
return function.New(&function.Spec{
Params: []function.Parameter{},
Type: function.StaticReturnType(cty.String),
Description: `Returns a string representation of the current date and time.`,
Params: []function.Parameter{},
Type: function.StaticReturnType(cty.String),
Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) {
return cty.StringVal(time.Now().UTC().Format(time.RFC3339)), nil
},
Expand Down
5 changes: 2 additions & 3 deletions docs/bake-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1399,8 +1399,7 @@ $ docker buildx bake

## Function

A [set of general-purpose functions][bake_stdlib]
provided by [go-cty][go-cty]
A [set of general-purpose functions][bake_stdlib] provided by [go-cty][go-cty]
are available for use in HCL files:

```hcl
Expand Down Expand Up @@ -1440,7 +1439,7 @@ target "webapp-dev" {

[add-host]: https://docs.docker.com/reference/cli/docker/buildx/build/#add-host
[attestations]: https://docs.docker.com/build/attestations/
[bake_stdlib]: https://github.com/docker/buildx/blob/master/bake/hclparser/stdlib.go
[bake_stdlib]: https://github.com/docker/buildx/blob/master/docs/bake-stdlib.md
[build-arg]: https://docs.docker.com/reference/cli/docker/image/build/#build-arg
[build-context]: https://docs.docker.com/reference/cli/docker/buildx/build/#build-context
[cache-backends]: https://docs.docker.com/build/cache/backends/
Expand Down
Loading