File Handling

    Flexible options for handling files, permissions, and content sources.

    File Properties

    • skip — Skip file/folder creation entirely
    • skip_if_exists — Skip only if the file already exists
    • permissions — Set custom file permissions (octal)
    • content — Define file content inline
    • file — Reference external file content
    File propertiesyaml
    files:
      - README.md:
          skip: true  # Never create this file
    
      - config.yml:
          skip_if_exists: true  # Only create if it doesn't exist
          content: "default: value"
    
      - scripts/deploy.sh:
          permissions: '0755'  # Executable script
          content: |
            #!/bin/bash
            echo "Deploying..."

    Remote File Protocols

    StructKit supports multiple protocols for fetching remote content:

    HTTP/HTTPS

    file: https://raw.githubusercontent.com/example/repo/main/requirements.txt

    GitHub Protocols

    # Standard GitHub
    file: github://github/gitignore/main/Python.gitignore
    
    # GitHub HTTPS
    file: githubhttps://actions/starter-workflows/main/ci/python-app.yml
    
    # GitHub SSH (private repos)
    file: githubssh://company/private-repo/main/config/template.yml

    Cloud Storage

    # Amazon S3
    file: s3://my-bucket/data/template.csv
    
    # Google Cloud Storage
    file: gs://my-bucket/configs/default.json

    Environment variables for HTTP behavior: STRUCTKIT_HTTP_TIMEOUT (default 10s), STRUCTKIT_HTTP_RETRIES (default 2), STRUCTKIT_DENY_NETWORK=1 to skip HTTP.

    File Handling Strategies

    Control how existing files are handled with --file-strategy:

    • overwrite — Replace existing files (default)
    • skip — Skip files that already exist
    • append — Add content to existing files
    • rename — Rename existing files with a suffix
    • backup — Move existing files to backup directory
    Terminalbash
    # Skip existing files
    structkit generate --file-strategy=skip my-config.yaml ./output
    
    # Backup existing files
    structkit generate --file-strategy=backup --backup=/tmp/backup my-config.yaml ./output