diff --git a/README.md b/README.md index d7f289e..a2fcd41 100644 --- a/README.md +++ b/README.md @@ -113,19 +113,26 @@ Inside the container, all devkitARM tools are available in PATH. Run `make` to b For testing with real Nextcloud servers, copy the example configuration: ```bash -cp config.example config +cp config.example.json config.json ``` -Edit `config` and add your test Nextcloud credentials: +Edit `config.json` and add your test Nextcloud credentials: -```ini -# Local test configuration - DO NOT COMMIT THIS FILE -NEXTCLOUD_URL=https://your-nextcloud-instance.com -NEXTCLOUD_USER=your-username -NEXTCLOUD_PASSWORD=your-password +```json +{ + "nextcloud": { + "url": "https://your-nextcloud-instance.com", + "username": "your-username", + "password": "your-app-password" + }, + "settings": { + "maxRecentFolders": 5, + "uploadChunkSize": 10485760 + } +} ``` -**Note**: The `config` file is in `.gitignore` and will never be committed. +**Note**: The `config.json` file is in `.gitignore` and will never be committed. ## 🔧 Building @@ -161,31 +168,71 @@ Platform-specific build instructions: ### Local Development Configuration -The `config` file (copied from `config.example`) is used for local testing: +The project uses a JSON configuration file for managing test credentials and build options. -```ini -NEXTCLOUD_URL=https://cloud.example.com -NEXTCLOUD_USER=testuser -NEXTCLOUD_PASSWORD=testpass -MAX_RECENT_FOLDERS=5 # Build-time option +**Setup:** +```bash +# Copy the example configuration +cp config.example.json config.json + +# Edit config.json with your credentials +nano config.json ``` -### CI/CD Environment Variables - -For CI/CD pipelines, use environment variables to override the local config: - -- `NEXTCLOUD_TEST_URL` - Test server URL -- `NEXTCLOUD_TEST_USER` - Test username -- `NEXTCLOUD_TEST_PASSWORD` - Test password -- `MAX_RECENT_FOLDERS` - Number of recent folders to track - -Example: +**Configuration structure:** +```json +{ + "nextcloud": { + "url": "https://cloud.example.com", + "username": "testuser", + "password": "your-app-password" + }, + "settings": { + "maxRecentFolders": 5, + "uploadChunkSize": 10485760 + } +} +``` +**Loading configuration:** ```bash -NEXTCLOUD_TEST_URL=https://cloud.tomusan.com \ -NEXTCLOUD_TEST_USER=ci-user \ -NEXTCLOUD_TEST_PASSWORD=ci-pass \ -podman run --rm -v ./:/project:z nextcloud-share-3ds make +# Load configuration and export as environment variables +source scripts/load-config.sh + +# Validate configuration +./scripts/validate-config.sh +``` + +### Environment Variable Overrides + +Environment variables take precedence over JSON configuration values. This is useful for CI/CD pipelines where you don't want to store credentials in files. + +**Supported environment variables:** +- `NEXTCLOUD_URL` - Nextcloud server URL (required) +- `NEXTCLOUD_USER` - Username for authentication (required) +- `NEXTCLOUD_PASSWORD` - Password or app password (required) +- `MAX_RECENT_FOLDERS` - Number of recent folders to track (default: 5) +- `UPLOAD_CHUNK_SIZE` - Upload chunk size in bytes (default: 10485760) +- `CONFIG_FILE` - Path to config file (default: config.json) + +**CI/CD Example:** +```bash +# Override configuration with environment variables +export NEXTCLOUD_URL=https://cloud.tomusan.com +export NEXTCLOUD_USER=ci-user +export NEXTCLOUD_PASSWORD=ci-pass + +# Load any remaining config from file +source scripts/load-config.sh + +# Run tests +podman run --rm \ + -e NEXTCLOUD_URL \ + -e NEXTCLOUD_USER \ + -e NEXTCLOUD_PASSWORD \ + -v ./:/project:z \ + tomusan/devkitarm-3ds:latest \ + make test ``` ## 🧪 Testing