Skip to content

Commit 1053be8

Browse files
committed
updates to devel/*.md files
Signed-off-by: mikebrow <[email protected]>
1 parent 6bdc0bf commit 1053be8

6 files changed

+1225
-586
lines changed

docs/devel/adding-an-APIGroup.md

+50-15
Original file line numberDiff line numberDiff line change
@@ -35,50 +35,85 @@ Documentation for other releases can be found at
3535
Adding an API Group
3636
===============
3737

38-
This document includes the steps to add an API group. You may also want to take a look at PR [#16621](https://github.com/kubernetes/kubernetes/pull/16621) and PR [#13146](https://github.com/kubernetes/kubernetes/pull/13146), which add API groups.
38+
This document includes the steps to add an API group. You may also want to take
39+
a look at PR [#16621](https://github.com/kubernetes/kubernetes/pull/16621) and
40+
PR [#13146](https://github.com/kubernetes/kubernetes/pull/13146), which add API
41+
groups.
3942

40-
Please also read about [API conventions](api-conventions.md) and [API changes](api_changes.md) before adding an API group.
43+
Please also read about [API conventions](api-conventions.md) and
44+
[API changes](api_changes.md) before adding an API group.
4145

4246
### Your core group package:
4347

44-
We plan on improving the way the types are factored in the future; see [#16062](https://github.com/kubernetes/kubernetes/pull/16062) for the directions in which this might evolve.
48+
We plan on improving the way the types are factored in the future; see
49+
[#16062](https://github.com/kubernetes/kubernetes/pull/16062) for the directions
50+
in which this might evolve.
4551

46-
1. Create a folder in pkg/apis to hold you group. Create types.go in pkg/apis/`<group>`/ and pkg/apis/`<group>`/`<version>`/ to define API objects in your group;
52+
1. Create a folder in pkg/apis to hold you group. Create types.go in
53+
pkg/apis/`<group>`/ and pkg/apis/`<group>`/`<version>`/ to define API objects
54+
in your group;
4755

48-
2. Create pkg/apis/`<group>`/{register.go, `<version>`/register.go} to register this group's API objects to the encoding/decoding scheme (e.g., [pkg/apis/extensions/register.go](../../pkg/apis/extensions/register.go) and [pkg/apis/extensions/v1beta1/register.go](../../pkg/apis/extensions/v1beta1/register.go);
56+
2. Create pkg/apis/`<group>`/{register.go, `<version>`/register.go} to register
57+
this group's API objects to the encoding/decoding scheme (e.g.,
58+
[pkg/apis/extensions/register.go](../../pkg/apis/extensions/register.go) and
59+
[pkg/apis/extensions/v1beta1/register.go](../../pkg/apis/extensions/v1beta1/register.go);
4960

50-
3. Add a pkg/apis/`<group>`/install/install.go, which is responsible for adding the group to the `latest` package, so that other packages can access the group's meta through `latest.Group`. You probably only need to change the name of group and version in the [example](../../pkg/apis/extensions/install/install.go)). You need to import this `install` package in {pkg/master, pkg/client/unversioned}/import_known_versions.go, if you want to make your group accessible to other packages in the kube-apiserver binary, binaries that uses the client package.
61+
3. Add a pkg/apis/`<group>`/install/install.go, which is responsible for adding
62+
the group to the `latest` package, so that other packages can access the group's
63+
meta through `latest.Group`. You probably only need to change the name of group
64+
and version in the [example](../../pkg/apis/extensions/install/install.go)). You
65+
need to import this `install` package in {pkg/master,
66+
pkg/client/unversioned}/import_known_versions.go, if you want to make your group
67+
accessible to other packages in the kube-apiserver binary, binaries that uses
68+
the client package.
5169

52-
Step 2 and 3 are mechanical, we plan on autogenerate these using the cmd/libs/go2idl/ tool.
70+
Step 2 and 3 are mechanical, we plan on autogenerate these using the
71+
cmd/libs/go2idl/ tool.
5372

5473
### Scripts changes and auto-generated code:
5574

5675
1. Generate conversions and deep-copies:
5776

58-
1. Add your "group/" or "group/version" into hack/after-build/{update-generated-conversions.sh, update-generated-deep-copies.sh, verify-generated-conversions.sh, verify-generated-deep-copies.sh};
59-
2. Make sure your pkg/apis/`<group>`/`<version>` directory has a doc.go file with the comment `// +genconversion=true`, to catch the attention of our gen-conversion script.
77+
1. Add your "group/" or "group/version" into
78+
hack/after-build/{update-generated-conversions.sh,
79+
update-generated-deep-copies.sh, verify-generated-conversions.sh,
80+
verify-generated-deep-copies.sh};
81+
2. Make sure your pkg/apis/`<group>`/`<version>` directory has a doc.go file
82+
with the comment `// +genconversion=true`, to catch the attention of our
83+
gen-conversion script.
6084
3. Run hack/update-all.sh.
6185

86+
6287
2. Generate files for Ugorji codec:
6388

6489
1. Touch types.generated.go in pkg/apis/`<group>`{/, `<version>`};
6590
2. Run hack/update-codecgen.sh.
6691

6792
### Client (optional):
6893

69-
We are overhauling pkg/client, so this section might be outdated; see [#15730](https://github.com/kubernetes/kubernetes/pull/15730) for how the client package might evolve. Currently, to add your group to the client package, you need to
94+
We are overhauling pkg/client, so this section might be outdated; see
95+
[#15730](https://github.com/kubernetes/kubernetes/pull/15730) for how the client
96+
package might evolve. Currently, to add your group to the client package, you
97+
need to:
7098

71-
1. Create pkg/client/unversioned/`<group>`.go, define a group client interface and implement the client. You can take pkg/client/unversioned/extensions.go as a reference.
99+
1. Create pkg/client/unversioned/`<group>`.go, define a group client interface
100+
and implement the client. You can take pkg/client/unversioned/extensions.go as a
101+
reference.
72102

73-
2. Add the group client interface to the `Interface` in pkg/client/unversioned/client.go and add method to fetch the interface. Again, you can take how we add the Extensions group there as an example.
103+
2. Add the group client interface to the `Interface` in
104+
pkg/client/unversioned/client.go and add method to fetch the interface. Again,
105+
you can take how we add the Extensions group there as an example.
74106

75-
3. If you need to support the group in kubectl, you'll also need to modify pkg/kubectl/cmd/util/factory.go.
107+
3. If you need to support the group in kubectl, you'll also need to modify
108+
pkg/kubectl/cmd/util/factory.go.
76109

77110
### Make the group/version selectable in unit tests (optional):
78111

79-
1. Add your group in pkg/api/testapi/testapi.go, then you can access the group in tests through testapi.`<group>`;
112+
1. Add your group in pkg/api/testapi/testapi.go, then you can access the group
113+
in tests through testapi.`<group>`;
80114

81-
2. Add your "group/version" to `KUBE_API_VERSIONS` and `KUBE_TEST_API_VERSIONS` in hack/test-go.sh.
115+
2. Add your "group/version" to `KUBE_API_VERSIONS` and `KUBE_TEST_API_VERSIONS`
116+
in hack/test-go.sh.
82117

83118
TODO: Add a troubleshooting section.
84119

0 commit comments

Comments
 (0)