Skip to content

Commit

Permalink
Move docs into stashed/docs repo + Cleanup (#855)
Browse files Browse the repository at this point in the history
/cherry-pick

Signed-off-by: Emruz Hossain <emruz@appscode.com>
Signed-off-by: Tamal Saha <tamal@appscode.com>
  • Loading branch information
Emruz Hossain authored and tamalsaha committed Mar 16, 2021
1 parent c9fe7d9 commit 2806781
Show file tree
Hide file tree
Showing 104 changed files with 10 additions and 8,865 deletions.
50 changes: 0 additions & 50 deletions .github/workflows/ci.yml
Expand Up @@ -31,23 +31,6 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Prepare Host
run: |
sudo apt-get -qq update || true
sudo apt-get install -y bzr
# install yq
curl -fsSL -o yq https://github.com/mikefarah/yq/releases/download/3.3.0/yq_linux_amd64
chmod +x yq
sudo mv yq /usr/local/bin/yq
# install kubectl
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.17.0/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
# install codespan schema checker
curl -fsSL -o codespan-schema-checker https://github.com/kmodules/codespan-schema-checker/releases/download/v0.0.1/codespan-schema-checker-linux-amd64
chmod +x codespan-schema-checker
sudo mv codespan-schema-checker /usr/local/bin/codespan-schema-checker
- name: Run checks
run: |
make ci
Expand All @@ -60,36 +43,3 @@ jobs:
run: |
docker login --username ${USERNAME} --password ${DOCKER_TOKEN}
make push
- name: Create Kubernetes cluster
id: kind
uses: engineerd/setup-kind@v0.5.0
with:
version: v0.10.0
config: hack/kubernetes/kind.yaml

- name: Prepare cluster for testing
id: local-path
run: |
echo "waiting for nodes to be ready ..."
kubectl wait --for=condition=Ready nodes --all --timeout=5m
kubectl get nodes
echo
echo "install helm 3"
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
echo "install stash-crds chart"
helm repo add appscode https://charts.appscode.com/stable/
helm repo update
helm install stash-crds appscode/stash-crds
helm install kubedb-crds appscode/kubedb-crds
helm install kmodules-crds appscode/kmodules-crds
kubectl wait --for=condition=NamesAccepted crds --all --timeout=5m
- name: Test charts
run: |
export KUBECONFIG=$HOME/.kube/config
make ct
- name: Check codespan schema
run: |
codespan-schema-checker --content=./docs
30 changes: 0 additions & 30 deletions .github/workflows/release.yml
Expand Up @@ -18,10 +18,6 @@ jobs:
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
sudo mv bin/hub /usr/local/bin
- name: Install Helm 3
run: |
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
- name: Print version info
id: semver
run: |
Expand Down Expand Up @@ -55,29 +51,3 @@ jobs:
run: |
docker login --username ${USERNAME} --password ${DOCKER_TOKEN}
make release
- name: Clone charts repository
env:
GITHUB_USER: 1gtm
GITHUB_TOKEN: ${{ secrets.LGTM_GITHUB_TOKEN }}
CHART_REPOSITORY: ${{ secrets.CHART_REPOSITORY }}
run: |
url="https://${GITHUB_USER}:${GITHUB_TOKEN}@${CHART_REPOSITORY}.git"
cd $RUNNER_WORKSPACE
git clone $url
cd $(basename $CHART_REPOSITORY)
git config user.name "${GITHUB_USER}"
git config user.email "${GITHUB_USER}@appscode.com"
- name: Package
env:
GITHUB_USER: 1gtm
GITHUB_TOKEN: ${{ secrets.LGTM_GITHUB_TOKEN }}
CHART_REPOSITORY: ${{ secrets.CHART_REPOSITORY }}
run: |
cd $RUNNER_WORKSPACE/$(basename $CHART_REPOSITORY)
GIT_TAG=${GITHUB_REF#"refs/tags/"}
if [[ $GIT_TAG =~ "-alpha." ]] || [[ $GIT_TAG =~ "-beta." ]]; then
export REPO_DIR=testing
fi
./hack/scripts/upload-charts.sh $GITHUB_WORKSPACE
224 changes: 3 additions & 221 deletions Makefile
Expand Up @@ -19,12 +19,6 @@ REPO := $(notdir $(shell pwd))
BIN := stash-mongodb
COMPRESS ?= no

# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false,crdVersions={v1}"
# https://github.com/appscodelabs/gengo-builder
CODE_GENERATOR_IMAGE ?= appscode/gengo:release-1.18
API_GROUPS ?= installer:v1alpha1

# Where to push the docker image.
REGISTRY ?= stashed

Expand Down Expand Up @@ -54,7 +48,7 @@ RESTIC_VER := 0.12.0
### These variables should not need tweaking.
###

SRC_PKGS := apis cmd pkg
SRC_PKGS := cmd pkg
SRC_DIRS := $(SRC_PKGS) # directories which hold app source (not vendored)

DOCKER_PLATFORMS := linux/amd64 linux/arm64
Expand All @@ -76,7 +70,6 @@ TAG_DBG := $(VERSION)-dbg_$(OS)_$(ARCH)

GO_VERSION ?= 1.16
BUILD_IMAGE ?= appscode/golang-dev:$(GO_VERSION)
CHART_TEST_IMAGE ?= quay.io/helmpack/chart-testing:v3.0.0

OUTBIN = bin/$(OS)_$(ARCH)/$(BIN)
ifeq ($(OS),windows)
Expand Down Expand Up @@ -137,194 +130,9 @@ version:
@echo ::set-output name=commit_hash::$(commit_hash)
@echo ::set-output name=commit_timestamp::$(commit_timestamp)

.PHONY: clientset
clientset:
@docker run --rm \
-u $$(id -u):$$(id -g) \
-v /tmp:/.cache \
-v $$(pwd):$(DOCKER_REPO_ROOT) \
-w $(DOCKER_REPO_ROOT) \
--env HTTP_PROXY=$(HTTP_PROXY) \
--env HTTPS_PROXY=$(HTTPS_PROXY) \
$(CODE_GENERATOR_IMAGE) \
/go/src/k8s.io/code-generator/generate-groups.sh \
"deepcopy" \
$(GO_PKG)/$(REPO)/client \
$(GO_PKG)/$(REPO)/apis \
"$(API_GROUPS)" \
--go-header-file "./hack/license/go.txt"

# Generate openapi schema
.PHONY: openapi
openapi: $(addprefix openapi-, $(subst :,_, $(API_GROUPS)))
@echo "Generating api/openapi-spec/swagger.json"
@docker run --rm \
-u $$(id -u):$$(id -g) \
-v /tmp:/.cache \
-v $$(pwd):$(DOCKER_REPO_ROOT) \
-w $(DOCKER_REPO_ROOT) \
--env HTTP_PROXY=$(HTTP_PROXY) \
--env HTTPS_PROXY=$(HTTPS_PROXY) \
--env GO111MODULE=on \
--env GOFLAGS="-mod=vendor" \
$(BUILD_IMAGE) \
go run hack/gencrd/main.go

openapi-%:
@echo "Generating openapi schema for $(subst _,/,$*)"
@docker run --rm \
-u $$(id -u):$$(id -g) \
-v /tmp:/.cache \
-v $$(pwd):$(DOCKER_REPO_ROOT) \
-w $(DOCKER_REPO_ROOT) \
--env HTTP_PROXY=$(HTTP_PROXY) \
--env HTTPS_PROXY=$(HTTPS_PROXY) \
$(CODE_GENERATOR_IMAGE) \
openapi-gen \
--v 1 --logtostderr \
--go-header-file "./hack/license/go.txt" \
--input-dirs "$(GO_PKG)/$(REPO)/apis/$(subst _,/,$*),k8s.io/apimachinery/pkg/apis/meta/v1,k8s.io/apimachinery/pkg/api/resource,k8s.io/apimachinery/pkg/runtime,k8s.io/apimachinery/pkg/util/intstr,k8s.io/apimachinery/pkg/version,k8s.io/api/core/v1,k8s.io/api/apps/v1,k8s.io/api/rbac/v1" \
--output-package "$(GO_PKG)/$(REPO)/apis/$(subst _,/,$*)" \
--report-filename /tmp/violation_exceptions.list

# Generate CRD manifests
.PHONY: gen-crds
gen-crds:
@echo "Generating CRD manifests"
@docker run --rm \
-u $$(id -u):$$(id -g) \
-v /tmp:/.cache \
-v $$(pwd):$(DOCKER_REPO_ROOT) \
-w $(DOCKER_REPO_ROOT) \
--env HTTP_PROXY=$(HTTP_PROXY) \
--env HTTPS_PROXY=$(HTTPS_PROXY) \
$(CODE_GENERATOR_IMAGE) \
controller-gen \
$(CRD_OPTIONS) \
paths="./apis/..." \
output:crd:artifacts:config=crds

crds_to_patch := installer.stash.appscode.com_stashmongodbs.yaml

.PHONY: patch-crds
patch-crds: $(addprefix patch-crd-, $(crds_to_patch))
patch-crd-%: $(BUILD_DIRS)
@echo "patching $*"
@kubectl patch -f crds/$* -p "$$(cat hack/crd-patch.json)" --type=json --local=true -o yaml > bin/$*
@mv bin/$* crds/$*

.PHONY: label-crds
label-crds: $(BUILD_DIRS)
@for f in crds/*.yaml; do \
echo "applying app=stash label to $$f"; \
kubectl label --overwrite -f $$f --local=true -o yaml app=stash > bin/crd.yaml; \
mv bin/crd.yaml $$f; \
done

.PHONY: gen-crd-protos
gen-crd-protos: $(addprefix gen-crd-protos-, $(subst :,_, $(API_GROUPS)))

gen-crd-protos-%:
@echo "Generating protobuf for $(subst _,/,$*)"
@docker run --rm \
-u $$(id -u):$$(id -g) \
-v /tmp:/.cache \
-v $$(pwd):$(DOCKER_REPO_ROOT) \
-w $(DOCKER_REPO_ROOT) \
--env HTTP_PROXY=$(HTTP_PROXY) \
--env HTTPS_PROXY=$(HTTPS_PROXY) \
$(CODE_GENERATOR_IMAGE) \
go-to-protobuf \
--go-header-file "./hack/license/go.txt" \
--proto-import=$(DOCKER_REPO_ROOT)/vendor \
--proto-import=$(DOCKER_REPO_ROOT)/third_party/protobuf \
--apimachinery-packages=-k8s.io/apimachinery/pkg/api/resource,-k8s.io/apimachinery/pkg/apis/meta/v1,-k8s.io/apimachinery/pkg/apis/meta/v1beta1,-k8s.io/apimachinery/pkg/runtime,-k8s.io/apimachinery/pkg/runtime/schema,-k8s.io/apimachinery/pkg/util/intstr \
--packages=-k8s.io/api/core/v1,stash.appscode.dev/mongodb/apis/$(subst _,/,$*)

.PHONY: gen-bindata
gen-bindata:
@docker run \
-i \
--rm \
-u $$(id -u):$$(id -g) \
-v $$(pwd):/src \
-w /src/crds \
-v /tmp:/.cache \
--env HTTP_PROXY=$(HTTP_PROXY) \
--env HTTPS_PROXY=$(HTTPS_PROXY) \
$(BUILD_IMAGE) \
go-bindata -ignore=\\.go -ignore=\\.DS_Store -mode=0644 -modtime=1573722179 -o bindata.go -pkg crds ./...

.PHONY: gen-values-schema
gen-values-schema: $(BUILD_DIRS)
@for dir in charts/*/; do \
dir=$${dir%*/}; \
dir=$${dir##*/}; \
crd=$$(echo $$dir | tr -d '-'); \
yq r crds/installer.stash.appscode.com_$${crd}s.yaml spec.versions[0].schema.openAPIV3Schema.properties.spec > bin/values.openapiv3_schema.yaml; \
yq d bin/values.openapiv3_schema.yaml description > charts/$${dir}/values.openapiv3_schema.yaml; \
rm -rf bin/values.openapiv3_schema.yaml; \
done

.PHONY: gen-readme
gen-readme:
@jq -n -c --arg v "$(CHART_VERSION)" '{"version":$$v}' > /tmp/data.json
@render-gotpl --template=hack/templates/readme.txt --data=/tmp/data.json > README.md

.PHONY: gen-chart-doc
gen-chart-doc: gen-chart-doc-stash-mongodb

gen-chart-doc-%:
@echo "Generate $* chart docs"
@docker run --rm \
-u $$(id -u):$$(id -g) \
-v /tmp:/.cache \
-v $$(pwd):$(DOCKER_REPO_ROOT) \
-w $(DOCKER_REPO_ROOT) \
--env HTTP_PROXY=$(HTTP_PROXY) \
--env HTTPS_PROXY=$(HTTPS_PROXY) \
$(BUILD_IMAGE) \
chart-doc-gen -d ./charts/$*/doc.yaml -v ./charts/$*/values.yaml > ./charts/$*/README.md

.PHONY: manifests
manifests: gen-crds gen-values-schema gen-chart-doc

.PHONY: gen
gen: clientset manifests

CHART_REGISTRY ?= appscode
CHART_REGISTRY_URL ?= https://charts.appscode.com/stable/
CHART_VERSION ?=
APP_VERSION ?= $(CHART_VERSION)

.PHONY: update-charts
update-charts: $(shell find $$(pwd)/charts -maxdepth 1 -mindepth 1 -type d -printf 'chart-%f ')

chart-%:
@$(MAKE) chart-contents-$* gen-chart-doc-$* --no-print-directory

chart-contents-%:
@yq w -i ./charts/$*/doc.yaml repository.name --tag '!!str' $(CHART_REGISTRY)
@yq w -i ./charts/$*/doc.yaml repository.url --tag '!!str' $(CHART_REGISTRY_URL)
@if [ ! -z "$(CHART_VERSION)" ]; then \
yq w -i ./charts/$*/Chart.yaml version --tag '!!str' $(CHART_VERSION); \
yq w -i ./charts/$*/doc.yaml chart.version --tag '!!str' $(CHART_VERSION); \
yq w -i ./charts/$*/doc.yaml release.name --tag '!!str' $(BIN)-$(CHART_VERSION); \
yq w -i ./docs/examples/backup/replicaset/backupconfiguration-replicaset.yaml spec.task.name --tag '!!str' mongodb-backup-$(CHART_VERSION); \
yq w -i -d2 ./docs/examples/backup/replicaset/standalone-backup.yaml spec.task.name --tag '!!str' mongodb-backup-$(CHART_VERSION); \
yq w -i ./docs/examples/backup/sharding/backupconfiguration-sharding.yaml spec.task.name --tag '!!str' mongodb-backup-$(CHART_VERSION); \
yq w -i -d2 ./docs/examples/backup/sharding/standalone-backup.yaml spec.task.name --tag '!!str' mongodb-backup-$(CHART_VERSION); \
yq w -i ./docs/examples/backup/standalone/backupconfiguration.yaml spec.task.name --tag '!!str' mongodb-backup-$(CHART_VERSION); \
yq w -i ./docs/examples/restore/replicaset/restoresession-replicaset.yaml spec.task.name --tag '!!str' mongodb-restore-$(CHART_VERSION); \
yq w -i ./docs/examples/restore/replicaset/restoresession-standalone.yaml spec.task.name --tag '!!str' mongodb-restore-$(CHART_VERSION); \
yq w -i ./docs/examples/restore/sharding/restoresession-sharding.yaml spec.task.name --tag '!!str' mongodb-restore-$(CHART_VERSION); \
yq w -i ./docs/examples/restore/sharding/restoresession-standalone.yaml spec.task.name --tag '!!str' mongodb-restore-$(CHART_VERSION); \
yq w -i ./docs/examples/restore/standalone/restoresession.yaml spec.task.name --tag '!!str' mongodb-restore-$(CHART_VERSION); \
fi
@if [ ! -z "$(APP_VERSION)" ]; then \
yq w -i ./charts/$*/Chart.yaml appVersion --tag '!!str' $(APP_VERSION); \
yq w -i ./charts/$*/values.yaml image.tag --tag '!!str' $(APP_VERSION); \
fi
gen:
@true

fmt: $(BUILD_DIRS)
@docker run \
Expand Down Expand Up @@ -454,32 +262,6 @@ unit-tests: $(BUILD_DIRS)
./hack/test.sh $(SRC_PKGS) \
"

.PHONY: ct
ct: $(BUILD_DIRS)
@docker run \
-i \
--rm \
-v $$(pwd):/src \
-w /src \
--net=host \
-v $(HOME)/.kube:/.kube \
-v $(HOME)/.minikube:$(HOME)/.minikube \
-v $(HOME)/.credentials:$(HOME)/.credentials \
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin \
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin/$(OS)_$(ARCH) \
-v $$(pwd)/.go/cache:/.cache \
--env HTTP_PROXY=$(HTTP_PROXY) \
--env HTTPS_PROXY=$(HTTPS_PROXY) \
--env KUBECONFIG=$(subst $(HOME),,$(KUBECONFIG)) \
$(CHART_TEST_IMAGE) \
/bin/sh -c " \
kubectl -n kube-system create sa tiller; \
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller; \
helm init --service-account tiller; \
kubectl wait --for=condition=Ready pods -n kube-system --all --timeout=5m; \
ct lint-and-install --all; \
"

ADDTL_LINTERS := goconst,gofmt,goimports,unparam

.PHONY: lint
Expand Down
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -8,6 +8,7 @@

MongoDB backup and restore plugin for [Stash by AppsCode](https://appscode.com/products/stash).

<<<<<<< HEAD
## Install

Install MongoDB 4.2.3 backup or restore plugin for Stash as below.
Expand All @@ -28,12 +29,14 @@ Uninstall MongoDB 4.2.3 backup or restore plugin for Stash as below.
helm delete stash-mongodb--4.1.13 --namespace=kube-system
```

=======
>>>>>>> bd146366... Move docs into stashed/docs repo + Cleanup (#855)
## Support

We use Slack for public discussions. To chit chat with us or the rest of the community, join us in the [AppsCode Slack team](https://appscode.slack.com/messages/C8NCX6N23/details/) channel `#stash`. To sign up, use our [Slack inviter](https://slack.appscode.com/).

To join public discussions with the Stash community, join us in the [AppsCode Slack team](https://appscode.slack.com/messages/C8NCX6N23/details/) channel `#stash`. To sign up, use our [Slack inviter](https://slack.appscode.com/).

To receive product annoucements, follow us on [Twitter](https://twitter.com/KubeStash).
To receive product announcements, follow us on [Twitter](https://twitter.com/KubeStash).

If you have found a bug with Stash or want to request new features, please [file an issue](https://github.com/stashed/project/issues/new).

0 comments on commit 2806781

Please sign in to comment.