Skip to content

Commit f638336

Browse files
author
Mengqi Yu
committed
Merge branch 'master' into starlark/v0.2
2 parents 5bb72c2 + 54c6e47 commit f638336

File tree

91 files changed

+3445
-2861
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+3445
-2861
lines changed

CONTRIBUTING.md

Lines changed: 100 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,9 @@
11
# Contributing to kpt-functions-catalog
22

3-
We'd love to accept your contributions to this project. There are
4-
just a few small guidelines you need to follow.
3+
We'd love to accept your contributions to this project. There are just a few
4+
small guidelines you need to follow.
55

6-
## Community Guidelines
7-
8-
This project follows [Google's Open Source Community Guidelines]
9-
and a [Code of Conduct].
10-
11-
## How to Contribute
12-
13-
This catalog contains configuration functions to fetch, display, customize,
14-
update, validate, and apply Kubernetes configuration. Contribute functions
15-
to this catalog by making the following changes:
16-
17-
1. Make the code changes implementing the function and any unit tests. The code
18-
belongs under [functions/] in the appropriate directory.
19-
2. Create an example of how to run your function and put it under [examples/].
20-
3. Test running your function example imperatively and declaratively in
21-
[e2e tests]. These tests are run regularly and help catch regressions.
22-
4. Document your function in the config functions catalog on the [kpt website]
23-
by following the [kpt contribution guidelines].
24-
5. Reach out to the maintainers to publish the function.
25-
26-
Make PRs and request reviews for these changes. You can follow the pull request
27-
changes below:
28-
29-
* [function implementation PR]
30-
* [example and e2e test PR]
31-
* [catalog documentation PR]
32-
33-
### Code Changes
34-
35-
#### Contributor License Agreement
6+
## Contributor License Agreement
367

378
Contributions to this project must be accompanied by a Contributor License
389
Agreement. You (or your employer) retain the copyright to your contribution;
@@ -44,38 +15,117 @@ You generally only need to submit a CLA once, so if you've already submitted
4415
one (even if it was for a different project), you probably don't need to do it
4516
again.
4617

47-
#### Code reviews
18+
## Code reviews
4819

4920
All submissions, including submissions by project members, require review. We
50-
use GitHub pull requests for this purpose. Consult
51-
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
21+
use GitHub pull requests for this purpose. Consult [GitHub Help] for more
5222
information on using pull requests.
5323

54-
### Documentation Changes
24+
## Community Guidelines
5525

56-
This catalog is documented on the [kpt website]. Follow the
57-
[kpt contribution guidelines] to make docs changes.
26+
This project follows [Google's Open Source Community Guidelines] and
27+
a [Code of Conduct].
5828

59-
Changes to other documentation such as examples and README files can follow the
60-
same pull request format as code changes.
29+
## Style Guides
30+
31+
Contributions are required to follow these style guides:
32+
33+
- [Error Message Style Guide]
34+
- [Documentation Style Guide]
35+
36+
## How to Contribute
37+
38+
### Repo Layout
39+
40+
```shell
41+
├── examples: Home for all function examples
42+
│ ├── contrib: Home for all contrib function examples
43+
│ ├── curated_function_bar_example
44+
│ └── curated_function_foo_example
45+
├── functions
46+
│ ├── contrib: Home for all contrib function source code
47+
│ │ └── ts: Home for all typescript-based contrib function source code
48+
│ │ ├── Makefile
49+
│ │ └── contrib_ts_function_foo
50+
│ ├── go: Home for all golang-based curated function source code
51+
│ │ ├── Makefile
52+
│ │ ├── curated_go_function_bar
53+
│ │ └── curated_go_function_foo
54+
│ └── ts: Home for all typescript-based curated function source code
55+
│ ├── Makefile
56+
│ ├── curated_ts_function_bar
57+
│ └── curated_ts_function_foo
58+
├── scripts
59+
└── tests: Home for e2e tests
60+
```
61+
62+
For each function, its files spread in the follow places:
63+
64+
- `functions/` directory: Each function must have its own directory in one
65+
of `functions/` sub-directory. In each function's directory, it must have
66+
the following:
67+
- Source code (and unit tests).
68+
- A README.md file serving as the usage doc and will be shown in
69+
the [catalog website].
70+
- golang-based functions should follow [this template][golang-template].
71+
- typescript-based functions should follow [this template][ts-template].
72+
- A metadata.yaml file that follows the function metadata schema.
73+
- A Dockerfile to build the docker container.
74+
- `examples/` directory: It contains examples for functions, and these examples
75+
are also being tested as e2e tests. Each function should have at least one
76+
example here. There must be a README.md file in each example directory, and it
77+
should follow the [template][example-template].
78+
- The `tests/` directory contains additional e2e tests.
79+
80+
### E2E Tests
81+
82+
The e2e tests are the recommended way to test functions in the catalog. They are
83+
very easy to write and set up with our [e2e test harness].
84+
85+
You can choose to put the e2e test in either the `examples/` directory or in the
86+
`tests/` directory depending on if it is worthwhile to be shown as an example.
87+
88+
### Change Existing Functions
89+
90+
You must follow the layout convention when you make changes to existing
91+
functions.
92+
93+
If you implement a new feature, you must add a new example or modify existing
94+
one to cover it.
95+
96+
If you fix a bug, you must add (unit or e2e) tests to cover that.
97+
98+
### Contribute New Functions
99+
100+
You must follow the layout convention when you contribute new functions.
61101

62102
## Contact Us
63103

64-
Do you need a review or release of configuration functions? We’d love to hear
65-
from you!
104+
Do you need a review or release of functions? We’d love to hear from you!
66105

67106
* Message our [Slack channel]
68107
* Join our [email list]
69108

70109
[Google's Open Source Community Guidelines]: https://opensource.google.com/conduct/
110+
71111
[Code of Conduct]: CODE_OF_CONDUCT.md
72-
[kpt website]: https://googlecontainertools.github.io/kpt/guides/consumer/function/
73-
[kpt contribution guidelines]: https://github.com/GoogleContainerTools/kpt/blob/master/CONTRIBUTING.md#adding-or-updating-catalog-functions
74-
[functions/]: functions/
75-
[examples/]: examples/
76-
[e2e tests]: tests/e2e.sh
77-
[function implementation PR]: https://github.com/GoogleContainerTools/kpt-functions-catalog/pull/61/
78-
[example and e2e test PR]: https://github.com/GoogleContainerTools/kpt-functions-catalog/pull/71
79-
[catalog documentation PR]: https://github.com/GoogleContainerTools/kpt/pull/785/
112+
113+
[catalog website]: https://catalog.kpt.dev/
114+
115+
[e2e test harness]: https://pkg.go.dev/github.com/GoogleContainerTools/kpt@v1.0.0-beta.2/pkg/test/runner
116+
117+
[golang-template]: https://raw.githubusercontent.com/GoogleContainerTools/kpt-functions-catalog/master/functions/go/_template/README.md
118+
119+
[ts-template]: https://raw.githubusercontent.com/GoogleContainerTools/kpt-functions-catalog/master/functions/ts/_template/README.md
120+
121+
[example-template]: https://raw.githubusercontent.com/GoogleContainerTools/kpt-functions-catalog/master/examples/_template/README.md
122+
80123
[Slack channel]: https://kubernetes.slack.com/channels/kpt/
124+
81125
[email list]: https://groups.google.com/forum/?oldui=1#!forum/kpt-users
126+
127+
[error message style guide]: https://github.com/GoogleContainerTools/kpt/blob/main/docs/style-guides/errors.md
128+
129+
[documentation style guide]: https://github.com/GoogleContainerTools/kpt/blob/main/docs/style-guides/docs.md
130+
131+
[GitHub Help]: https://help.github.com/articles/about-pull-requests/

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ push: ## Push images to registry. WARN: This operation should only be done in CI
5656

5757
site-generate: ## Collect function branches and generate a catalog of their examples and documentation using kpt next.
5858
rm -rf ./site/*/
59-
# GO111MODULE=on go get -v github.com/GoogleContainerTools/kpt@next
6059
(cd scripts/generate_catalog/ && go run . ../.. ../../site)
6160

6261
site-run: ## Run the site locally.

VERSIONING.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Versioning
2+
3+
## SemVer and shorter SemVer
4+
5+
We use [semantic versioning] for all of our images. The images with fully
6+
specified version (e.g. `vX.Y.Z`) are immutable and will never be changed. We
7+
also support a shorter version of semantic versioning. E.g.
8+
`v<major>` and `v<major>.<minor>`.
9+
10+
The shorter version of semantic versioning is going to be floating tags:
11+
12+
- `v<major>.<minor>` always points to `v<major>.<minor>.X` where X is the latest
13+
(largest) patch version number. E.g. assume `v1.2` points `v1.2.0` initially.
14+
After `v1.2.1` is released, `v1.2` now points to `v1.2.1`.
15+
16+
- `v<major>` always points to `v<major>.X` where X is the latest (largest) minor
17+
version number. E.g. assume `v1` points `v1.2.0` initially. After `v1.3.0` is
18+
released, `v1` now points to `v1.3.0`. After `v1.3.1` is released, `v1` now
19+
points to `v1.3.1`.
20+
21+
Note: We do NOT support the `latest` tag, since we cannot provide any
22+
compatibility guarantee for it, and the pipeline won’t produce deterministic
23+
results.
24+
25+
## User-facing Surfaces
26+
27+
All functions in the catalog comply with the [function spec]. To learn more
28+
about the functions concept,
29+
see [here](http://kpt.dev/book/02-concepts/03-functions).
30+
31+
There are 2 user-facing surfaces for a function:
32+
33+
- The `functionConfig`
34+
- The function behavior
35+
36+
### functionConfig Surface
37+
38+
A `functionConfig` can be either a core resource (e.g. `ConfigMap`) or a custom
39+
resource. If the `functionConfig` is a CRD, it can be versioned independently as
40+
a normal CRD.
41+
42+
### Function Behavior Surface
43+
44+
#### What are NOT part of the function behavior surface
45+
46+
- The formatting of serialization for output items and results. e.g. yaml
47+
indentation and order of fields in a map.
48+
- The order of resources in the output items.
49+
- The order of result items in the results.
50+
- The content of the unstructured messages in the results.
51+
52+
#### What are part of the function behavior surface
53+
54+
- The supported `functionConfig`:
55+
- If the function supports `ConfigMap` as `functionConfig`, the supported
56+
fields in the `ConfigMap`.
57+
- If the function supports a custom resource as `functionConfig`, the
58+
supported versions of the custom resource.
59+
- How the function behave given the input items and `functionConfig`:
60+
- The remaining aspects of the output items that are not mentioned in the
61+
previous section.
62+
- The remaining aspects of the results that are not mentioned in the
63+
previous section.
64+
65+
For example, if the `kubeval` function stops supporting
66+
the `ignore_missing_schemas` option in the `ConfigMap`, it will be a breaking
67+
change.
68+
69+
Another example, if the `set-namespace` function stops supporting custom
70+
resource of apiVersion `fn.kpt.dev/v1alpha1` and kind `SetNamespace`, it will be
71+
a breaking change.
72+
73+
### Breaking Changes
74+
75+
We define a breaking change as: For any given input (including `input items`,
76+
`functionConfig` and OpenAPI), the function produces a different output
77+
(including output items, results) that are part of the user-facing surface.
78+
79+
### Backwards Compatibility
80+
81+
For post v1.0.0 versions, we will:
82+
83+
- Bump major version: There are breaking changes.
84+
85+
- Bump minor version: There are backward-compatible features.
86+
87+
- Bump patch version: There are only bug fixes and security fixes (e.g.
88+
dependency package non-breaking version bump and base image non-breaking
89+
version bump).
90+
91+
For pre v1.0.0 versions, the major version is always `0` and we will:
92+
93+
- Bumping minor version: There are breaking changes.
94+
95+
- Bumping patch version: In all other cases, including backward-compatible
96+
features, bug fixes and security fixes.
97+
98+
## Best Practices
99+
100+
There are 2 ways to specify your desired version:
101+
102+
- You can fully specify the whole SemVer: The benefits are that you get
103+
immutable infrastructure, and you control when to upgrade functions.
104+
- You can use floating tags (e.g. `vX.Y` and `vX`): The benefits are that there
105+
are less maintenance toil, since it automatically pick up the security and bug
106+
fixes.
107+
108+
Don't use `latest` tag if you use your own function images, since
109+
it’s [not a best practice] for production and also it
110+
is [not recommended by kubernetes].
111+
112+
[not a best practice]: https://vsupalov.com/docker-latest-tag/
113+
114+
[not recommended by kubernetes]: https://kubernetes.io/docs/concepts/configuration/overview/#container-images
115+
116+
[semantic versioning]: https://semver.org/
117+
118+
[function spec]: https://github.com/kubernetes-sigs/kustomize/blob/master/cmd/config/docs/api-conventions/functions-spec.md

examples/apply-setters-simple/.expected/diff.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ index b521905..0d10662 100644
2626
environments: # kpt-set: ${env}
2727
+ - prod
2828
- dev
29-
- - stage
29+
- - stage

0 commit comments

Comments
 (0)