Skip to content

Commit 0403dd0

Browse files
author
Phillip Wittrock
authored
Merge pull request #14 from pwittrock/master
Support generating docs in kubebuilder
2 parents a540df7 + 6d0f20b commit 0403dd0

File tree

15 files changed

+507
-331
lines changed

15 files changed

+507
-331
lines changed

build/apiserverbuilder/Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright 2018 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Build an image containing apiserver-builder for generating docs
16+
17+
FROM golang:1.10-stretch
18+
19+
ENV URL https://github.com/kubernetes-incubator/apiserver-builder/releases/download/v1.9-alpha.2
20+
ENV BIN apiserver-builder-v1.9-alpha.2-linux-amd64.tar.gz
21+
ENV DEST /usr/local/apiserver-builder/bin/
22+
RUN curl -L $URL/$BIN -o /tmp/$BIN
23+
RUN mkdir -p /usr/local/apiserver-builder
24+
RUN tar -xzvf /tmp/$BIN -C /usr/local/apiserver-builder/
25+
26+
ENV PATH /usr/local/apiserver-builder/bin/:$PATH
27+
28+
RUN apt-get update
29+
RUN apt-get install less -y
30+
RUN apt-get install nano -yu
31+
32+
COPY docs.sh /usr/local/bin/docs.sh
33+
34+
CMD docs.sh

build/apiserverbuilder/docs.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2018 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
set -x
19+
20+
# Copy over the files from the host repo
21+
export D=$DIR/$OUTPUT
22+
mkdir -p $D
23+
24+
# Copy the api definitions
25+
cp -r /host/repo/pkg $DIR/pkg
26+
27+
# Copy the docs
28+
if [ -d "/host/repo/$OUTPUT" ]; then
29+
cp -r /host/repo/$OUTPUT/* $D
30+
fi
31+
if [ ! -d "$DIR/boilerplate.go.txt" ]; then
32+
touch $DIR/boilerplate.go.txt
33+
else
34+
cp /host/repo/boilerplate.go.txt $DIR/boilerplate.go.txt
35+
fi
36+
37+
cd $DIR
38+
39+
# Generate the artifacts
40+
apiserver-boot init repo --domain $DOMAIN
41+
apiserver-boot build generated clean
42+
apiserver-boot build generated
43+
44+
# Generate the input .md files for the docs
45+
go build -o bin/apiserver cmd/apiserver/main.go
46+
bin/apiserver --etcd-servers=http://localhost:2379 --secure-port=9443 --print-openapi --delegated-auth=false > $OUTPUT/openapi-spec/swagger.json
47+
gen-apidocs --build-operations=false --use-tags=false --allow-errors --config-dir=$OUTPUT
48+
49+
# Copy the input files to the host
50+
if [ ! -d "/host/repo/$OUTPUT" ]; then
51+
mkdir -p /host/repo/$OUTPUT
52+
fi
53+
cp -r $OUTPUT/* /host/repo/$OUTPUT

build/test.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
#!/usr/bin/env bash
22

3+
# Copyright 2018 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
317
cp -r /workspace/_output/kubebuilder /tmp/kubebuilder/
418

519
# Tests won't work on darwin

build/thirdparty/darwin/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2018 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
# Build the following into binaries for darwin and then host them in a tar.gz file in an alpine image
216
# - apiserver
317
# - kubectl

build/thirdparty/linux/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright 2018 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
# Build the following into binaries for linux and then host them in a tar.gz file in an alpine image
216
# - apiserver
317
# - kubectl

cmd/kubebuilder/build/build.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,29 @@ package build
1818

1919
import (
2020
"github.com/spf13/cobra"
21+
"github.com/kubernetes-sigs/kubebuilder/cmd/kubebuilder/docs"
22+
"github.com/kubernetes-sigs/kubebuilder/cmd/kubebuilder/generate"
2123
)
2224

2325
var buildCmd = &cobra.Command{
2426
Use: "build",
2527
Short: "Command group for building source into artifacts.",
2628
Long: `Command group for building source into artifacts.`,
2729
Example: `# Generate code and build the apiserver and controller-manager binaries into bin/
28-
kubebuilder build executables
30+
kubebuilder build docs
2931
3032
# Rebuild generated code
3133
kubebuilder build generated
3234
`,
3335
Run: RunBuild,
36+
Deprecated: "`build generated` and `build docs` have been moved to `generate` and `docs`",
3437
}
3538

3639
func AddBuild(cmd *cobra.Command) {
3740
cmd.AddCommand(buildCmd)
3841

39-
AddBuildExecutables(buildCmd)
40-
// AddBuildContainer(buildCmd)
41-
AddDocs(buildCmd)
42-
AddGenerate(buildCmd)
42+
buildCmd.AddCommand(docs.GetDocs())
43+
buildCmd.AddCommand(generate.GetGenerate())
4344
}
4445

4546
func RunBuild(cmd *cobra.Command, args []string) {

cmd/kubebuilder/build/build_executables.go

Lines changed: 0 additions & 99 deletions
This file was deleted.

0 commit comments

Comments
 (0)