Skip to content

Commit 509c51f

Browse files
committed
refactor: [#28] consolidate infra-config commands into parameterized command
- Replace 5 separate infra-config-{environment} commands with unified infra-config - Add ENVIRONMENT_TYPE and PROVIDER parameters for consistency - Update .PHONY declarations to match new command structure - Simplify help text with parameterized examples - Maintain backward compatibility through parameter validation - Improves maintainability and reduces command duplication
1 parent f569712 commit 509c51f

File tree

1 file changed

+17
-52
lines changed

1 file changed

+17
-52
lines changed

Makefile

Lines changed: 17 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Makefile for Torrust Tracker Demo - Twelve-Factor App Deployment
22
.PHONY: help install-deps test-e2e lint test-unit clean
33
.PHONY: infra-init infra-plan infra-apply infra-destroy infra-status infra-refresh-state
4-
.PHONY: infra-config-development infra-config-production infra-config-e2e infra-config-testing infra-config-staging infra-validate-config
4+
.PHONY: infra-config infra-validate-config
55
.PHONY: infra-test-prereq infra-test-ci infra-test-local
66
.PHONY: infra-providers infra-environments provider-info
77
.PHONY: app-deploy app-redeploy app-health-check
@@ -69,9 +69,9 @@ help: ## Show this help message
6969
@echo " make app-deploy ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt"
7070
@echo ""
7171
@echo "Configuration examples:"
72-
@echo " make infra-config-development PROVIDER=libvirt # Create development-libvirt.env"
73-
@echo " make infra-config-production PROVIDER=hetzner # Create production-hetzner.env"
74-
@echo " make infra-config-e2e PROVIDER=libvirt # Create e2e-libvirt.env"
72+
@echo " make infra-config ENVIRONMENT_TYPE=development PROVIDER=libvirt # Create development-libvirt.env"
73+
@echo " make infra-config ENVIRONMENT_TYPE=production PROVIDER=hetzner # Create production-hetzner.env"
74+
@echo " make infra-config ENVIRONMENT_TYPE=e2e PROVIDER=libvirt # Create e2e-libvirt.env"
7575

7676
install-deps: ## Install required dependencies (Ubuntu/Debian)
7777
@echo "Installing dependencies..."
@@ -167,8 +167,8 @@ infra-environments: ## List available environments and their providers
167167
@echo " production - Production deployment"
168168
@echo ""
169169
@echo "Usage examples:"
170-
@echo " make infra-config-development PROVIDER=libvirt # Create development-libvirt.env"
171-
@echo " make infra-config-production PROVIDER=hetzner # Create production-hetzner.env"
170+
@echo " make infra-config ENVIRONMENT_TYPE=development PROVIDER=libvirt # Create development-libvirt.env"
171+
@echo " make infra-config ENVIRONMENT_TYPE=production PROVIDER=hetzner # Create production-hetzner.env"
172172
@echo " make infra-apply ENVIRONMENT_TYPE=development ENVIRONMENT_FILE=development-libvirt"
173173
@echo " make infra-apply ENVIRONMENT_TYPE=production ENVIRONMENT_FILE=production-hetzner"
174174

@@ -181,60 +181,25 @@ provider-info: ## Show provider information (requires PROVIDER=<name>)
181181
@echo "Getting information for provider: $(PROVIDER)"
182182
@$(SCRIPTS_DIR)/providers/provider-interface.sh info $(PROVIDER)
183183

184-
infra-config-development: ## Generate development environment configuration (requires PROVIDER=<name>)
185-
@if [ -z "$(PROVIDER)" ]; then \
186-
echo "Error: PROVIDER not specified"; \
187-
echo "Usage: make infra-config-development PROVIDER=<provider>"; \
188-
echo "Available providers: libvirt, hetzner"; \
189-
echo "Example: make infra-config-development PROVIDER=libvirt"; \
190-
exit 1; \
191-
fi
192-
@echo "Configuring development environment for $(PROVIDER)..."
193-
$(SCRIPTS_DIR)/configure-env.sh development $(PROVIDER)
194-
195-
infra-config-production: ## Generate production environment configuration (requires PROVIDER=<name>)
196-
@if [ -z "$(PROVIDER)" ]; then \
197-
echo "Error: PROVIDER not specified"; \
198-
echo "Usage: make infra-config-production PROVIDER=<provider>"; \
199-
echo "Available providers: libvirt, hetzner"; \
200-
echo "Example: make infra-config-production PROVIDER=hetzner"; \
201-
exit 1; \
202-
fi
203-
@echo "Configuring production environment for $(PROVIDER)..."
204-
$(SCRIPTS_DIR)/configure-env.sh production $(PROVIDER)
205-
206-
infra-config-e2e: ## Generate e2e environment configuration (requires PROVIDER=<name>)
207-
@if [ -z "$(PROVIDER)" ]; then \
208-
echo "Error: PROVIDER not specified"; \
209-
echo "Usage: make infra-config-e2e PROVIDER=<provider>"; \
210-
echo "Available providers: libvirt, hetzner"; \
211-
echo "Example: make infra-config-e2e PROVIDER=libvirt"; \
212-
exit 1; \
213-
fi
214-
@echo "Configuring e2e environment for $(PROVIDER)..."
215-
$(SCRIPTS_DIR)/configure-env.sh e2e $(PROVIDER)
216-
217-
infra-config-testing: ## Generate testing environment configuration (requires PROVIDER=<name>)
218-
@if [ -z "$(PROVIDER)" ]; then \
219-
echo "Error: PROVIDER not specified"; \
220-
echo "Usage: make infra-config-testing PROVIDER=<provider>"; \
184+
infra-config: ## Generate environment configuration (requires ENVIRONMENT_TYPE and PROVIDER)
185+
@if [ -z "$(ENVIRONMENT_TYPE)" ]; then \
186+
echo "Error: ENVIRONMENT_TYPE not specified"; \
187+
echo "Usage: make infra-config ENVIRONMENT_TYPE=<type> PROVIDER=<provider>"; \
188+
echo "Available environment types: development, testing, e2e, staging, production"; \
221189
echo "Available providers: libvirt, hetzner"; \
222-
echo "Example: make infra-config-testing PROVIDER=libvirt"; \
190+
echo "Example: make infra-config ENVIRONMENT_TYPE=development PROVIDER=libvirt"; \
223191
exit 1; \
224192
fi
225-
@echo "Configuring testing environment for $(PROVIDER)..."
226-
$(SCRIPTS_DIR)/configure-env.sh testing $(PROVIDER)
227-
228-
infra-config-staging: ## Generate staging environment configuration (requires PROVIDER=<name>)
229193
@if [ -z "$(PROVIDER)" ]; then \
230194
echo "Error: PROVIDER not specified"; \
231-
echo "Usage: make infra-config-staging PROVIDER=<provider>"; \
195+
echo "Usage: make infra-config ENVIRONMENT_TYPE=<type> PROVIDER=<provider>"; \
196+
echo "Available environment types: development, testing, e2e, staging, production"; \
232197
echo "Available providers: libvirt, hetzner"; \
233-
echo "Example: make infra-config-staging PROVIDER=hetzner"; \
198+
echo "Example: make infra-config ENVIRONMENT_TYPE=development PROVIDER=libvirt"; \
234199
exit 1; \
235200
fi
236-
@echo "Configuring staging environment for $(PROVIDER)..."
237-
$(SCRIPTS_DIR)/configure-env.sh staging $(PROVIDER)
201+
@echo "Configuring $(ENVIRONMENT_TYPE) environment for $(PROVIDER)..."
202+
$(SCRIPTS_DIR)/configure-env.sh $(ENVIRONMENT_TYPE) $(PROVIDER)
238203

239204
infra-validate-config: ## Validate configuration for all environments
240205
@echo "Validating configuration..."

0 commit comments

Comments
 (0)