Skip to content

Commit 68abac1

Browse files
authored
🐛: sync kb binary from source code for docs (#3520)
fix: sync kb binary from source code for docs
1 parent e0dfbee commit 68abac1

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ generate-testdata: ## Update/generate the testdata in $GOPATH/src/sigs.k8s.io/ku
7373

7474
.PHONY: generate-docs
7575
generate-docs: ## Update/generate the docs in $GOPATH/src/sigs.k8s.io/kubebuilder
76-
go run hack/docs/generate_samples.go
76+
./hack/docs/generate.sh
7777

7878
.PHONY: check-docs
7979
check-docs: ## Run the script to ensure that the docs are updated

hack/docs/check.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
source "$(dirname "$0")/../../test/common.sh"
18-
19-
build_kb
20-
2117
check_directory="$(dirname "$0")/../../docs/book/src/"
2218

2319
# Check docs directory first. If there are any uncommitted change, fail the test.
@@ -27,7 +23,8 @@ if [[ $(git status ${check_directory} --porcelain) ]]; then
2723
exit 1
2824
fi
2925

30-
make generate-docs
26+
27+
$(dirname "$0")/generate.sh
3128

3229
# Check if there are any changes to files under testdata directory.
3330
if [[ $(git status ${check_directory} --porcelain) ]]; then

hack/docs/generate.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2023 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+
source "$(dirname "$0")/../../test/common.sh"
18+
19+
build_kb
20+
21+
docs_gen_directory="$(dirname "$0")/../../hack/docs/generate_samples.go"
22+
go run ${docs_gen_directory}
23+

hack/docs/generate_samples.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ import (
2121

2222
componentconfig "sigs.k8s.io/kubebuilder/v3/hack/docs/internal/component-config-tutorial"
2323
cronjob "sigs.k8s.io/kubebuilder/v3/hack/docs/internal/cronjob-tutorial"
24-
"sigs.k8s.io/kubebuilder/v3/pkg/plugin/util"
2524
)
2625

26+
// Make sure executing `build_kb` to generate kb executable from the source code
27+
const KubebuilderBinName = "/tmp/kubebuilder/bin/kubebuilder"
28+
2729
func main() {
2830
fmt.Println("Generating documents...")
2931

@@ -36,7 +38,7 @@ func main() {
3638
}
3739

3840
func UpdateComponentConfigTutorial() {
39-
binaryPath := util.KubebuilderBinName
41+
binaryPath := KubebuilderBinName
4042
samplePath := "docs/book/src/component-config-tutorial/testdata/project/"
4143

4244
sp := componentconfig.NewSample(binaryPath, samplePath)
@@ -51,7 +53,7 @@ func UpdateComponentConfigTutorial() {
5153
}
5254

5355
func UpdateCronjobTutorial() {
54-
binaryPath := util.KubebuilderBinName
56+
binaryPath := KubebuilderBinName
5557
samplePath := "docs/book/src/cronjob-tutorial/testdata/project/"
5658

5759
sp := cronjob.NewSample(binaryPath, samplePath)

0 commit comments

Comments
 (0)