Permalink
Browse files

Add mkdocs support to build/cmd.sh

  • Loading branch information...
ivan4th committed Jan 24, 2019
1 parent d2218b1 commit 98711e51bd61772a3ea2af0572709e316491e15c
Showing with 97 additions and 15 deletions.
  1. +3 −0 .gitignore
  2. +75 −11 build/cmd.sh
  3. +1 −0 docs/docs/reference/config.md
  4. +13 −0 docs/docs/reference/virtletctl.md
  5. +1 −1 images/Dockerfile.build
  6. +4 −3 images/Dockerfile.build-base
@@ -76,3 +76,6 @@ test-driver

# build output
_output

# build docs output
_docs
@@ -16,6 +16,7 @@ FORCE_UPDATE_IMAGE="${FORCE_UPDATE_IMAGE:-}"
IMAGE_REGEXP_TRANSLATION="${IMAGE_REGEXP_TRANSLATION:-1}"
GH_RELEASE_TEST_USER="ivan4th"
DIND_CRI="${DIND_CRI:-containerd}"
MKDOCS_SERVE_ADDRESS="${MKDOCS_SERVE_ADDRESS:-localhost:8042}"

# Note that project_dir must not end with slash
project_dir="$(cd "$(dirname "${BASH_SOURCE}")/.." && pwd)"
@@ -178,6 +179,7 @@ function ensure_build_container {
-e VIRTLET_ON_MASTER="${VIRTLET_ON_MASTER:-}" \
-e VIRTLET_MULTI_NODE="${VIRTLET_MULTI_NODE:-}" \
-e GITHUB_TOKEN="${GITHUB_TOKEN:-}" \
-e MKDOCS_SERVE_ADDRESS="${MKDOCS_SERVE_ADDRESS:-}" \
${docker_cert_args[@]+"${docker_cert_args[@]}"} \
--name virtlet-build \
--tmpfs /tmp \
@@ -208,7 +210,7 @@ function vsh {
docker exec -it virtlet-build env TERM=xterm bash
}

function vcmd {
function sync_source {
ensure_build_container
cd "${project_dir}"
if [[ ! ${VIRTLET_SKIP_RSYNC} ]]; then
@@ -224,7 +226,15 @@ function vcmd {
-a --delete --compress-level=9 \
"${project_dir}/" "rsync://virtlet@${RSYNC_ADDR}/virtlet/"
fi
docker exec -i virtlet-build bash -c "$*"
}

function vcmd {
sync_source
local t=""
if [[ ${USE_TERM:-} ]]; then
t="t"
fi
docker exec -i"${t}" virtlet-build bash -c "$*"
}

function vcmd_simple {
@@ -507,17 +517,17 @@ function update_bindata_internal {
go-bindata -mode 0644 -modtime "${bindata_modtime}" -o "${bindata_out}" -pkg "${bindata_pkg}" "${bindata_dir}"
}

function update_docs_internal {
function update_generated_docs_internal {
if [[ ! -f _output/virtletctl ]]; then
echo >&2 "Please run build/cmd.sh build first"
fi
_output/virtletctl gendoc docs
virtletctl gendoc docs/docs/reference
tempfile="$(tempfile)"
_output/virtletctl gendoc --config >"${tempfile}"
sed -i "/<!-- begin -->/,/<!-- end -->/{
//!d
/begin/r ${tempfile}
}" docs/config.md
}" docs/docs/reference/config.md
rm -f "${tempfile}"
}

@@ -533,6 +543,43 @@ function update_generated_internal {
'{}' \;
}

function serve_docs_internal {
(cd docs && mkdocs serve -a "${MKDOCS_SERVE_ADDRESS}")
}

function build_docs_internal {
site_dir="$(mktemp -d)"
trap 'rm -rf "${site_dir}"' EXIT
(cd docs && mkdocs build -d "${site_dir}")
tar -C "${site_dir}" -c .
}

function build_docs {
cd "${project_dir}"
rm -rf _docs
git clone -b gh-pages . _docs
local docs_hash="$(git ls-tree HEAD -- docs | awk '{print $3}')"
if [[ ! -e _docs/source_hash || ${docs_hash} != $(cat _docs/source_hash) ]]; then
echo >&2 "docs/ directory changed since the last doc build, rebuilding docs"
elif [[ $(git status --porcelain) ]]; then
echo >&2 "Source directory dirty, rebuilding docs"
else
echo >&2 "Docs unchanged, no need to rebuild"
return 0
fi
# clean up _docs except for .git and CNAME
find _docs -name .git -prune -o -type f \! -name CNAME -exec rm -f '{}' \;
vcmd "build/cmd.sh build-docs-internal" | tar -C _docs -xv
echo "${docs_hash}" > _docs/source_hash
(
cd _docs
git add .
git commit -m "Update generated docs"
# this pushes the changes into the local repo (not github!)
git push origin gh-pages
)
}

function usage {
echo >&2 "Usage:"
echo >&2 " $0 build"
@@ -544,11 +591,13 @@ function usage {
echo >&2 " $0 stop"
echo >&2 " $0 clean"
echo >&2 " $0 update-bindata"
echo >&2 " $0 update-docs"
echo >&2 " $0 update-generated-docs"
echo >&2 " $0 gotest [TEST_ARGS...]"
echo >&2 " $0 gobuild [BUILD_ARGS...]"
echo >&2 " $0 run CMD..."
echo >&2 " $0 release TAG"
echo >&2 " $0 serve-docs"
echo >&2 " $0 sync"
exit 1
}

@@ -608,12 +657,12 @@ case "${cmd}" in
update-generated-internal)
update_generated_internal
;;
update-docs)
vcmd "build/cmd.sh update-docs-internal"
docker exec virtlet-build tar -C "${remote_project_dir}" -c docs/config.md docs/virtletctl.md | tar -C "${project_dir}" -xv
update-generated-docs)
vcmd "build/cmd.sh update-generated-docs-internal"
docker exec virtlet-build tar -C "${remote_project_dir}" -c docs/docs/reference/config.md docs/docs/reference/virtletctl.md | tar -C "${project_dir}" -xv
;;
update-docs-internal)
update_docs_internal
update-generated-docs-internal)
update_generated_docs_internal
;;
run)
vcmd "$*"
@@ -667,6 +716,21 @@ case "${cmd}" in
release-internal)
release_internal "$@"
;;
serve-docs-internal)
serve_docs_internal
;;
serve-docs)
( USE_TERM=1 vcmd "build/cmd.sh serve-docs-internal" )
;;
build-docs-internal)
build_docs_internal
;;
build-docs)
build_docs
;;
sync)
sync_source
;;
*)
usage
;;
@@ -89,6 +89,7 @@ standard Virtlet deployment YAML as generated by `virtletctl gen`.
| Enable regexp image name translation | `enableRegexpImageTranslation` | `true` | boolean | `--enable-regexp-image-translation` / `IMAGE_REGEXP_TRANSLATION` |
| CPU model to use in libvirt domain definition (libvirt's default value will be used if not set) | `cpuModel` | | string | `--cpu-model` / `VIRTLET_CPU_MODEL` |
| configurable port to the virtlet server | `streamPort` | `10010` | integer | `--stream-port` / `VIRTLET_STREAM_PORT` |
| Pod's root dir in kubelet | `kubeletRootDir` | `/var/lib/kubelet/pods` | string | `--kubelet-root-dir` / `KUBELET_ROOT_DIR` |
| Log level to use | `logLevel` | `1` | integer | `--v` / `VIRTLET_LOGLEVEL` |
<!-- end -->

@@ -16,6 +16,7 @@ Kubernetes cluster.
* [virtletctl gendoc](#virtletctl-gendoc) - Generate Markdown documentation for the commands
* [virtletctl install](#virtletctl-install) - Install virtletctl as a kubectl plugin
* [virtletctl ssh](#virtletctl-ssh) - Connect to a VM pod using ssh
* [virtletctl validate](#virtletctl-validate) - Make sure the cluster is ready for Virtlet deployment
* [virtletctl version](#virtletctl-version) - Display Virtlet version information
* [virtletctl virsh](#virtletctl-virsh) - Execute a virsh command
* [virtletctl vnc](#virtletctl-vnc) - Provide access to the VNC console of a VM pod
@@ -170,6 +171,18 @@ This command runs ssh and makes it connect to a VM pod.
virtletctl ssh [flags] user@pod -- [ssh args...]
```

## virtletctl validate

Make sure the cluster is ready for Virtlet deployment

**Synopsis**

Check configuration of the cluster nodes to make sure they're ready for Virtlet deployment

```
virtletctl validate [flags]
```

## virtletctl version

Display Virtlet version information
@@ -1,7 +1,7 @@
# TODO: generate this tag. unfortunately can't use ARG:
# https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
# (but add a note about it here for the future)
FROM mirantis/virtlet-build:v1-7513b921832f1162f75b8df32e2a54e6
FROM mirantis/virtlet-build:v1-a41085a8556b19927a08548c91d3f1bb
MAINTAINER Ivan Shvedunov <ishvedunov@mirantis.com>

LABEL virtlet.image="build"
@@ -23,7 +23,6 @@ ENV GOLANG_DOWNLOAD_SHA256 fa1b0e45d3b647c252f51f5e1204aba049cde4af177ef9f2181f4

ENV CIRROS_SHA256 fcd9e9a622835de8dba6b546481d13599b1e592bba1275219e1b31cae33b1365

# build container should be able to run libvirt because it's used for integration tests
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
git \
@@ -35,8 +34,10 @@ RUN apt-get update && \
tcpdump \
iputils-ping \
mercurial \
pkg-config && \
apt-get clean
pkg-config \
python-pip && \
apt-get clean && \
pip install mkdocs

# Install docker client
RUN mkdir -p /usr/local/bin && \

0 comments on commit 98711e5

Please sign in to comment.