Compare commits
1 Commits
3a9bd7c6b3
...
apps/homea
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a663746686 |
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Welcome! So excited you're here!
|
Welcome! So excited you're here!
|
||||||
|
|
||||||
_This project is massively in progress. It's not ready to be used yet (even though I am using it as I develop it). This is published publicly for transparency. If you want to help out, please [get in touch](https://forum.civilsociety.dev/c/wild-cloud/5)._
|
_This project is massively in progress. It's not ready to be used yet (even though I am using it as I develop it). This is published publicly for transparency. If you want to help out, please get in touch._
|
||||||
|
|
||||||
## Why Build Your Own Cloud?
|
## Why Build Your Own Cloud?
|
||||||
|
|
||||||
|
37
apps/homeassistant/config-job.yaml
Normal file
37
apps/homeassistant/config-job.yaml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: homeassistant-config-setup
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
restartPolicy: Never
|
||||||
|
containers:
|
||||||
|
- name: config-setup
|
||||||
|
image: busybox:1.35
|
||||||
|
command: ['sh', '-c']
|
||||||
|
args:
|
||||||
|
- |
|
||||||
|
# Wait for config file to exist
|
||||||
|
while [ ! -f /config/configuration.yaml ]; do
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
|
||||||
|
# Add HTTP config if not present
|
||||||
|
if ! grep -q "use_x_forwarded_for" /config/configuration.yaml; then
|
||||||
|
echo "" >> /config/configuration.yaml
|
||||||
|
echo "# HTTP configuration for reverse proxy support" >> /config/configuration.yaml
|
||||||
|
echo "http:" >> /config/configuration.yaml
|
||||||
|
echo " use_x_forwarded_for: true" >> /config/configuration.yaml
|
||||||
|
echo " trusted_proxies:" >> /config/configuration.yaml
|
||||||
|
echo " - 10.0.0.0/8" >> /config/configuration.yaml
|
||||||
|
echo " - 172.16.0.0/12" >> /config/configuration.yaml
|
||||||
|
echo " - 192.168.0.0/16" >> /config/configuration.yaml
|
||||||
|
fi
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /config
|
||||||
|
name: homeassistant-config
|
||||||
|
volumes:
|
||||||
|
- name: homeassistant-config
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: homeassistant-pvc
|
88
apps/homeassistant/deployment.yaml
Normal file
88
apps/homeassistant/deployment.yaml
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: homeassistant
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
component: homeassistant
|
||||||
|
strategy:
|
||||||
|
type: Recreate
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
component: homeassistant
|
||||||
|
spec:
|
||||||
|
# hostNetwork: true
|
||||||
|
dnsPolicy: ClusterFirstWithHostNet
|
||||||
|
initContainers:
|
||||||
|
- name: config-setup
|
||||||
|
image: busybox:1.35
|
||||||
|
command: ['sh', '-c']
|
||||||
|
args:
|
||||||
|
- |
|
||||||
|
# Create initial config if it doesn't exist
|
||||||
|
if [ ! -f /config/configuration.yaml ]; then
|
||||||
|
cat > /config/configuration.yaml << 'EOF'
|
||||||
|
# Loads default set of integrations. Do not remove.
|
||||||
|
default_config:
|
||||||
|
|
||||||
|
# Load frontend themes from the themes folder
|
||||||
|
frontend:
|
||||||
|
themes: !include_dir_merge_named themes
|
||||||
|
|
||||||
|
automation: !include automations.yaml
|
||||||
|
script: !include scripts.yaml
|
||||||
|
scene: !include scenes.yaml
|
||||||
|
|
||||||
|
# HTTP configuration for reverse proxy support
|
||||||
|
http:
|
||||||
|
use_x_forwarded_for: true
|
||||||
|
trusted_proxies:
|
||||||
|
- 10.0.0.0/8
|
||||||
|
- 172.16.0.0/12
|
||||||
|
- 192.168.0.0/16
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /config
|
||||||
|
name: homeassistant-config
|
||||||
|
containers:
|
||||||
|
- name: homeassistant
|
||||||
|
image: "{{ .apps.homeassistant.image }}"
|
||||||
|
ports:
|
||||||
|
- containerPort: 8123
|
||||||
|
protocol: TCP
|
||||||
|
env:
|
||||||
|
- name: TZ
|
||||||
|
value: "{{ .apps.homeassistant.timezone }}"
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /config
|
||||||
|
name: homeassistant-config
|
||||||
|
readOnly: false
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
memory: "512Mi"
|
||||||
|
cpu: "250m"
|
||||||
|
limits:
|
||||||
|
memory: "2Gi"
|
||||||
|
cpu: "2"
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /
|
||||||
|
port: 8123
|
||||||
|
initialDelaySeconds: 30
|
||||||
|
periodSeconds: 30
|
||||||
|
timeoutSeconds: 10
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /
|
||||||
|
port: 8123
|
||||||
|
initialDelaySeconds: 15
|
||||||
|
periodSeconds: 15
|
||||||
|
timeoutSeconds: 5
|
||||||
|
volumes:
|
||||||
|
- name: homeassistant-config
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: homeassistant-pvc
|
23
apps/homeassistant/ingress.yaml
Normal file
23
apps/homeassistant/ingress.yaml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: homeassistant-public
|
||||||
|
# annotations:
|
||||||
|
# external-dns.alpha.kubernetes.io/target: "{{ .apps.homeassistant.domain }}"
|
||||||
|
# external-dns.alpha.kubernetes.io/cloudflare-proxied: "false"
|
||||||
|
spec:
|
||||||
|
rules:
|
||||||
|
- host: "{{ .apps.homeassistant.domain }}"
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
pathType: Prefix
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: homeassistant
|
||||||
|
port:
|
||||||
|
number: 8123
|
||||||
|
tls:
|
||||||
|
- secretName: "{{ .apps.homeassistant.tlsKey }}"
|
||||||
|
hosts:
|
||||||
|
- "{{ .apps.homeassistant.domain }}"
|
16
apps/homeassistant/kustomization.yaml
Normal file
16
apps/homeassistant/kustomization.yaml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
namespace: homeassistant
|
||||||
|
labels:
|
||||||
|
- includeSelectors: true
|
||||||
|
pairs:
|
||||||
|
app: homeassistant
|
||||||
|
managedBy: kustomize
|
||||||
|
partOf: wild-cloud
|
||||||
|
resources:
|
||||||
|
- namespace.yaml
|
||||||
|
- deployment.yaml
|
||||||
|
- service.yaml
|
||||||
|
- ingress.yaml
|
||||||
|
- pvc.yaml
|
||||||
|
|
13
apps/homeassistant/manifest.yaml
Normal file
13
apps/homeassistant/manifest.yaml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
name: homeassistant
|
||||||
|
install: true
|
||||||
|
description: Home Assistant is an open source home automation platform that puts local control and privacy first.
|
||||||
|
version: 2025.1.0
|
||||||
|
icon: https://brands.home-assistant.io/homeassistant/logo.png
|
||||||
|
requires: []
|
||||||
|
defaultConfig:
|
||||||
|
image: ghcr.io/home-assistant/home-assistant:stable
|
||||||
|
timezone: UTC
|
||||||
|
storage: 50Gi
|
||||||
|
domain: hass.{{ .cloud.internalDomain }}
|
||||||
|
tlsSecretName: wildcard-internal-wild-cloud-tls
|
||||||
|
requiredSecrets: []
|
4
apps/homeassistant/namespace.yaml
Normal file
4
apps/homeassistant/namespace.yaml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: homeassistant
|
11
apps/homeassistant/pvc.yaml
Normal file
11
apps/homeassistant/pvc.yaml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: homeassistant-pvc
|
||||||
|
spec:
|
||||||
|
storageClassName: longhorn
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: {{ .apps.homeassistant.storage }}
|
12
apps/homeassistant/service.yaml
Normal file
12
apps/homeassistant/service.yaml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: homeassistant
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
port: 8123
|
||||||
|
targetPort: 8123
|
||||||
|
protocol: TCP
|
||||||
|
selector:
|
||||||
|
component: homeassistant
|
12
apps/jellyfin/config/example.env
Normal file
12
apps/jellyfin/config/example.env
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# Config
|
||||||
|
JELLYFIN_DOMAIN=jellyfin.$DOMAIN
|
||||||
|
JELLYFIN_CONFIG_STORAGE=1Gi
|
||||||
|
JELLYFIN_CACHE_STORAGE=10Gi
|
||||||
|
JELLYFIN_MEDIA_STORAGE=100Gi
|
||||||
|
TZ=UTC
|
||||||
|
|
||||||
|
# Docker Images
|
||||||
|
JELLYFIN_IMAGE=jellyfin/jellyfin:latest
|
||||||
|
|
||||||
|
# Jellyfin Configuration
|
||||||
|
JELLYFIN_PublishedServerUrl=https://jellyfin.$DOMAIN
|
49
apps/jellyfin/deployment.yaml
Normal file
49
apps/jellyfin/deployment.yaml
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: jellyfin
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: jellyfin
|
||||||
|
strategy:
|
||||||
|
type: Recreate
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: jellyfin
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: jellyfin/jellyfin:latest
|
||||||
|
name: jellyfin
|
||||||
|
ports:
|
||||||
|
- containerPort: 8096
|
||||||
|
protocol: TCP
|
||||||
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: config
|
||||||
|
env:
|
||||||
|
- name: TZ
|
||||||
|
valueFrom:
|
||||||
|
configMapKeyRef:
|
||||||
|
key: TZ
|
||||||
|
name: config
|
||||||
|
volumeMounts:
|
||||||
|
- mountPath: /config
|
||||||
|
name: jellyfin-config
|
||||||
|
- mountPath: /cache
|
||||||
|
name: jellyfin-cache
|
||||||
|
- mountPath: /media
|
||||||
|
name: jellyfin-media
|
||||||
|
volumes:
|
||||||
|
- name: jellyfin-config
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: jellyfin-config-pvc
|
||||||
|
- name: jellyfin-cache
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: jellyfin-cache-pvc
|
||||||
|
- name: jellyfin-media
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: jellyfin-media-pvc
|
24
apps/jellyfin/ingress.yaml
Normal file
24
apps/jellyfin/ingress.yaml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: jellyfin-public
|
||||||
|
annotations:
|
||||||
|
external-dns.alpha.kubernetes.io/target: your.jellyfin.domain
|
||||||
|
external-dns.alpha.kubernetes.io/cloudflare-proxied: "false"
|
||||||
|
spec:
|
||||||
|
rules:
|
||||||
|
- host: your.jellyfin.domain
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
pathType: Prefix
|
||||||
|
backend:
|
||||||
|
service:
|
||||||
|
name: jellyfin
|
||||||
|
port:
|
||||||
|
number: 8096
|
||||||
|
tls:
|
||||||
|
- secretName: wildcard-internal-wild-cloud-tls
|
||||||
|
hosts:
|
||||||
|
- your.jellyfin.domain
|
82
apps/jellyfin/kustomization.yaml
Normal file
82
apps/jellyfin/kustomization.yaml
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
namespace: jellyfin
|
||||||
|
labels:
|
||||||
|
- includeSelectors: true
|
||||||
|
pairs:
|
||||||
|
app: jellyfin
|
||||||
|
managedBy: kustomize
|
||||||
|
partOf: wild-cloud
|
||||||
|
resources:
|
||||||
|
- deployment.yaml
|
||||||
|
- ingress.yaml
|
||||||
|
- namespace.yaml
|
||||||
|
- pvc.yaml
|
||||||
|
- service.yaml
|
||||||
|
configMapGenerator:
|
||||||
|
- name: config
|
||||||
|
envs:
|
||||||
|
- config/config.env
|
||||||
|
|
||||||
|
replacements:
|
||||||
|
- source:
|
||||||
|
kind: ConfigMap
|
||||||
|
name: config
|
||||||
|
fieldPath: data.DOMAIN
|
||||||
|
targets:
|
||||||
|
- select:
|
||||||
|
kind: Ingress
|
||||||
|
name: jellyfin-public
|
||||||
|
fieldPaths:
|
||||||
|
- metadata.annotations.[external-dns.alpha.kubernetes.io/target]
|
||||||
|
- source:
|
||||||
|
kind: ConfigMap
|
||||||
|
name: config
|
||||||
|
fieldPath: data.JELLYFIN_DOMAIN
|
||||||
|
targets:
|
||||||
|
- select:
|
||||||
|
kind: Ingress
|
||||||
|
name: jellyfin-public
|
||||||
|
fieldPaths:
|
||||||
|
- spec.rules.0.host
|
||||||
|
- spec.tls.0.hosts.0
|
||||||
|
- source:
|
||||||
|
kind: ConfigMap
|
||||||
|
name: config
|
||||||
|
fieldPath: data.JELLYFIN_CONFIG_STORAGE
|
||||||
|
targets:
|
||||||
|
- select:
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
name: jellyfin-config-pvc
|
||||||
|
fieldPaths:
|
||||||
|
- spec.resources.requests.storage
|
||||||
|
- source:
|
||||||
|
kind: ConfigMap
|
||||||
|
name: config
|
||||||
|
fieldPath: data.JELLYFIN_CACHE_STORAGE
|
||||||
|
targets:
|
||||||
|
- select:
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
name: jellyfin-cache-pvc
|
||||||
|
fieldPaths:
|
||||||
|
- spec.resources.requests.storage
|
||||||
|
- source:
|
||||||
|
kind: ConfigMap
|
||||||
|
name: config
|
||||||
|
fieldPath: data.JELLYFIN_MEDIA_STORAGE
|
||||||
|
targets:
|
||||||
|
- select:
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
name: jellyfin-media-pvc
|
||||||
|
fieldPaths:
|
||||||
|
- spec.resources.requests.storage
|
||||||
|
- source:
|
||||||
|
kind: ConfigMap
|
||||||
|
name: config
|
||||||
|
fieldPath: data.JELLYFIN_IMAGE
|
||||||
|
targets:
|
||||||
|
- select:
|
||||||
|
kind: Deployment
|
||||||
|
name: jellyfin
|
||||||
|
fieldPaths:
|
||||||
|
- spec.template.spec.containers.0.image
|
5
apps/jellyfin/namespace.yaml
Normal file
5
apps/jellyfin/namespace.yaml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: jellyfin
|
37
apps/jellyfin/pvc.yaml
Normal file
37
apps/jellyfin/pvc.yaml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: jellyfin-config-pvc
|
||||||
|
namespace: jellyfin
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 1Gi
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: jellyfin-cache-pvc
|
||||||
|
namespace: jellyfin
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: jellyfin-media-pvc
|
||||||
|
namespace: jellyfin
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteMany
|
||||||
|
storageClassName: nfs
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 100Gi
|
15
apps/jellyfin/service.yaml
Normal file
15
apps/jellyfin/service.yaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: jellyfin
|
||||||
|
namespace: jellyfin
|
||||||
|
labels:
|
||||||
|
app: jellyfin
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 8096
|
||||||
|
targetPort: 8096
|
||||||
|
protocol: TCP
|
||||||
|
selector:
|
||||||
|
app: jellyfin
|
@@ -28,8 +28,8 @@ Tests project detection and script execution:
|
|||||||
|
|
||||||
### `test_config_functions.bats`
|
### `test_config_functions.bats`
|
||||||
Tests configuration and secret access:
|
Tests configuration and secret access:
|
||||||
- `wild-config` command
|
- `get_current_config()` function
|
||||||
- `wild-secret` command
|
- `get_current_secret()` function
|
||||||
- Configuration access from subdirectories
|
- Configuration access from subdirectories
|
||||||
- Fixture data usage
|
- Fixture data usage
|
||||||
|
|
||||||
|
@@ -36,18 +36,14 @@ teardown() {
|
|||||||
@test "init_wild_env sets WC_HOME correctly" {
|
@test "init_wild_env sets WC_HOME correctly" {
|
||||||
mkdir -p "$TEST_PROJECT_DIR/deep/nested"
|
mkdir -p "$TEST_PROJECT_DIR/deep/nested"
|
||||||
cd "$TEST_PROJECT_DIR/deep/nested"
|
cd "$TEST_PROJECT_DIR/deep/nested"
|
||||||
unset WC_HOME
|
unset WC_HOME WC_ROOT
|
||||||
export WC_ROOT="$PROJECT_ROOT"
|
|
||||||
export PATH="$PROJECT_ROOT/bin:$PATH"
|
|
||||||
init_wild_env
|
init_wild_env
|
||||||
assert_equal "$WC_HOME" "$TEST_PROJECT_DIR"
|
assert_equal "$WC_HOME" "$TEST_PROJECT_DIR"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "init_wild_env sets WC_ROOT correctly" {
|
@test "init_wild_env sets WC_ROOT correctly" {
|
||||||
cd "$TEST_PROJECT_DIR"
|
cd "$TEST_PROJECT_DIR"
|
||||||
unset WC_HOME
|
unset WC_HOME WC_ROOT
|
||||||
export WC_ROOT="$PROJECT_ROOT"
|
|
||||||
export PATH="$PROJECT_ROOT/bin:$PATH"
|
|
||||||
init_wild_env
|
init_wild_env
|
||||||
# WC_ROOT is set (value depends on test execution context)
|
# WC_ROOT is set (value depends on test execution context)
|
||||||
assert [ -n "$WC_ROOT" ]
|
assert [ -n "$WC_ROOT" ]
|
||||||
@@ -62,7 +58,7 @@ teardown() {
|
|||||||
@test "print functions work correctly" {
|
@test "print functions work correctly" {
|
||||||
cd "$TEST_PROJECT_DIR"
|
cd "$TEST_PROJECT_DIR"
|
||||||
run bash -c '
|
run bash -c '
|
||||||
source "$PROJECT_ROOT/scripts/common.sh"
|
source "$PROJECT_ROOT/bin/wild-common.sh"
|
||||||
print_header "Test Header"
|
print_header "Test Header"
|
||||||
print_info "Test info message"
|
print_info "Test info message"
|
||||||
print_warning "Test warning message"
|
print_warning "Test warning message"
|
||||||
|
@@ -15,47 +15,45 @@ teardown() {
|
|||||||
teardown_test_project "config-test"
|
teardown_test_project "config-test"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "wild-config with existing config" {
|
@test "get_current_config with existing config" {
|
||||||
CLUSTER_NAME=$(wild-config "cluster.name")
|
CLUSTER_NAME=$(get_current_config "cluster.name")
|
||||||
assert_equal "$CLUSTER_NAME" "test-cluster"
|
assert_equal "$CLUSTER_NAME" "test-cluster"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "wild-config with nested path" {
|
@test "get_current_config with nested path" {
|
||||||
VIP=$(wild-config "cluster.nodes.control.vip")
|
VIP=$(get_current_config "cluster.nodes.control.vip")
|
||||||
assert_equal "$VIP" "192.168.100.200"
|
assert_equal "$VIP" "192.168.100.200"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "wild-config with non-existent key" {
|
@test "get_current_config with non-existent key" {
|
||||||
NONEXISTENT=$(wild-config "nonexistent.key")
|
NONEXISTENT=$(get_current_config "nonexistent.key")
|
||||||
assert_equal "$NONEXISTENT" ""
|
assert_equal "$NONEXISTENT" ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "active nodes configuration access - interface" {
|
@test "active nodes configuration access - interface" {
|
||||||
CONTROL_NODE_INTERFACE=$(wild-config "cluster.nodes.active.\"192.168.100.201\".interface")
|
CONTROL_NODE_INTERFACE=$(get_current_config "cluster.nodes.active.\"192.168.100.201\".interface")
|
||||||
assert_equal "$CONTROL_NODE_INTERFACE" "eth0"
|
assert_equal "$CONTROL_NODE_INTERFACE" "eth0"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "active nodes configuration access - maintenance IP" {
|
@test "active nodes configuration access - maintenance IP" {
|
||||||
MAINTENANCE_IP=$(wild-config "cluster.nodes.active.\"192.168.100.201\".maintenanceIp")
|
MAINTENANCE_IP=$(get_current_config "cluster.nodes.active.\"192.168.100.201\".maintenanceIp")
|
||||||
assert_equal "$MAINTENANCE_IP" "192.168.100.131"
|
assert_equal "$MAINTENANCE_IP" "192.168.100.131"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "wild-secret function" {
|
@test "get_current_secret function" {
|
||||||
# Create temporary secrets file for testing
|
# Create temporary secrets file for testing
|
||||||
cp "$TEST_DIR/fixtures/sample-secrets.yaml" "$TEST_PROJECT_DIR/secrets.yaml"
|
cp "$TEST_DIR/fixtures/sample-secrets.yaml" "$TEST_PROJECT_DIR/secrets.yaml"
|
||||||
|
|
||||||
SECRET_VAL=$(wild-secret "operator.cloudflareApiToken")
|
SECRET_VAL=$(get_current_secret "operator.cloudflareApiToken")
|
||||||
assert_equal "$SECRET_VAL" "test_api_token_123456789"
|
assert_equal "$SECRET_VAL" "test_api_token_123456789"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "config access from subdirectory" {
|
@test "config access from subdirectory" {
|
||||||
mkdir -p "$TEST_PROJECT_DIR/config-subdir"
|
mkdir -p "$TEST_PROJECT_DIR/config-subdir"
|
||||||
cd "$TEST_PROJECT_DIR/config-subdir"
|
cd "$TEST_PROJECT_DIR/config-subdir"
|
||||||
unset WC_HOME
|
unset WC_HOME WC_ROOT
|
||||||
export WC_ROOT="$PROJECT_ROOT"
|
|
||||||
export PATH="$PROJECT_ROOT/bin:$PATH"
|
|
||||||
init_wild_env
|
init_wild_env
|
||||||
|
|
||||||
SUBDIR_CLUSTER=$(wild-config "cluster.name")
|
SUBDIR_CLUSTER=$(get_current_config "cluster.name")
|
||||||
assert_equal "$SUBDIR_CLUSTER" "test-cluster"
|
assert_equal "$SUBDIR_CLUSTER" "test-cluster"
|
||||||
}
|
}
|
@@ -29,7 +29,7 @@ setup_test_project() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Source wild-common.sh
|
# Source wild-common.sh
|
||||||
source "$PROJECT_ROOT/scripts/common.sh"
|
source "$PROJECT_ROOT/bin/wild-common.sh"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Clean up test environment
|
# Clean up test environment
|
||||||
|
@@ -59,9 +59,7 @@ teardown() {
|
|||||||
cd "$TEST_PROJECT_DIR/config-test"
|
cd "$TEST_PROJECT_DIR/config-test"
|
||||||
|
|
||||||
# Set up environment like the scripts do
|
# Set up environment like the scripts do
|
||||||
unset WC_HOME
|
unset WC_HOME WC_ROOT
|
||||||
export WC_ROOT="$PROJECT_ROOT"
|
|
||||||
export PATH="$PROJECT_ROOT/bin:$PATH"
|
|
||||||
init_wild_env
|
init_wild_env
|
||||||
|
|
||||||
CLUSTER_NAME=$("$PROJECT_ROOT/bin/wild-config" cluster.name 2>/dev/null)
|
CLUSTER_NAME=$("$PROJECT_ROOT/bin/wild-config" cluster.name 2>/dev/null)
|
||||||
@@ -70,10 +68,8 @@ teardown() {
|
|||||||
|
|
||||||
@test "environment variables from project root" {
|
@test "environment variables from project root" {
|
||||||
cd "$TEST_PROJECT_DIR"
|
cd "$TEST_PROJECT_DIR"
|
||||||
unset WC_HOME
|
unset WC_HOME WC_ROOT
|
||||||
export WC_ROOT="$PROJECT_ROOT"
|
source "$PROJECT_ROOT/bin/wild-common.sh"
|
||||||
export PATH="$PROJECT_ROOT/bin:$PATH"
|
|
||||||
source "$PROJECT_ROOT/scripts/common.sh"
|
|
||||||
init_wild_env
|
init_wild_env
|
||||||
|
|
||||||
assert_equal "$WC_HOME" "$TEST_PROJECT_DIR"
|
assert_equal "$WC_HOME" "$TEST_PROJECT_DIR"
|
||||||
@@ -83,10 +79,8 @@ teardown() {
|
|||||||
@test "environment variables from nested directory" {
|
@test "environment variables from nested directory" {
|
||||||
mkdir -p "$TEST_PROJECT_DIR/deep/very"
|
mkdir -p "$TEST_PROJECT_DIR/deep/very"
|
||||||
cd "$TEST_PROJECT_DIR/deep/very"
|
cd "$TEST_PROJECT_DIR/deep/very"
|
||||||
unset WC_HOME
|
unset WC_HOME WC_ROOT
|
||||||
export WC_ROOT="$PROJECT_ROOT"
|
source "$PROJECT_ROOT/bin/wild-common.sh"
|
||||||
export PATH="$PROJECT_ROOT/bin:$PATH"
|
|
||||||
source "$PROJECT_ROOT/scripts/common.sh"
|
|
||||||
init_wild_env
|
init_wild_env
|
||||||
|
|
||||||
assert_equal "$WC_HOME" "$TEST_PROJECT_DIR"
|
assert_equal "$WC_HOME" "$TEST_PROJECT_DIR"
|
||||||
|
Reference in New Issue
Block a user