Skip to content

Commit

Permalink
add versioned docs (#1645)
Browse files Browse the repository at this point in the history
  • Loading branch information
sozercan authored Nov 9, 2021
1 parent 87cb662 commit 2047863
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 22 deletions.
46 changes: 29 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ KUSTOMIZE_VERSION ?= 3.8.9
BATS_VERSION ?= 1.2.1
BATS_TESTS_FILE ?= test/bats/test.bats
HELM_VERSION ?= 3.4.2
NODE_VERSION ?= 16-bullseye-slim

HELM_ARGS ?=
GATEKEEPER_NAMESPACE ?= gatekeeper-system

Expand Down Expand Up @@ -189,8 +191,8 @@ run: generate manifests
# Install CRDs into a cluster
install: manifests
docker run -v $(shell pwd)/config:/config -v $(shell pwd)/vendor:/vendor \
k8s.gcr.io/kustomize/kustomize:v${KUSTOMIZE_VERSION} build \
/config/crd | kubectl apply -f -
k8s.gcr.io/kustomize/kustomize:v${KUSTOMIZE_VERSION} build \
/config/crd | kubectl apply -f -

# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: patch-image manifests
Expand All @@ -199,8 +201,8 @@ ifeq ($(ENABLE_EXTERNAL_DATA),true)
@grep -q -v 'enable-external-data' ./config/overlays/dev/manager_image_patch.yaml && sed -i '/- --operation=audit/a \ \ \ \ \ \ \ \ - --enable-external-data=true' ./config/overlays/dev/manager_image_patch.yaml
endif
docker run -v $(shell pwd)/config:/config -v $(shell pwd)/vendor:/vendor \
k8s.gcr.io/kustomize/kustomize:v${KUSTOMIZE_VERSION} build \
/config/overlays/dev | kubectl apply -f -
k8s.gcr.io/kustomize/kustomize:v${KUSTOMIZE_VERSION} build \
/config/overlays/dev | kubectl apply -f -

# Generate manifests e.g. CRD, RBAC etc.
manifests: __controller-gen
Expand All @@ -215,29 +217,29 @@ manifests: __controller-gen
mkdir -p manifest_staging/deploy/experimental
mkdir -p manifest_staging/charts/gatekeeper
docker run --rm -v $(shell pwd):/gatekeeper \
k8s.gcr.io/kustomize/kustomize:v${KUSTOMIZE_VERSION} build \
/gatekeeper/config/default -o /gatekeeper/manifest_staging/deploy/gatekeeper.yaml
k8s.gcr.io/kustomize/kustomize:v${KUSTOMIZE_VERSION} build \
/gatekeeper/config/default -o /gatekeeper/manifest_staging/deploy/gatekeeper.yaml
docker run --rm -v $(shell pwd):/gatekeeper \
k8s.gcr.io/kustomize/kustomize:v${KUSTOMIZE_VERSION} build \
--load_restrictor LoadRestrictionsNone /gatekeeper/cmd/build/helmify | go run cmd/build/helmify/*.go
k8s.gcr.io/kustomize/kustomize:v${KUSTOMIZE_VERSION} build \
--load_restrictor LoadRestrictionsNone /gatekeeper/cmd/build/helmify | go run cmd/build/helmify/*.go

# lint runs a dockerized golangci-lint, and should give consistent results
# across systems.
# Source: https://golangci-lint.run/usage/install/#docker
lint:
docker run --rm -v $(shell pwd):/app \
-v ${GOLANGCI_LINT_CACHE}:/root/.cache/golangci-lint \
-w /app golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine \
golangci-lint run -v
-v ${GOLANGCI_LINT_CACHE}:/root/.cache/golangci-lint \
-w /app golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine \
golangci-lint run -v

# Generate code
generate: __conversion-gen __controller-gen target-template-source
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths="./apis/..." paths="./pkg/..."
$(CONVERSION_GEN) \
--output-base=/gatekeeper \
--input-dirs=./apis/mutations/v1beta1,./apis/mutations/v1alpha1 \
--go-header-file=./hack/boilerplate.go.txt \
--output-file-base=zz_generated.conversion
--output-base=/gatekeeper \
--input-dirs=./apis/mutations/v1beta1,./apis/mutations/v1alpha1 \
--go-header-file=./hack/boilerplate.go.txt \
--output-file-base=zz_generated.conversion

# Prepare crds to be added to gatekeeper-crds image
clean-crds:
Expand Down Expand Up @@ -353,6 +355,16 @@ release-manifest:
export
$(MAKE) manifests

# Tags a new version for docs
.PHONY: version-docs
version-docs:
docker run \
-v $(shell pwd)/website:/website \
-w /website \
-u $(shell id -u):$(shell id -g) \
node:${NODE_VERSION} \
sh -c "yarn install --frozen-lockfile && yarn run docusaurus docs:version ${NEWVERSION}"

promote-staging-manifest:
@rm -rf deploy
@cp -r manifest_staging/deploy .
Expand All @@ -362,8 +374,8 @@ promote-staging-manifest:
# Delete gatekeeper from a cluster. Note this is not a complete uninstall, just a dev convenience
uninstall:
docker run -v $(shell pwd)/config:/config -v $(shell pwd)/vendor:/vendor \
k8s.gcr.io/kustomize/kustomize:v${KUSTOMIZE_VERSION} build \
/config/overlays/dev | kubectl delete -f -
k8s.gcr.io/kustomize/kustomize:v${KUSTOMIZE_VERSION} build \
/config/overlays/dev | kubectl delete -f -

__controller-gen: __tooling-image
CONTROLLER_GEN=docker run -v $(shell pwd):/gatekeeper gatekeeper-tooling controller-gen
Expand Down
7 changes: 7 additions & 0 deletions docs/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,16 @@ Cherry pick script is copied over from https://github.com/kubernetes/kubernetes/
make promote-staging-manifest
```

1. If it's a new minor release (e.g. v3.**6**.x -> 3.**7**.0), tag docs to be versioned. Make sure to keep patch version as `.x` for a minor release.

```
make version-docs NEWVERSION=v3.7.x
```

1. Preview the changes:

```
git status
git diff
```

Expand Down
15 changes: 10 additions & 5 deletions website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,21 @@ module.exports = {
href: 'https://open-policy-agent.github.io/gatekeeper/website/docs/',
},
items: [
{
href: 'https://github.com/open-policy-agent/gatekeeper',
label: 'GitHub',
position: 'left',
},
{
href: 'https://github.com/open-policy-agent/gatekeeper-library',
label: 'Library',
position: 'left',
},
{
type: 'docsVersionDropdown',
position: 'right',
},
{
href: 'https://github.com/open-policy-agent/gatekeeper',
position: 'right',
className: 'header-github-link',
'aria-label': 'GitHub repository',
},
],
},
footer: {
Expand Down
18 changes: 18 additions & 0 deletions website/src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,21 @@
margin: 0 calc(-1 * var(--ifm-pre-padding));
padding: 0 var(--ifm-pre-padding);
}

.header-github-link:hover {
opacity: 0.6;
}

.header-github-link:before {
content: '';
width: 24px;
height: 24px;
display: flex;
background: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12'/%3E%3C/svg%3E")
no-repeat;
}

html[data-theme='dark'] .header-github-link:before {
background: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='white' d='M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12'/%3E%3C/svg%3E")
no-repeat;
}

0 comments on commit 2047863

Please sign in to comment.