clean up makefile, config (#18517)

Added target for createversiondirs (shell script) in Makefile.

updates for tagged release

regenerate api ref, rm Makefile_temp

add parens to pip check
This commit is contained in:
Karen Bradshaw
2020-01-30 19:40:20 -05:00
committed by GitHub
parent f5e63a268c
commit 694815d454
5 changed files with 88 additions and 217 deletions
-128
View File
@@ -1,128 +0,0 @@
WEBROOT=${K8S_WEBROOT}
K8SROOT=${K8S_ROOT}
K8SRELEASE=${K8S_RELEASE}
# change <major>.<minor> to <major>_<minor>
getversion:
echo $(K8SRELEASE) | sed "s/\./_/g" > b.tmp
K8SVERDIR=$(shell cat b.tmp)
sepversion: getversion
echo $(K8SVERDIR) | sed "s/[0-9]_//g" > minor.tmp
echo $(K8SVERDIR) | sed "s/_[0-9]*//g" > major.tmp
MINOR_VERSION := $(shell cat minor.tmp)
MAJOR_VERSION := $(shell cat major.tmp)
ONE := 1
PREV_MINOR_VERSION := $(shell echo $$(( $(MINOR_VERSION) - $(ONE) )))
cleantmp:
rm minor.tmp; rm major.tmp; rm b.tmp
APISRC=gen-apidocs
APIDST=$(WEBROOT)/static/docs/reference/generated/kubernetes-api/v$(K8SRELEASE)
CLISRC=gen-kubectldocs/generators/build
CLIDST=$(WEBROOT)/static/docs/reference/generated/kubectl
CLISRCFONT=$(CLISRC)/node_modules/font-awesome
CLIDSTFONT=$(CLIDST)/node_modules/font-awesome
default:
@echo "Support commands:\ncli api comp copycli copyapi updateapispec"
# Set up versioned directories for new release
# kubectl-command static-includes, toc.yaml
createkubectldir: sepversion
@echo version $(K8SVERDIR)
mkdir -p $(shell pwd)/gen-kubectldocs/generators/v$(K8SVERDIR)
if ! [ -f "$(shell pwd)/gen-kubectldocs/generators/v1_$(PREV_MINOR_VERSION)/config.yaml" ]; then \
cp -r $(shell pwd)/gen-kubectldocs/generators/v1_15/* $(shell pwd)/gen-kubectldocs/generators/v$(K8SVERDIR)/; \
else \
cp -r $(shell pwd)/gen-kubectldocs/generators/v1_$(PREV_MINOR_VERSION)/* $(shell pwd)/gen-kubectldocs/generators/v$(K8SVERDIR)/; \
fi
# api-ref versioned dir, swagger.json, config.yaml
createapidir: sepversion
@echo version $(K8SVERDIR)
mkdir -p $(shell pwd)/gen-apidocs/config/v$(K8SVERDIR)
# config.yaml
if ! [ -f "$(APISRC)/config/v1_$(MINOR_VERSION)/config.yaml" ]; then \
if [ -f "$(shell pwd)/gen-apidocs/config/v1_$(PREV_MINOR_VERSION)/config.yaml" ]; then \
cp $(shell pwd)/gen-apidocs/config/v1_$(PREV_MINOR_VERSION)/config.yaml $(APISRC)/config/v1_$(MINOR_VERSION)/config.yaml; \
echo "Using config file: $(shell pwd)/gen-apidocs/config/v1_$(PREV_MINOR_VERSION)/config.yaml"; \
else \
cp $(APISRC)/config/config.yaml $(APISRC)/config/v1_$(MINOR_VERSION)/config.yaml; \
fi \
fi
# swagger.json
if ! [ -f "$(APISRC)/config/v1_$(MINOR_VERSION)/swagger.json" ]; then \
cp $(K8SROOT)/api/openapi-spec/swagger.json $(APISRC)/config/v1_$(MINOR_VERSION)/swagger.json; \
fi
# copy versioned files to the base config dir before generating api ref
stageapifiles: createapidir
cp $(APISRC)/config/v1_$(MINOR_VERSION)/config.yaml $(APISRC)/config/config.yaml
cp $(APISRC)/config/v1_$(MINOR_VERSION)/swagger.json $(APISRC)/config/swagger.json
# 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: createkubectldir cleancli
go run gen-kubectldocs/main.go --kubernetes-version v1_$(MINOR_VERSION)
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 pwittrock/brodocs
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
# Build kube component,tool docs
cleancomp:
rm -rf $(shell pwd)/gen-compdocs/build
comp: cleancomp
mkdir -p gen-compdocs/build
go run gen-compdocs/main.go gen-compdocs/build kube-apiserver
go run gen-compdocs/main.go gen-compdocs/build kube-controller-manager
go run gen-compdocs/main.go gen-compdocs/build cloud-controller-manager
go run gen-compdocs/main.go gen-compdocs/build kube-scheduler
go run gen-compdocs/main.go gen-compdocs/build kubelet
go run gen-compdocs/main.go gen-compdocs/build kube-proxy
go run gen-compdocs/main.go gen-compdocs/build kubeadm
go run gen-compdocs/main.go gen-compdocs/build kubectl
# Build api docs
updateapispec:
cp $(K8SROOT)/api/openapi-spec/swagger.json gen-apidocs/config/swagger.json
api: cleanapi stageapifiles
go run gen-apidocs/main.go --work-dir=gen-apidocs --munge-groups=false
cleanapi:
rm -rf $(shell pwd)/gen-apidocs/build
copyapi: api
mkdir -p $(APIDST)
cp $(APISRC)/build/index.html $(APIDST)/index.html
# copy scroll.js, jquery.scrollTo.min.js and the new navData.js
mkdir -p $(APIDST)/js
cp $(APISRC)/build/navData.js $(APIDST)/js/
cp $(APISRC)/static/js/* $(APIDST)/js/
# copy stylesheet.css, bootstrap.min.css, font-awesome.min.css
mkdir -p $(APIDST)/css
cp $(APISRC)/static/css/* $(APIDST)/css/
# copy fonts data
mkdir -p $(APIDST)/fonts
cp $(APISRC)/static/fonts/* $(APIDST)/fonts/
+4 -5
View File
@@ -8,7 +8,8 @@ repos:
cd $GOPATH
git clone https://github.com/kubernetes/kubernetes.git src/k8s.io/kubernetes
cd src/k8s.io/kubernetes
git checkout release-${K8S_RELEASE}
# set the branch, ex: v1.17.0
git checkout v${K8S_RELEASE}.0
make generated_files
cp -L -R vendor $GOPATH/src
rm -r vendor/github.com/spf13/cobra
@@ -21,12 +22,10 @@ repos:
cd $GOPATH
go get -v github.com/kubernetes-sigs/reference-docs/gen-kubectldocs
cd src/github.com/kubernetes-sigs/reference-docs/
cp ${K8S_WEBROOT}/update-imported-docs/Makefile_temp ./Makefile
# testing
make sepversion
# create versioned dirs if needed and fetch v${K8S_RELEASE}.0:swagger.json
make updateapispec
# generate kubectl cmd reference
make copycli
#
# generate api reference
cd $GOPATH
rm -rf src/vendor
+3 -3
View File
@@ -37,7 +37,7 @@ import tempfile
error_msgs = []
# pip should be installed when Python is installed, but just in case...
if not shutil.which('pip'):
if not (shutil.which('pip') or shutil.which('pip3')):
error_msgs.append("Install pip so you can install PyYAML. https://pip.pypa.io/en/stable/installing")
reqs = subprocess.check_output([sys.executable, '-m', 'pip', 'freeze'])
@@ -184,9 +184,9 @@ def main():
# second parse input argument
k8s_release = in_args.k8s_release
print("ks8_release is {}".format(k8s_release))
print("k8s_release is {}".format(k8s_release))
curr_dir = os.path.dirname(__file__)
curr_dir = os.path.dirname(os.path.abspath(__file__))
print("curr_dir {}".format(curr_dir))
root_dir = os.path.realpath(os.path.join(curr_dir, '..'))
print("root_dir {}".format(root_dir))