Skip to content

Commit 1d499c6

Browse files
committed
Add TOC to develop.md
1 parent e54e1cd commit 1d499c6

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

docs/develop.md

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@
22

33
This guide will walk you through developing a KPT function using the Typescript SDK.
44

5-
## Prerequisites
5+
<!-- toc -->
6+
7+
- [Setup](#setup)
8+
- [Create the NPM package](#create-the-npm-package)
9+
- [Implement the function](#implement-the-function)
10+
- [Build and push Docker image](#build-and-push-docker-image)
11+
- [Use the SDK CLI](#use-the-sdk-cli)
12+
- [Next Steps](#next-steps)
13+
14+
<!-- tocstop -->
15+
16+
## Setup
617

718
### System Requirements
819

@@ -92,9 +103,9 @@ gcloud container clusters get-credentials $USER-1-14-alpha --zone us-central1-a
92103
93104
### Working with CRDs
94105
106+
The SDK uses the k8s server to generate the typescript classes.
95107
If your function uses a Custom Resource Definition, make sure you apply it to the cluster before
96-
generating the SDK. Typescript uses the k8s server to generate the types represented there,
97-
including your CRD.
108+
generating the SDK.
98109
99110
```sh
100111
kubectl apply -f /path/to/my/crd.yaml
@@ -105,8 +116,8 @@ kubectl apply -f /path/to/my/crd.yaml
105116
To initialize a new NPM package, first create a package directory:
106117
107118
```sh
108-
mkdir <my-package>
109-
cd <my-package>
119+
mkdir my-package
120+
cd my-package
110121
```
111122
112123
> **Note:** All subsequent commands are run from the `my-package/` directory.
@@ -133,13 +144,13 @@ This process will create the following:
133144
including the `create-kpt-functions` CLI discussed later in the `README`.
134145
1. `src/`: Directory containing the source files for all your functions, e.g.:
135146
136-
- `<my_func.ts>`: Implement your function's interface here.
137-
- `<my_func_test.ts>`: Unit tests for your function.
138-
- `<my_func_run.ts>`: The entry point from which your function is run.
147+
- `my_func.ts`: Implement your function's interface here.
148+
- `my_func_test.ts`: Unit tests for your function.
149+
- `my_func_run.ts`: The entry point from which your function is run.
139150
140151
1. `src/gen/`: Contains Kubernetes core and CRD types generated from the OpenAPI spec published by the cluster you selected.
141152
1. `build/`: Contains Dockerfile for each function, e.g.:
142-
- `<my_func>.Dockerfile`
153+
- `my_func.Dockerfile`
143154
144155
Next, install all package dependencies:
145156
@@ -152,20 +163,20 @@ In addition to installation, `install` compiles your function into the `dist/` d
152163
You can run your function directly:
153164
154165
```sh
155-
node dist/<my_func_run>.js --help
166+
node dist/my_func_run.js --help
156167
```
157168
158169
Currently, it simply passes through the input configuration data. Let's remedy this.
159170
160-
## Implementing the function
171+
## Implement the function
161172
162173
You can now start implementing the function using your favorite IDE, e.g. [VSCode][vscode]:
163174
164175
```sh
165176
code .
166177
```
167178
168-
In `src/<my_func>.ts`, implement the `KptFunc` interface [documented here][api-kptfunc].
179+
In `src/my_func.ts`, implement the `KptFunc` interface [documented here][api-kptfunc].
169180
170181
Take a look at [these example functions][demo-funcs] to better understand how to use
171182
`kpt-functions` library. These functions are available as docker images documented in the [catalog][catalog].
@@ -189,7 +200,7 @@ To run the tests, use:
189200
npm test
190201
```
191202
192-
## Container images
203+
## Build and push Docker image
193204
194205
With your working function in-hand, it's time to package your function into an executable docker
195206
image.
@@ -230,7 +241,7 @@ npm run kpt:docker-build -- --tag=latest
230241
npm run kpt:docker-push -- --tag=latest
231242
```
232243
233-
## SDK CLI
244+
## Use the SDK CLI
234245
235246
The `create-kpt-functions` package (installed as `devDependencies`), provides a CLI for managing
236247
the NPM package you created above. The CLI sub-commands can be invoked via `npm run`. For example,
@@ -240,6 +251,8 @@ to add a new function to the package:
240251
npm run kpt:function-create -- --help
241252
```
242253
254+
> **Note:** Flags are passed to the CLI after the `--` separator.
255+
243256
These sub-commands are available:
244257
245258
```console
@@ -253,8 +266,6 @@ kpt:type-create Generate classes for core and CRD types. Overwrite
253266
files if they exist.
254267
```
255268
256-
> **Note:** Flags are passed to the CLI after the `--` separator.
257-
258269
## Next Steps
259270
260271
- [Running KPT Functions](run.md)

0 commit comments

Comments
 (0)