-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for lint and test locally
Fixes: https://github.com/aquarist-labs/s3gw/issues/677 Signed-off-by: Giuseppe Baccini <giuseppe.baccini@suse.com>
- Loading branch information
Giuseppe Baccini
committed
Oct 26, 2023
1 parent
61b2b80
commit 6066675
Showing
10 changed files
with
334 additions
and
0 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,37 @@ | ||
name: str() | ||
home: str(required=False) | ||
version: str() | ||
apiVersion: str() | ||
appVersion: any(str(), num(), required=False) | ||
description: str(required=False) | ||
keywords: list(str(), required=False) | ||
sources: list(str(), required=False) | ||
maintainers: list(include('maintainer'), required=False) | ||
dependencies: list(include('dependency'), required=False) | ||
icon: str(required=False) | ||
engine: str(required=False) | ||
condition: str(required=False) | ||
tags: str(required=False) | ||
deprecated: bool(required=False) | ||
kubeVersion: str(required=False) | ||
annotations: map(str(), str(), required=False) | ||
type: str(required=False) | ||
--- | ||
maintainer: | ||
name: str() | ||
email: str(required=False) | ||
url: str(required=False) | ||
--- | ||
dependency: | ||
name: str() | ||
version: str() | ||
repository: str(required=False) | ||
condition: str(required=False) | ||
tags: list(str(), required=False) | ||
enabled: bool(required=False) | ||
import-values: any(list(str()), list(include('import-value')), required=False) | ||
alias: str(required=False) | ||
--- | ||
import-value: | ||
child: str() | ||
parent: str() |
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,42 @@ | ||
--- | ||
rules: | ||
braces: | ||
min-spaces-inside: 0 | ||
max-spaces-inside: 0 | ||
min-spaces-inside-empty: -1 | ||
max-spaces-inside-empty: -1 | ||
brackets: | ||
min-spaces-inside: 0 | ||
max-spaces-inside: 0 | ||
min-spaces-inside-empty: -1 | ||
max-spaces-inside-empty: -1 | ||
colons: | ||
max-spaces-before: 0 | ||
max-spaces-after: 1 | ||
commas: | ||
max-spaces-before: 0 | ||
min-spaces-after: 1 | ||
max-spaces-after: 1 | ||
comments: | ||
require-starting-space: true | ||
min-spaces-from-content: 2 | ||
document-end: disable | ||
document-start: disable # No --- to start a file | ||
empty-lines: | ||
max: 2 | ||
max-start: 0 | ||
max-end: 0 | ||
hyphens: | ||
max-spaces-after: 1 | ||
indentation: | ||
spaces: consistent | ||
indent-sequences: true | ||
check-multi-line-strings: false | ||
key-duplicates: enable | ||
line-length: disable # Lines can be any length | ||
new-line-at-end-of-file: enable | ||
new-lines: | ||
type: unix | ||
trailing-spaces: enable | ||
truthy: | ||
level: warning |
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 |
---|---|---|
|
@@ -3,3 +3,5 @@ charts/**/charts/*.tgz | |
values.yaml | ||
/.idea/ | ||
.DS_Store | ||
tmp | ||
venv |
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,37 @@ | ||
# Copyright © 2023 SUSE LLC | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
######################################################################## | ||
# Testing cluster | ||
|
||
cluster-start: | ||
@./test-env/cluster-create.sh | ||
k3d kubeconfig merge -ad | ||
kubectl config use-context k3d-s3gw-charts-testing | ||
@./test-env/cluster-prepare.sh | ||
|
||
cluster-delete: | ||
k3d cluster delete s3gw-charts-testing | ||
@if test -f /usr/local/bin/rke2-uninstall.sh; then sudo sh /usr/local/bin/rke2-uninstall.sh; fi | ||
|
||
######################################################################## | ||
# Setup test environment | ||
|
||
setup-test-environment: | ||
python3 -m venv venv \ | ||
&& source venv/bin/activate \ | ||
&& pip install -r requirements-dev.txt | ||
|
||
######################################################################## | ||
# Test charts | ||
|
||
lint-test-all: | ||
@./test-env/run-lint-test.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
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,2 @@ | ||
yamllint | ||
yamale |
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,63 @@ | ||
#!/bin/bash | ||
# Copyright © 2023 SUSE LLC | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -e | ||
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
NETWORK_NAME=s3gw-charts-testing | ||
CLUSTER_NAME=s3gw-charts-testing | ||
K3S_IMAGE=${K3S_IMAGE:-rancher/k3s:v1.25.10-k3s1} | ||
export KUBECONFIG=$SCRIPT_DIR/../tmp/kubeconfig | ||
|
||
check_deps() { | ||
if ! command -v k3d &> /dev/null | ||
then | ||
echo "k3d could not be found" | ||
exit | ||
fi | ||
} | ||
|
||
existingCluster() { | ||
k3d cluster list | grep ${CLUSTER_NAME} | ||
} | ||
|
||
if [[ "$(existingCluster)" != "" ]]; then | ||
echo "Cluster already exists, skipping creation." | ||
exit 0 | ||
fi | ||
|
||
echo "Ensuring a network" | ||
docker network create $NETWORK_NAME || echo "Network already exists" | ||
|
||
echo "Creating a new one named $CLUSTER_NAME" | ||
if [ -z ${EXPOSE_CLUSTER_PORTS+x} ]; then | ||
# Without exposing ports on the host: | ||
k3d cluster create $CLUSTER_NAME --network $NETWORK_NAME --image "$K3S_IMAGE" $S3GW_K3D_INSTALL_ARGS | ||
else | ||
# Exposing ports on the host: | ||
k3d cluster create $CLUSTER_NAME --network $NETWORK_NAME --image "$K3S_IMAGE" -p '80:80@server:0' -p '443:443@server:0' $S3GW_K3D_INSTALL_ARGS | ||
fi | ||
k3d kubeconfig get $CLUSTER_NAME > $KUBECONFIG | ||
|
||
echo "Waiting for node to be ready" | ||
nodeName=$(kubectl get nodes -o name) | ||
kubectl wait --for=condition=Ready "$nodeName" | ||
|
||
date | ||
echo "Waiting for the deployments of the foundational configurations to be ready" | ||
# 1200s = 20 min, to handle even a horrendously slow setup. Regular is 10 to 30 seconds. | ||
kubectl wait --for=condition=Available --namespace kube-system deployment/metrics-server --timeout=1200s | ||
kubectl wait --for=condition=Available --namespace kube-system deployment/coredns --timeout=1200s | ||
kubectl wait --for=condition=Available --namespace kube-system deployment/local-path-provisioner --timeout=1200s | ||
date | ||
|
||
echo "The cluster is ready! ✔️" |
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,73 @@ | ||
#!/bin/bash | ||
# Copyright © 2023 SUSE LLC | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -e | ||
|
||
UI_IMAGE_TAG=${UI_IMAGE_TAG:-"latest"} | ||
BE_IMAGE_TAG=${BE_IMAGE_TAG:-"latest"} | ||
|
||
function prepare_system_domain { | ||
echo -e "\e[32mGenerating a magic domain...\e[0m" | ||
S3GW_CLUSTER_IP=$(docker inspect k3d-s3gw-charts-testing-server-0 | jq -r '.[0]["NetworkSettings"]["Networks"]["s3gw-charts-testing"]["IPAddress"]') | ||
if [[ -z $S3GW_CLUSTER_IP ]]; then | ||
echo "Couldn't find the cluster's IP address" | ||
exit 1 | ||
fi | ||
export S3GW_CLUSTER_IP="${S3GW_CLUSTER_IP}" | ||
export S3GW_SYSTEM_DOMAIN="${S3GW_CLUSTER_IP}.omg.howdoi.website" | ||
echo -e "Using \e[32m${S3GW_SYSTEM_DOMAIN}\e[0m for s3gw domain" | ||
} | ||
|
||
function deploy_s3gw_local_charts { | ||
helm upgrade --debug --wait --timeout 180s --install -n s3gw-charts-testing --create-namespace s3gw-charts-testing ./charts/s3gw \ | ||
--set publicDomain="${S3GW_SYSTEM_DOMAIN}" \ | ||
--set ui.publicDomain="${S3GW_SYSTEM_DOMAIN}" \ | ||
--set ui.imageTag="${UI_IMAGE_TAG}" \ | ||
--set imageTag="${BE_IMAGE_TAG}" \ | ||
--set logLevel="20" | ||
} | ||
|
||
echo "Installing helm-unittest plugin" | ||
|
||
set +e | ||
helm plugin install https://github.com/helm-unittest/helm-unittest.git | ||
helm plugin update unittest | ||
set -e | ||
|
||
echo "Preparing k3d environment" | ||
|
||
helm repo add jetstack https://charts.jetstack.io | ||
helm repo add s3gw https://aquarist-labs.github.io/s3gw-charts/ | ||
helm repo update | ||
|
||
#Install the cert-manager | ||
if ! [[ -v SKIP_CM_INSTALL ]]; then | ||
kubectl create namespace cert-manager | ||
|
||
helm install cert-manager --namespace cert-manager jetstack/cert-manager \ | ||
--set installCRDs=true \ | ||
--set extraArgs[0]=--enable-certificate-owner-ref=true \ | ||
--version 1.10 \ | ||
--wait | ||
fi | ||
|
||
echo "Deploying s3gw" | ||
|
||
prepare_system_domain | ||
|
||
echo -e "Using UI_IMAGE_TAG: \e[32m${UI_IMAGE_TAG}\e[0m" | ||
echo -e "Using BE_IMAGE_TAG: \e[32m${BE_IMAGE_TAG}\e[0m" | ||
|
||
deploy_s3gw_local_charts | ||
|
||
echo | ||
echo "Done preparing k3d environment! ✔️" |
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 @@ | ||
#!/bin/bash | ||
# Copyright © 2023 SUSE LLC | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -e | ||
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" | ||
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) | ||
echo -e "\e[32mUsing BRANCH_NAME=$BRANCH_NAME \e[0m" | ||
|
||
python3 -m venv venv && source venv/bin/activate | ||
|
||
ct lint-and-install \ | ||
--charts ${SCRIPT_DIR}"/../charts/s3gw" \ | ||
--target-branch ${BRANCH_NAME} \ | ||
--additional-commands="helm unittest --strict ${SCRIPT_DIR}/../charts/s3gw" \ | ||
--validate-maintainers=false \ | ||
--debug |