Skip to content

Commit

Permalink
馃悰: sync kb binary from source code for docs (#3520)
Browse files Browse the repository at this point in the history
fix: sync kb binary from source code for docs
  • Loading branch information
Kavinjsir committed Aug 15, 2023
1 parent e0dfbee commit 68abac1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
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

0 comments on commit 68abac1

Please sign in to comment.