xcad 3 месяцев назад
Родитель
Сommit
39fafc4691

+ 33 - 41
archetypes/compose/extension.yaml

@@ -1,10 +1,9 @@
 ---
 # Extension variables for archetype testing
-# These variables are only available when testing archetypes
-# and are NOT part of the main module spec
-# They provide reasonable defaults for variables that normally have None values
+# These variables provide defaults for variables that have no default in the module spec
+# or add custom variables specifically needed for archetype testing
 
-# General service defaults
+# Variables from spec that need defaults for testing
 service_name:
   type: str
   description: Service name for testing
@@ -20,13 +19,11 @@ container_hostname:
   description: Container hostname for testing
   default: testapp-host
 
-# Traefik defaults
 traefik_host:
   type: hostname
   description: Traefik host for testing
   default: app.example.com
 
-# Database defaults
 database_port:
   type: int
   description: Database port for testing
@@ -48,7 +45,6 @@ database_password:
   default: secretpassword123
   sensitive: true
 
-# Email server defaults
 email_host:
   type: str
   description: Email server host for testing
@@ -70,7 +66,6 @@ email_from:
   description: Email from address for testing
   default: noreply@example.com
 
-# Authentik SSO defaults
 authentik_url:
   type: url
   description: Authentik URL for testing
@@ -92,51 +87,48 @@ authentik_client_secret:
   default: client_secret_abcdef
   sensitive: true
 
-# Ports defaults
+# Custom variables specific to archetype testing (not in module spec)
+network_enabled:
+  type: bool
+  description: Enable network configuration for testing
+  default: true
+
+volume_external:
+  type: bool
+  description: Use external volume for testing
+  default: false
+
 ports_http:
   type: int
   description: HTTP port for testing
   default: 8080
 
-ports_https:
-  type: int
-  description: HTTPS port for testing
-  default: 8443
-
-# Additional test variables
-test_image:
+secret_name:
   type: str
-  description: Docker image for testing
-  default: nginx:alpine
-
-test_port:
-  type: int
-  description: Port number for testing
-  default: 80
+  description: Secret name for testing
+  default: app_secret
 
-test_secret_token:
+config_name:
   type: str
-  description: Example secret token
-  default: my-secret-token-123
-  sensitive: true
+  description: Config name for testing
+  default: app_config
 
-test_api_key:
+service_image:
   type: str
-  description: Example API key
-  default: api_key_example_12345
-  sensitive: true
+  description: Service image for testing
+  default: nginx:alpine
 
-test_database_url:
-  type: str
-  description: Example database connection string
-  default: postgresql://user:pass@localhost:5432/db
+service_port:
+  type: int
+  description: Service port for testing
+  default: 8080
 
-test_environment_var:
+volume_name:
   type: str
-  description: Example environment variable
-  default: production
+  description: Volume name for testing
+  default: app_data
 
-test_config_path:
+traefik_middleware:
   type: str
-  description: Example configuration file path
-  default: /etc/app/config.yaml
+  description: Traefik middleware for testing
+  default: auth@file

+ 0 - 17
archetypes/compose/service-envfile-v1.j2

@@ -1,17 +0,0 @@
-{#
-  Archetype: service-environment-file-v1
-  
-  Description:
-    References external environment file(s) for configuration.
-  
-  Approach:
-    - Loads variables from .env file(s)
-    - Keeps sensitive data out of compose file
-    - Supports multiple env files
-  
-  Usage:
-    Use for services with many environment variables or sensitive data.
-    Create corresponding .env.j2 template file.
-#}
-    env_file:
-      - .env.{{ service_name }}

+ 14 - 10
archetypes/compose/service-environment-v1.j2

@@ -2,20 +2,24 @@
   Archetype: service-environment-v1
   
   Description:
-    Sets environment variables directly in the compose file.
+    Environment variables for common container configurations.
   
   Approach:
-    - Always includes TZ (timezone) variable
-    - Swarm-compatible (env_file doesn't work in Swarm mode)
-    - Can be extended with additional environment variables
+    - Sets standard environment variables (timezone, UID/GID)
+    - Demonstrates secret handling: file-based for swarm, env var for standalone
+    - Uses user_uid/user_gid from module spec general section
   
   Usage:
-    Use for services that need environment variables set directly.
-    This approach works in both standard Docker Compose and Swarm mode.
-    
-  Notes:
-    - For sensitive data in Swarm mode, use secrets instead
-    - For many variables in standard mode, consider env_file archetype
+    Use for services that need timezone and user/group configuration.
+    Adapt the secret handling pattern for your specific secret variables.
+    Replace SECRET example with actual secret variable names as needed.
 #}
     environment:
       - TZ={{ container_timezone }}
+      - UID={{ user_uid }}
+      - GID={{ user_gid }}
+      {% if swarm_enabled %}
+      - SECRET=/run/secrets/{{ secret_name }}
+      {% else %}
+      - SECRET=${SECRET}
+      {% endif %}

+ 0 - 2
archetypes/compose/service-ports-v1.j2

@@ -16,13 +16,11 @@
     {% if not traefik_enabled %}
     ports:
       {% if swarm_enabled %}
-      # Swarm: long syntax with mode host
       - target: {{ service_port }}
         published: {{ ports_http }}
         protocol: tcp
         mode: host
       {% else %}
-      # Standalone: short syntax
       - "{{ ports_http }}:{{ service_port }}"
       {% endif %}
     {% endif %}

+ 15 - 14
archetypes/compose/service-volumes-v1.j2

@@ -1,25 +1,26 @@
 {#
-  Archetype: service-volumes-swarm-v1
+  Archetype: service-volumes-v1
   
   Description:
-    Swarm-aware volume mounts supporting mount/local/NFS modes.
+    Service volume mounts supporting standalone and swarm modes.
   
   Approach:
-    - Swarm mount mode: Uses host path for bind mounts
-    - Swarm local/NFS mode: Uses named volumes
-    - Standalone mode: Always uses named volumes
+    - Standalone mode: Uses named volumes
+    - Swarm mount mode: Uses bind mounts from swarm_volume_mount_path
+    - Swarm local/nfs mode: Uses named volumes
   
   Usage:
-    Use for swarm deployments where you need flexibility in volume storage.
-    Requires swarm_volume_mode and swarm_volume_mount_path variables.
+    Use for services that need persistent storage.
+    Follows the pattern from pihole template.
+    Uses volume_name variable for named volumes.
 #}
     volumes:
-      {% if swarm_enabled %}
-        {% if swarm_volume_mode == 'mount' %}
-      - {{ swarm_volume_mount_path }}/data:/data:rw
-        {% elif swarm_volume_mode in ['local', 'nfs'] %}
-      - app_data:/data
-        {% endif %}
+      {% if not swarm_enabled %}
+      - {{ volume_name }}:/data
       {% else %}
-      - app_data:/data
+      {% if swarm_volume_mode == 'mount' %}
+      - {{ swarm_volume_mount_path }}/data:/data:rw
+      {% elif swarm_volume_mode in ['local', 'nfs'] %}
+      - {{ volume_name }}:/data
+      {% endif %}
       {% endif %}