Attempt to workaround various "spelling mistakes"

Signed-off-by: Nic Cope <nicc@rk0n.org>
This commit is contained in:
Nic Cope 2023-10-31 17:46:50 -07:00
parent 6487b23a4f
commit 038ad6b0f9
1 changed files with 22 additions and 25 deletions

View File

@ -16,7 +16,7 @@ page to learn more about composition functions.
You can write a function to template resources using a general purpose You can write a function to template resources using a general purpose
programming language. Using a general purpose programming language allows a programming language. Using a general purpose programming language allows a
Function to use more advanced logic to template resources, like loops and function to use more advanced logic to template resources, like loops and
conditionals. This guide explains how to write a composition function in conditionals. This guide explains how to write a composition function in
[Go](https://go.dev). [Go](https://go.dev).
@ -77,11 +77,10 @@ build or test a composition function.
## Initialize the function from a template ## Initialize the function from a template
Use the `crossplane beta xpkg init` command to initialize a new function named Use the `crossplane beta xpkg init` command to initialize a new function. When
function-xbuckets. When you run this command the CLI initializes your function you run this command the CLI initializes your function using
using the [this GitHub repository](https://github.com/crossplane/function-template-go)
[function-template-go](https://github.com/crossplane/function-template-go) as a template.
GitHub repository as a template.
```shell ```shell
crossplane beta xpkg init function-xbuckets function-template-go -d function-xbuckets crossplane beta xpkg init function-xbuckets function-template-go -d function-xbuckets
@ -132,9 +131,8 @@ you push Go code to GitHub, you can use your GitHub username. For example
The `input` directory defines a Go struct that a function can use to take input, The `input` directory defines a Go struct that a function can use to take input,
using the `input` field from a Composition. The using the `input` field from a Composition. The
[composition functions]({{<ref "../../master/concepts/composition-functions">}}) [composition functions]({{<ref "../../master/concepts/composition-functions">}})
documentation explains how to pass an input to a composition function. documentation explains how to pass an input to a composition function. This
function-xbuckets doesn't use an input, so you should delete the `input` function doesn't use an input, so you should delete the `input` directory.
directory.
You should also delete the `package/input` directory. It contains an OpenAPI You should also delete the `package/input` directory. It contains an OpenAPI
schema automatically generated from the structs in the `input` directory. schema automatically generated from the structs in the `input` directory.
@ -142,7 +140,7 @@ schema automatically generated from the structs in the `input` directory.
{{<hint "tip">}} {{<hint "tip">}}
If you're writing a function that does use an input type, rename the type from If you're writing a function that does use an input type, rename the type from
`Input` to something more specific to your function. For example `Input` to something more specific to your function. For example
function-patch-and-transform names its input type `Resources`. Rename the API Function Patch and Transform names its input type `Resources`. Rename the API
version too by updating the `// +groupName` comment at the top of `input.go`. version too by updating the `// +groupName` comment at the top of `input.go`.
When you edit files under the `input` directory you must update some generated When you edit files under the `input` directory you must update some generated
@ -405,23 +403,22 @@ The code uses the `v1beta1.Bucket` type from
advantage of writing a function in Go is that you can compose resources using advantage of writing a function in Go is that you can compose resources using
the same strongly typed structs Crossplane uses in its providers. the same strongly typed structs Crossplane uses in its providers.
You must You must get the AWS Provider Go module to use this type:
get the provider-aws Go to use this type:
```shell ```shell
go get github.com/upbound/provider-aws@v0.43.0 go get github.com/upbound/provider-aws@v0.43.0
``` ```
Crossplane provides a software development kit (SDK) named Crossplane provides a
[function-sdk-go](https://github.com/crossplane/function-sdk-go) for writing [software development kit](https://github.com/crossplane/function-sdk-go) (SDK)
composition functions in [Go](https://go.dev). The function-xbuckets code uses for writing composition functions in [Go](https://go.dev). This function uses
utilities from function-sdk-go. In particular the `request` and `response` utilities from the SDK. In particular the `request` and `response` packages make
packages make working with the `RunFunctionRequest` and `RunFunctionResponse` working with the `RunFunctionRequest` and `RunFunctionResponse` types easier.
types easier.
{{<hint "tip">}} {{<hint "tip">}}
Read the Go package documentation for function-sdk-go at Read the
[pkg.go.dev](https://pkg.go.dev/github.com/crossplane/function-sdk-go). [Go package documentation](https://pkg.go.dev/github.com/crossplane/function-sdk-go).
for the SDK.
{{</hint>}} {{</hint>}}
## Test the function end-to-end ## Test the function end-to-end
@ -436,7 +433,7 @@ They use only [`pkg/testing`](https://pkg.go.dev/testing) from the Go standard
library and [`google/go-cmp`](https://pkg.go.dev/github.com/google/go-cmp/cmp). library and [`google/go-cmp`](https://pkg.go.dev/github.com/google/go-cmp/cmp).
To add test cases, update the `cases` map in `TestRunFunction`. Expand the below To add test cases, update the `cases` map in `TestRunFunction`. Expand the below
block to view the full `fn_test.go` file for function-xbuckets. block to view the full `fn_test.go` file for the function.
{{<expand "The full fn_test.go file" >}} {{<expand "The full fn_test.go file" >}}
```go ```go
@ -557,7 +554,7 @@ func TestRunFunction(t *testing.T) {
``` ```
{{</expand>}} {{</expand>}}
Run the function-xbuckets unit tests using the `go test` command: Run the unit tests using the `go test` command:
```shell ```shell
go test -v -cover . go test -v -cover .
@ -570,7 +567,7 @@ coverage: 52.6% of statements
ok github.com/negz/function-xbuckets 0.016s coverage: 52.6% of statements ok github.com/negz/function-xbuckets 0.016s coverage: 52.6% of statements
``` ```
You can preview the output of a Composition that uses function-xbuckets using You can preview the output of a Composition that uses this function using
the Crossplane CLI. You don't need a Crossplane control plane to do this. the Crossplane CLI. You don't need a Crossplane control plane to do this.
Create a directory under `function-xbuckets` named `examples`, and add the Create a directory under `function-xbuckets` named `examples`, and add the
@ -632,7 +629,7 @@ spec:
``` ```
{{</expand>}} {{</expand>}}
Note that the Function in functions.yaml uses the Note that the Function in `functions.yaml` uses the
{{<hover label="development" line="6">}}Development{{</hover>}} {{<hover label="development" line="6">}}Development{{</hover>}}
runtime. This tells `crossplane beta render` that your function is running runtime. This tells `crossplane beta render` that your function is running
locally. It connects to your locally running function instead of using Docker to locally. It connects to your locally running function instead of using Docker to
@ -739,7 +736,7 @@ Read the composition functions documentation to learn more about
You build a function in two stages. First you build the function's runtime. This You build a function in two stages. First you build the function's runtime. This
is the Open Container Initiative (OCI) image Crossplane uses to run your is the Open Container Initiative (OCI) image Crossplane uses to run your
function. You then embed that runtime in a package, and push it to a package function. You then embed that runtime in a package, and push it to a package
registry. The Crossplane CLI uses xpkg.upbound.io as its default package registry. The Crossplane CLI uses `xpkg.upbound.io` as its default package
registry. registry.
A function supports a single platform, like `linux/amd64`, by default. You can A function supports a single platform, like `linux/amd64`, by default. You can