-
Notifications
You must be signed in to change notification settings - Fork 121
Expand file tree
/
Copy pathMakefile
More file actions
132 lines (106 loc) · 4.83 KB
/
Makefile
File metadata and controls
132 lines (106 loc) · 4.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# To generate docs with make targets
# from this repo base directory,
# set the following environment variables
# to match your environment and release version
#
# K8S_WEBROOT=~/src/github.com/kubernetes/website
# K8S_ROOT=~/path/to/your/kubernetes/clone (REQUIRED)
# K8S_RELEASE=1.17.0, 1.17.5, 1.17.0-rc.2
#
# PREFERRED directory structure (follows Go workspace conventions):
# <work dir>/k8s.io/kubernetes <- Set K8S_ROOT to this path
# <work dir>/k8s.io/website
# <work dir>/k8s.io/reference-docs
#
# Examples:
# export K8S_ROOT=~/go/src/k8s.io/kubernetes
# export K8S_ROOT=~/workspace/k8s.io/kubernetes
# export K8S_ROOT=~/dev/kubernetes # any valid path works
WEBROOT=${K8S_WEBROOT}
# Validate K8S_ROOT is set and points to valid Kubernetes source
ifeq ($(K8S_ROOT),)
$(error K8S_ROOT environment variable is not set. Please set it to your Kubernetes clone path. Example: export K8S_ROOT=$GOPATH/src/k8s.io/kubernetes)
endif
K8SROOT=${K8S_ROOT}
# Verify K8S_ROOT points to a valid Kubernetes repository
ifeq ($(wildcard $(K8SROOT)/go.mod),)
$(error K8S_ROOT ($(K8SROOT)) does not appear to contain a valid Kubernetes repository. Please ensure it points to a Kubernetes source directory with go.mod file)
endif
K8SRELEASE=${K8S_RELEASE}
ifeq ($(K8SRELEASE),)
$(error Please define K8S_RELEASE, e.g. 'export K8S_RELEASE=1.21.0')
endif
ifeq ($(K8SROOT),)
$(error Please define K8S_ROOT, e.g. 'export K8S_ROOT=$GOPATH/src/k8s.io/kubernetes')
endif
ifeq ($(WEBROOT),)
$(error Please define K8S_WEBROOT, e.g. 'export K8S_WEBROOT=$GOPATH/src/k8s.io/website')
endif
K8SRELEASE_PREFIX=$(shell echo "$(K8SRELEASE)" | cut -c 1-4)
# create a directory name from release string, e.g. 1.17 -> 1_17
K8SRELEASEDIR=$(shell echo "$(K8SRELEASE_PREFIX)" | sed "s/\./_/g")
CLISRC=gen-kubectldocs/generators/build
CLIDST=$(WEBROOT)/static/docs/reference/generated/kubectl
CLISRCFONT=$(CLISRC)/node_modules/font-awesome
CLIDSTFONT=$(CLIDST)/node_modules/font-awesome
all:
@echo "Supported targets:\n\tcli api comp copycli copyapi createversiondirs genresources updateapispec configapi"
# create directories for new release
createversiondirs:
@echo "Calling set_version_dirs.sh"
./set_version_dirs.sh
@echo "K8S Release dir: $(K8SRELEASEDIR)"
# Build kubectl docs
cleancli:
sudo rm -f main
sudo rm -rf $(shell pwd)/gen-kubectldocs/generators/includes
sudo rm -rf $(shell pwd)/gen-kubectldocs/generators/build
sudo rm -rf $(shell pwd)/gen-kubectldocs/generators/manifest.json
cli: cleancli
cd gen-kubectldocs && go mod download && go run main.go --kubernetes-version v$(K8SRELEASEDIR)
mkdir -p $(CLISRC)
docker run -v $(shell pwd)/gen-kubectldocs/generators/includes:/source -v $(shell pwd)/gen-kubectldocs/generators/build:/build -v $(shell pwd)/gen-kubectldocs/generators/:/manifest brianpursley/brodocs:latest
copycli: cli
cp gen-kubectldocs/generators/build/index.html $(WEBROOT)/static/docs/reference/generated/kubectl/kubectl-commands.html
cp gen-kubectldocs/generators/build/navData.js $(WEBROOT)/static/docs/reference/generated/kubectl/navData.js
cp $(CLISRC)/scroll.js $(CLIDST)/scroll.js
cp $(CLISRC)/stylesheet.css $(CLIDST)/stylesheet.css
cp $(CLISRC)/tabvisibility.js $(CLIDST)/tabvisibility.js
cp $(CLISRC)/node_modules/bootstrap/dist/css/bootstrap.min.css $(CLIDST)/node_modules/bootstrap/dist/css/bootstrap.min.css
cp $(CLISRC)/node_modules/highlight.js/styles/default.css $(CLIDST)/node_modules/highlight.js/styles/default.css
cp $(CLISRC)/node_modules/jquery.scrollto/jquery.scrollTo.min.js $(CLIDST)/node_modules/jquery.scrollto/jquery.scrollTo.min.js
cp $(CLISRC)/node_modules/jquery/dist/jquery.min.js $(CLIDST)/node_modules/jquery/dist/jquery.min.js
cp $(CLISRCFONT)/css/font-awesome.min.css $(CLIDSTFONT)/css/font-awesome.min.css
cp -r $(CLISRCFONT)/fonts $(CLIDSTFONT)
# Build kube component,tool docs
cleancomp:
rm -rf $(shell pwd)/gen-compdocs/build
comp: cleancomp
make -C gen-compdocs
# Build API docs
APISRC=gen-apidocs
APIDST=$(WEBROOT)/static/docs/reference/generated/kubernetes-api/v$(K8SRELEASE_PREFIX)
updateapispec: createversiondirs
CURDIR=$(shell pwd)
@echo "Updating swagger.json for release v$(K8SRELEASE)"
cd $(K8SROOT) && git show "v$(K8SRELEASE):api/openapi-spec/swagger.json" > $(CURDIR)/$(APISRC)/config/v$(K8SRELEASEDIR)/swagger.json
api: cleanapi
cd $(APISRC) && go run main.go --kubernetes-release=$(K8SRELEASE_PREFIX) --work-dir=.
cleanapi:
rm -rf $(shell pwd)/gen-apidocs/build
copyapi: api
mkdir -p $(APIDST)
cp $(APISRC)/build/index.html $(APIDST)/index.html
# copy the new navData.js
mkdir -p $(APIDST)/js
cp $(APISRC)/build/navData.js $(APIDST)/js/
# Build resource reference
genresources:
make -C gen-resourcesdocs kwebsite
# Build config API reference
CONFIGSRC=genref/output/md
CONFIGDST=$(WEBROOT)/content/en/docs/reference/config-api/
configapi:
make -C genref
copyconfigapi: configapi
cp $(CONFIGSRC)/*.md $(CONFIGDST)/