This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create initial testing structure and tests. * Build docker image. * Format with `goimports -w .`. * Get operator name from environment variable. * Script improvements. * Document command for building Docker images. * Add usage to uninstall_operator.sh script. * Add tooling to check formatting and format go code. * Update data-services-kudo module to the latest master.
- Loading branch information
Showing
26 changed files
with
1,346 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*-junit.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
# shellcheck disable=SC2039 | ||
|
||
set -euxo pipefail | ||
|
||
readonly script_directory="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" | ||
readonly project_directory="$(readlink -f "${script_directory}/..")" | ||
|
||
# shellcheck source=../metadata.sh | ||
source "${project_directory}/metadata.sh" | ||
|
||
readonly cassandra_docker_image="${CASSANDRA_DOCKER_IMAGE:-}" | ||
|
||
if [[ -z ${cassandra_docker_image} ]]; then | ||
echo "Missing CASSANDRA_DOCKER_IMAGE" >&2 | ||
exit 1 | ||
fi | ||
|
||
docker image build \ | ||
-t "${cassandra_docker_image}" \ | ||
-f "${project_directory}/images/Dockerfile" \ | ||
"${project_directory}/images" | ||
|
||
if [[ "${1:-}" == "push" ]]; then | ||
docker push "${cassandra_docker_image}" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,55 @@ | ||
#!/usr/bin/env bash | ||
|
||
# https://github.com/kudobuilder/kudo/releases/tag/v0.6.0 | ||
export KUDO_VERSION="0.7.2" | ||
# This script contains metadata that is either used in other scripts or expanded | ||
# into templates via `tools/compile_templates.sh`. | ||
|
||
# "Shadowing" these two environment variables so that they don't affect | ||
# similarly named environment variables in other scripts loading this script. | ||
_script_directory="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" | ||
_project_directory="$(readlink -f "${_script_directory}")" | ||
|
||
################################################################################ | ||
################################# Operator ##################################### | ||
################################################################################ | ||
|
||
# https://github.com/mesosphere/kudo-cassandra-operator | ||
|
||
export PROJECT_NAME="kudo-cassandra-operator" | ||
export OPERATOR_NAME="cassandra" | ||
|
||
# KUDO still doesn't support snapshots, or compound versions yet. Check out: | ||
# - https://github.com/kudobuilder/kudo/pull/889 | ||
# - https://github.com/kudobuilder/kudo/issues/163 | ||
export OPERATOR_VERSION="0.1.0" | ||
|
||
export OPERATOR_DIRECTORY="${_project_directory}/operator" | ||
export VENDOR_DIRECTORY="${_project_directory}/shared/vendor" | ||
|
||
################################################################################ | ||
############################### Dependencies ################################### | ||
################################################################################ | ||
|
||
# http://www.apache.org/dyn/closer.lua/cassandra/3.11.4 | ||
# https://hub.docker.com/_/cassandra | ||
# https://github.com/docker-library/cassandra/blob/master/3.11/Dockerfile | ||
export CASSANDRA_VERSION="3.11.4" | ||
|
||
# https://github.com/mesosphere/kudo-cassandra-operator/releases | ||
export KUDO_CASSANDRA_VERSION="0.1.0" | ||
# https://github.com/kudobuilder/kudo/releases/tag/v0.7.4 | ||
export KUDO_VERSION="0.7.4" | ||
|
||
export KUBERNETES_VERSION="1.15.0" | ||
|
||
################################################################################ | ||
############################## Docker images ################################### | ||
################################################################################ | ||
|
||
export CASSANDRA_DOCKER_IMAGE_NAMESPACE="mesosphere" | ||
export CASSANDRA_DOCKER_IMAGE_NAME="${OPERATOR_NAME}" | ||
export CASSANDRA_DOCKER_IMAGE_TAG="${OPERATOR_VERSION}-${CASSANDRA_VERSION}" | ||
export CASSANDRA_DOCKER_IMAGE="${CASSANDRA_DOCKER_IMAGE_NAMESPACE}/${CASSANDRA_DOCKER_IMAGE_NAME}:${CASSANDRA_DOCKER_IMAGE_TAG}" | ||
|
||
################################################################################ | ||
################################# Testing ###################################### | ||
################################################################################ | ||
|
||
export INTEGRATION_TESTS_DOCKER_IMAGE="golang:1.13.1-stretch" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env bash | ||
# shellcheck disable=SC2039 | ||
|
||
set -euxo pipefail | ||
|
||
readonly script_directory="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" | ||
readonly project_directory="$(readlink -f "${script_directory}")" | ||
|
||
# shellcheck source=metadata.sh | ||
source "${project_directory}/metadata.sh" | ||
|
||
readonly kubeconfig="${KUBECONFIG:-${HOME}/.kube/config}" | ||
|
||
readonly container_kubeconfig="/root/.kube/config" | ||
readonly container_project_directory="/${PROJECT_NAME}" | ||
readonly container_operator_directory="${container_project_directory}/operator" | ||
readonly container_vendor_directory="${container_project_directory}/shared/vendor" | ||
|
||
# Note: DS_KUDO_VERSION is used by the shared data-services-kudo tooling. | ||
|
||
docker run \ | ||
--rm \ | ||
-e "KUBECONFIG=${container_kubeconfig}" \ | ||
-e "KUBECTL_PATH=${container_vendor_directory}/kubectl.sh" \ | ||
-e "DS_KUDO_VERSION=v${KUDO_VERSION}" \ | ||
-e "OPERATOR_DIRECTORY=${container_operator_directory}" \ | ||
-e "VENDOR_DIRECTORY=${container_vendor_directory}" \ | ||
-v "${kubeconfig}:${container_kubeconfig}:ro" \ | ||
-v "${OPERATOR_DIRECTORY}:${container_operator_directory}:ro" \ | ||
-v "${project_directory}:${container_project_directory}" \ | ||
-v "${VENDOR_DIRECTORY}:${container_vendor_directory}" \ | ||
-w "${container_project_directory}" \ | ||
"${INTEGRATION_TESTS_DOCKER_IMAGE}" \ | ||
bash -c "${container_project_directory}/tests/run.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Scripts | ||
|
||
Scripts to be used by operators. | ||
|
||
## `uninstall_operator.sh` | ||
|
||
TODO(mpereira) description. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/usr/bin/env bash | ||
# shellcheck disable=SC2039 | ||
|
||
readonly script_directory="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" | ||
readonly project_directory="$(readlink -f "${script_directory}/..")" | ||
|
||
# shellcheck source=../metadata.sh | ||
source "${project_directory}/metadata.sh" | ||
|
||
readonly kubectl="${KUBECTL_PATH:-kubectl}" | ||
|
||
operator_name= | ||
operator_version= | ||
operator_instance_name= | ||
operator_instance_namespace= | ||
|
||
usage() { | ||
echo -n "Usage: ${0} " >&2 | ||
echo -n "--operator OPERATOR_NAME " >&2 | ||
echo -n "--version OPERATOR_VERSION " >&2 | ||
echo -n "--instance OPERATOR_INSTANCE_NAME " >&2 | ||
echo -n "--namespace OPERATOR_INSTANCE_NAMESPACE" >&2 | ||
echo >&2 | ||
} | ||
|
||
while [[ ${#} -gt 0 ]]; do | ||
# TODO(mpereira): handle parameters passed in as "parameter=value"; | ||
parameter="${1}" | ||
|
||
case "${parameter}" in | ||
--operator|-o) | ||
operator_name="${2}" | ||
shift | ||
;; | ||
--version|-v) | ||
operator_version="${2}" | ||
shift | ||
;; | ||
--instance|-i) | ||
operator_instance_name="${2}" | ||
shift | ||
;; | ||
--namespace|-n) | ||
operator_instance_namespace="${2}" | ||
shift | ||
;; | ||
--help|-h) | ||
usage | ||
exit 0 | ||
;; | ||
*) | ||
echo "Invalid parameter: ${parameter}" >&2 | ||
exit 1 | ||
;; | ||
esac | ||
|
||
shift | ||
done | ||
|
||
operator_name="${operator_name:-${OPERATOR_NAME}}" | ||
operator_version="${operator_version:-${OPERATOR_VERSION}}" | ||
operator_instance_name="${operator_instance_name:-${OPERATOR_INSTANCE_NAME}}" | ||
operator_instance_namespace="${operator_instance_namespace:-${OPERATOR_INSTANCE_NAMESPACE}}" | ||
|
||
for parameter in operator_name \ | ||
operator_version \ | ||
operator_instance_name \ | ||
operator_instance_namespace; do | ||
if [[ -z ${!parameter} ]]; then | ||
echo "Missing ${parameter}" >&2 | ||
echo >&2 | ||
usage | ||
exit 1 | ||
fi | ||
done | ||
|
||
${kubectl} delete instance \ | ||
"${operator_instance_name}" \ | ||
-n "${operator_instance_namespace}" | ||
|
||
# TODO(mpereira): add a flag to skip operatorversion deletion? | ||
${kubectl} delete operatorversion \ | ||
"${operator_name}-${operator_version}" \ | ||
-n "${operator_instance_namespace}" | ||
|
||
# TODO(mpereira): add a flag to skip operator deletion? | ||
${kubectl} delete operator \ | ||
"${operator_name}" \ | ||
-n "${operator_instance_namespace}" | ||
|
||
# TODO(mpereira): add a flag to skip pvc deletion? | ||
declare -a PVCS | ||
mapfile -t PVCS < <( | ||
${kubectl} get pvc \ | ||
-n "${operator_instance_namespace}" \ | ||
-o 'jsonpath={.items[*].metadata.name}' \ | ||
| tr ' ' '\n' | ||
) | ||
|
||
for pvc in "${PVCS[@]}"; do | ||
${kubectl} delete "pvc/${pvc}" -n "${operator_instance_namespace}" | ||
done |
Submodule shared
updated
from f7a9ac to ee403e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module github.com/mesosphere/kudo-cassandra-operator/tests | ||
|
||
go 1.13 | ||
|
||
require ( | ||
github.com/avast/retry-go v2.4.1+incompatible | ||
github.com/gogo/protobuf v1.3.1 // indirect | ||
github.com/imdario/mergo v0.3.8 // indirect | ||
github.com/kudobuilder/kudo v0.7.4 | ||
github.com/mitchellh/go-homedir v1.1.0 | ||
github.com/onsi/ginkgo v1.8.0 | ||
github.com/onsi/gomega v1.5.0 | ||
github.com/sirupsen/logrus v1.4.2 | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0 // indirect | ||
k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b | ||
k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8 | ||
k8s.io/apimachinery v0.0.0-20190704094520-6f131bee5e2c | ||
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible | ||
) |
Oops, something went wrong.