Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bin/init.bash
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ generate_default_config() {
if [[ -f "${config_template_path}/providers/${CK8S_CLOUD_PROVIDER}/${config_name}" ]]; then
files+=("${config_template_path}/providers/${CK8S_CLOUD_PROVIDER}/${config_name}")
fi
if [[ -f "${config_template_path}/providers/${CK8S_CLOUD_PROVIDER}/${CK8S_K8S_INSTALLER}/${config_name}" ]]; then
files+=("${config_template_path}/providers/${CK8S_CLOUD_PROVIDER}/${CK8S_K8S_INSTALLER}/${config_name}")
fi

yq_merge "${files[@]}" | envsubst >"${new_config}"

Expand Down
15 changes: 15 additions & 0 deletions config/providers/safespring/capi/common-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
networkPolicies:
global:
externalLoadBalancer: false
ingressUsingHostNetwork: false
ingressNginx:
ingressOverride:
enabled: true
ips:
- 0.0.0.0/0
ingressNginx:
controller:
service:
enabled: true
type: LoadBalancer
useHostPort: false
2 changes: 2 additions & 0 deletions tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ RUN curl -LOs "https://github.com/getsops/sops/releases/download/v${SOPS_VERSION

ARG YAJSV_VERSION="1.4.1"
RUN curl -LOs "https://github.com/neilpa/yajsv/releases/download/v${YAJSV_VERSION}/yajsv.linux.amd64" && \
echo "4bd6d2b1d6292ab1f7ba63db83c182a603a790d431429cf71f05cb0fcc677def yajsv.linux.amd64" | sha256sum -c - && \
install -Tm 755 yajsv.linux.amd64 /usr/local/bin/yajsv && \
rm yajsv.linux.amd64

ARG YQ_VERSION="4.45.1"
RUN curl -LOs "https://github.com/mikefarah/yq/releases/download/v${YQ_VERSION}/yq_linux_amd64" && \
echo "654d2943ca1d3be2024089eb4f270f4070f491a0610481d128509b2834870049 yq_linux_amd64" | sha256sum -c - && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat way of validating hash inline

install -Tm 755 yq_linux_amd64 /usr/local/bin/yq && \
rm yq_linux_amd64

Expand Down
73 changes: 73 additions & 0 deletions tests/unit/safespring/bin-init-separate-installer-configs.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env bats

# bats file_tags=static,bin:init,safespring

setup_file() {
load "../../bats.lib.bash"
load_common "env.bash"
load_common "gpg.bash"
load_common "yq.bash"

gpg.setup
env.setup

}

setup() {
load "../../bats.lib.bash"
load_common "env.bash"
load_common "yq.bash"

load_assert
load_file
load "../templates/bin-init.bash"

env.private
}

teardown() {
env.teardown
}

teardown_file() {
env.teardown
gpg.teardown
}

@test "config is different - safespring:capi:prod" {
env.init safespring capi prod
test_init_successful

assert_equal "$(yq.get sc '.networkPolicies.global.externalLoadBalancer')" "false"
assert_equal "$(yq.get sc '.networkPolicies.global.ingressUsingHostNetwork')" "false"
assert_equal "$(yq.get sc '.networkPolicies.ingressNginx.ingressOverride.enabled')" "true"
assert_equal "$(yq.get sc '.networkPolicies.ingressNginx.ingressOverride.ips[0]')" "0.0.0.0/0"
assert_equal "$(yq.get sc '.ingressNginx.controller.service.enabled')" "true"
assert_equal "$(yq.get sc '.ingressNginx.controller.service.type')" "LoadBalancer"
assert_equal "$(yq.get sc '.ingressNginx.controller.useHostPort')" "false"
assert_equal "$(yq.get wc '.networkPolicies.global.externalLoadBalancer')" "false"
assert_equal "$(yq.get wc '.networkPolicies.global.ingressUsingHostNetwork')" "false"
assert_equal "$(yq.get wc '.networkPolicies.ingressNginx.ingressOverride.enabled')" "true"
assert_equal "$(yq.get wc '.networkPolicies.ingressNginx.ingressOverride.ips[0]')" "0.0.0.0/0"
assert_equal "$(yq.get wc '.ingressNginx.controller.service.enabled')" "true"
assert_equal "$(yq.get wc '.ingressNginx.controller.service.type')" "LoadBalancer"
assert_equal "$(yq.get wc '.ingressNginx.controller.useHostPort')" "false"
}

@test "config is different - safespring:kubespray:prod" {
env.init safespring kubespray prod
test_init_successful

assert_equal "$(yq.get sc '.networkPolicies.global.externalLoadBalancer')" "true"
assert_equal "$(yq.get sc '.networkPolicies.global.ingressUsingHostNetwork')" "true"
assert_equal "$(yq.get sc '.networkPolicies.ingressNginx.ingressOverride.enabled')" "false"
assert_equal "$(yq.get sc '.ingressNginx.controller.service.enabled')" "false"
assert_equal "$(yq.get sc '.ingressNginx.controller.service.type')" "NodePort"
assert_equal "$(yq.get sc '.ingressNginx.controller.useHostPort')" "true"
assert_equal "$(yq.get wc '.networkPolicies.global.externalLoadBalancer')" "true"
assert_equal "$(yq.get wc '.networkPolicies.global.ingressUsingHostNetwork')" "true"
assert_equal "$(yq.get wc '.networkPolicies.ingressNginx.ingressOverride.enabled')" "false"
assert_equal "$(yq.get wc '.ingressNginx.controller.service.enabled')" "false"
assert_equal "$(yq.get wc '.ingressNginx.controller.service.type')" "NodePort"
assert_equal "$(yq.get wc '.ingressNginx.controller.useHostPort')" "true"
}