Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛: sync kb binary from source code for docs #3520

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ generate-testdata: ## Update/generate the testdata in $GOPATH/src/sigs.k8s.io/ku

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

.PHONY: check-docs
check-docs: ## Run the script to ensure that the docs are updated
Expand Down
7 changes: 2 additions & 5 deletions hack/docs/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

source "$(dirname "$0")/../../test/common.sh"

build_kb

check_directory="$(dirname "$0")/../../docs/book/src/"

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

make generate-docs

$(dirname "$0")/generate.sh

# Check if there are any changes to files under testdata directory.
if [[ $(git status ${check_directory} --porcelain) ]]; then
Expand Down
23 changes: 23 additions & 0 deletions hack/docs/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# Copyright 2023 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

source "$(dirname "$0")/../../test/common.sh"

build_kb

docs_gen_directory="$(dirname "$0")/../../hack/docs/generate_samples.go"
go run ${docs_gen_directory}

8 changes: 5 additions & 3 deletions hack/docs/generate_samples.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ import (

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

// Make sure executing `build_kb` to generate kb executable from the source code
const KubebuilderBinName = "/tmp/kubebuilder/bin/kubebuilder"

func main() {
fmt.Println("Generating documents...")

Expand All @@ -36,7 +38,7 @@ func main() {
}

func UpdateComponentConfigTutorial() {
binaryPath := util.KubebuilderBinName
binaryPath := KubebuilderBinName
samplePath := "docs/book/src/component-config-tutorial/testdata/project/"

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

func UpdateCronjobTutorial() {
binaryPath := util.KubebuilderBinName
binaryPath := KubebuilderBinName
samplePath := "docs/book/src/cronjob-tutorial/testdata/project/"

sp := cronjob.NewSample(binaryPath, samplePath)
Expand Down
Loading