Skip to content

Commit

Permalink
Merge pull request #1131 from salasberryfin/netlify-config-for-book
Browse files Browse the repository at this point in the history
docs: basic netlify configuration for book
  • Loading branch information
k8s-ci-robot authored Feb 10, 2024
2 parents 9788374 + b63fdd2 commit 273a0d9
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 0 deletions.
43 changes: 43 additions & 0 deletions docs/book/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2024 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.

# Directories.
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
TOOLS_DIR := $(realpath ../../hack/tools)
TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
BIN_DIR := bin
MDBOOK_INSTALL := $(realpath ../../scripts/ci-install-mdbook.sh)
TABULATE := $(TOOLS_BIN_DIR)/mdbook-tabulate
EMBED := $(TOOLS_BIN_DIR)/mdbook-embed
RELEASELINK := $(TOOLS_BIN_DIR)/mdbook-releaselink
MDBOOK := $(TOOLS_BIN_DIR)/mdbook

export PATH := $(TOOLS_BIN_DIR):$(PATH)

BOOK_DEPS := $(MDBOOK) $(TABULATE) $(EMBED) $(RELEASELINK)

$(TOOLS_BIN_DIR)/%: $(TOOLS_DIR_DEPS)
make -C $(TOOLS_DIR) $(subst $(TOOLS_DIR)/,,$@)

.PHONY: serve
serve: $(BOOK_DEPS) ## Run a local web server with the compiled book
$(MDBOOK) serve

.PHONY: build
build: $(BOOK_DEPS) ## Build the book
$(MDBOOK) build

.PHONY: clean
clean:
rm -rf book
69 changes: 69 additions & 0 deletions hack/tools/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright 2024 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.

ROOT_DIR_RELATIVE := ../..

UNAME := $(shell uname -s)

OS := $(shell go env GOOS)
RUST_TARGET := unknown-$(OS)-gnu

ifeq ($(OS), darwin)
RUST_TARGET := apple-darwin
GH_ARCH_SUFFIX := macOS_amd64
GTAR := gtar
endif

# Directories.
BIN_DIR := bin
BIN_DIR_ABS := $(abspath $(BIN_DIR))
SHARE_DIR := share

MDBOOK_EXTRACT_COMMAND := tar xfvz $(SHARE_DIR)/mdbook.tar.gz -C bin
MDBOOK_ARCHIVE_EXT := .tar.gz

MDBOOK_VERSION := v0.4.5

# Tooling binaries.
$(BIN_DIR):
mkdir -p $@

$(SHARE_DIR):
mkdir -p $@

# Binaries.
MDBOOK := $(BIN_DIR)/mdbook
MDBOOK_SHARE := $(SHARE_DIR)/mdbook$(MDBOOK_ARCHIVE_EXT)
$(MDBOOK): $(BIN_DIR) $(SHARE_DIR)
curl -sL -o $(MDBOOK_SHARE) "https://github.com/rust-lang/mdBook/releases/download/$(MDBOOK_VERSION)/mdBook-$(MDBOOK_VERSION)-x86_64-$(RUST_TARGET)$(MDBOOK_ARCHIVE_EXT)"
$(MDBOOK_EXTRACT_COMMAND)
chmod +x $@
touch -m $@

MDBOOK_EMBED := $(BIN_DIR)/mdbook-embed
$(MDBOOK_EMBED): $(BIN_DIR) go.mod go.sum
go build -tags=tools -o $(BIN_DIR)/mdbook-embed sigs.k8s.io/cluster-api/hack/tools/mdbook/embed

MDBOOK_RELEASELINK := $(BIN_DIR)/mdbook-releaselink
$(MDBOOK_RELEASELINK): $(BIN_DIR) go.mod go.sum
go build -tags=tools -o $(BIN_DIR)/mdbook-releaselink sigs.k8s.io/cluster-api/hack/tools/mdbook/releaselink

MDBOOK_TABULATE := $(BIN_DIR)/mdbook-tabulate
$(MDBOOK_TABULATE): $(BIN_DIR) go.mod go.sum
go build -tags=tools -o $(BIN_DIR)/mdbook-tabulate sigs.k8s.io/cluster-api/hack/tools/mdbook/tabulate

.PHONY: clean
clean: ## Remove all tools
rm -rf bin
rm -rf share
5 changes: 5 additions & 0 deletions hack/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ go 1.21

toolchain go1.21.6

replace sigs.k8s.io/cluster-api => sigs.k8s.io/cluster-api v1.6.1

require sigs.k8s.io/cluster-api/hack/tools v0.0.0-20240116064735-bfe8d0d16ff3

require (
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/gofuzz v1.2.0 // indirect
Expand All @@ -26,7 +29,9 @@ require (
k8s.io/apimachinery v0.28.5 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/utils v0.0.0-20231127182322-b307cd553661 // indirect
sigs.k8s.io/cluster-api v0.0.0-00010101000000-000000000000 // indirect
sigs.k8s.io/controller-tools v0.13.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kubebuilder/docs/book/utils v0.0.0-20211028165026-57688c578b5d // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
)
6 changes: 6 additions & 0 deletions hack/tools/go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
Expand Down Expand Up @@ -106,12 +108,16 @@ k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg=
k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
k8s.io/utils v0.0.0-20231127182322-b307cd553661 h1:FepOBzJ0GXm8t0su67ln2wAZjbQ6RxQGZDnzuLcrUTI=
k8s.io/utils v0.0.0-20231127182322-b307cd553661/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
sigs.k8s.io/cluster-api v1.6.1 h1:I34p/fwgRlEhs+o9cUhKXDwNNfPS3no0yJsd2bJyQVc=
sigs.k8s.io/cluster-api v1.6.1/go.mod h1:DaxwruDvSaEYq5q6FREDaGzX6UsAVUCA99Sp8vfMHyQ=
sigs.k8s.io/cluster-api/hack/tools v0.0.0-20240116064735-bfe8d0d16ff3 h1:pbVMlqGtkJvCBYntRFIEsvOIGzoTTJtjW1hBEoZMSYk=
sigs.k8s.io/cluster-api/hack/tools v0.0.0-20240116064735-bfe8d0d16ff3/go.mod h1:1p1NPNOaoJmhqeNiXzNvRMOEFSdJhOwSJtSyfwigFMA=
sigs.k8s.io/controller-tools v0.13.0 h1:NfrvuZ4bxyolhDBt/rCZhDnx3M2hzlhgo5n3Iv2RykI=
sigs.k8s.io/controller-tools v0.13.0/go.mod h1:5vw3En2NazbejQGCeWKRrE7q4P+CW8/klfVqP8QZkgA=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/kubebuilder/docs/book/utils v0.0.0-20211028165026-57688c578b5d h1:KLiQzLW3RZJR19+j4pw2h5iioyAyqCkDBEAFdnGa3N8=
sigs.k8s.io/kubebuilder/docs/book/utils v0.0.0-20211028165026-57688c578b5d/go.mod h1:NRdZafr4zSCseLQggdvIMXa7umxf+Q+PJzrj3wFwiGE=
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE=
sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
Expand Down
2 changes: 2 additions & 0 deletions hack/tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ package tools

import (
_ "sigs.k8s.io/cluster-api/hack/tools/conversion-verifier"
_ "sigs.k8s.io/cluster-api/hack/tools/mdbook/embed"
_ "sigs.k8s.io/cluster-api/hack/tools/mdbook/releaselink"
)
27 changes: 27 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Netlify build instructions
[build]
command = "make -C docs/book build"
publish = "docs/book/book"

[build.environment]
GO_VERSION = "1.21"

# Standard Netlify redirects
[[redirects]]
from = "https://main--cluster-api-gcp.netlify.com/*"
to = "https://main.cluster-api-gcp.sigs.k8s.io/:splat"
status = 301
force = true

# HTTP-to-HTTPS rules
[[redirects]]
from = "http://main.cluster-api-gcp.sigs.k8s.io/*"
to = "https://main.cluster-api-gcp.sigs.k8s.io/:splat"
status = 301
force = true

[[redirects]]
from = "http://main--cluster-api-gcp.netlify.com/*"
to = "http://main.cluster-api-gcp.sigs.k8s.io/:splat"
status = 301
force = true

0 comments on commit 273a0d9

Please sign in to comment.