thothctl

ThothCTL Check Space Command

Overview

The thothctl check space command provides comprehensive diagnostics for space configuration and setup. This command validates space configuration, VCS settings, credentials status, and project usage to help troubleshoot space-related issues.

Command Structure

Usage: thothctl check space [OPTIONS]

  Check space configuration and diagnostics

Options:
  -s, --space-name TEXT    Name of the space to check [required]
  --help                   Show this message and exit.

Basic Usage

Check Space Configuration

thothctl check space --space-name development

This validates the specified spaceโ€™s configuration from the global ~/.thothcf/spaces.toml registry and provides comprehensive diagnostics.

Validation Output

The command provides professional Rich-formatted output with multiple diagnostic sections:

Space Overview

VCS Configuration

Credentials Status

Project Usage

Example Output

โ„น๏ธ ๐Ÿ” Checking space configuration: labvel-devsecops
                ๐ŸŒŒ Space Overview: labvel-devsecops                 
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Property         โ”ƒ Value                                         โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ Name             โ”‚ labvel-devsecops                              โ”‚
โ”‚ Version          โ”‚ 1.0.0                                         โ”‚
โ”‚ Path             โ”‚ /home/labvel/.thothcf/spaces/labvel-devsecops โ”‚
โ”‚ Config Path      โ”‚ configs                                       โ”‚
โ”‚ Credentials Path โ”‚ credentials                                   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        ๐Ÿ”„ VCS Configuration                         
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Setting             โ”ƒ Value                       โ”ƒ Status        โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ Default Provider    โ”‚ github                      โ”‚ โœ… Configured โ”‚
โ”‚ Available Providers โ”‚ azure_repos, github, gitlab โ”‚ โœ… Set        โ”‚
โ”‚ VCS Path            โ”‚ vcs                         โ”‚ โœ… Set        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                    ๐Ÿ”’ Credentials Status                     
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Type      โ”ƒ File          โ”ƒ Status       โ”ƒ Details         โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ VCS       โ”‚ vcs.enc       โ”‚ โœ… Available โ”‚ Size: 292 bytes โ”‚
โ”‚ TERRAFORM โ”‚ terraform.enc โ”‚ โŒ Missing   โ”‚ Not configured  โ”‚
โ”‚ CLOUD     โ”‚ cloud.enc     โ”‚ โŒ Missing   โ”‚ Not configured  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ ๐Ÿ“ Projects โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ No projects are currently using space 'labvel-devsecops'                                                                                                                                                                         โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Use Cases

Space Troubleshooting

When experiencing issues with space configuration:

thothctl check space --space-name production

This helps identify:

Pre-deployment Validation

Before deploying projects in a space:

thothctl check space --space-name staging

Ensures the space is properly configured and ready for project operations.

Credential Verification

To verify credential setup and security:

thothctl check space --space-name development

Shows credential status and provides security recommendations.

Configuration Validation

The command reads space configuration from ~/.thothcf/spaces.toml โ€” the single source of truth for all space definitions. It validates the space entry and its associated directory structure.

Global Registry (~/.thothcf/spaces.toml)

The check space command looks up the space in the global registry:

[spaces.development]
name = "development"
description = "Development environment space"
created_at = "2024-01-15T10:30:00Z"

[spaces.development.version_control]
provider = "github"

[spaces.development.terraform]
registry = "https://registry.terraform.io"
auth_method = "token"

[spaces.development.orchestration]
tool = "terragrunt"

[spaces.development.projects]
[spaces.development.projects.my-app]
registered_at = "2024-01-16T09:00:00Z"
[spaces.development.projects.vpc-network]
registered_at = "2024-01-17T14:00:00Z"

Space Directory Structure

~/.thothcf/spaces/{space_name}/
โ”œโ”€โ”€ metadata.toml            # Directory identification (name, created_at, config_source)
โ”œโ”€โ”€ configs/
โ”‚   โ””โ”€โ”€ scan_policy.toml     # Space-level scan policy overrides (optional)
โ”œโ”€โ”€ credentials/             # Encrypted VCS/TF/cloud credentials
โ”œโ”€โ”€ vcs/                     # VCS-specific settings
โ”œโ”€โ”€ terraform/               # Terraform registry settings
โ””โ”€โ”€ orchestration/           # Orchestration tool settings

The command also checks for configs/scan_policy.toml, which provides space-level security policy overrides for scan operations.

Credentials are stored as encrypted .enc files in the credentials/ directory. The check space command validates their presence and file integrity without decrypting them.

Error Scenarios

Space Not Found

โŒ Space 'nonexistent' does not exist

Solution: Verify space name or create the space using thothctl init space.

Missing Configuration

โš ๏ธ Configuration file missing: metadata.toml

Solution: Reinitialize the space or manually create the metadata file.

Invalid Credentials

โŒ GitHub Token: Invalid or expired

Solution: Update credentials using space initialization or manual configuration.

VCS Connection Issues

โŒ VCS Configuration: Connection failed

Solution: Verify network connectivity and credential validity.

Integration with Other Commands

Space Initialization

# Create a new space
thothctl init space --space-name development --vcs-provider github

# Check the newly created space
thothctl check space --space-name development

Project Creation

# Create project in space
thothctl init project --project-name my-app --space development

# Verify space configuration before project creation
thothctl check space --space-name development

Space Management

# List all spaces
thothctl list spaces

# Check specific space
thothctl check space --space-name production

# Remove space (with validation)
thothctl remove space --space-name old-space

Best Practices

  1. Regular Health Checks: Run space checks periodically to ensure configuration integrity
  2. Pre-Project Validation: Always check space configuration before creating new projects
  3. Credential Rotation: Use space checks to monitor credential status and expiration
  4. Environment Consistency: Validate space configuration across different environments
  5. Troubleshooting Workflow: Use space checks as the first step in diagnosing space-related issues

Troubleshooting

Common Issues

Permission Denied

Error: [Errno 13] Permission denied: ~/.thothcf/spaces/development

Solution: Check file permissions and ensure proper access to the ThothCTL configuration directory.

Network Connectivity

โŒ VCS Connection: Timeout

Solution: Verify network connectivity and firewall settings for VCS provider access.

Corrupted Configuration

โš ๏ธ Configuration file corrupted

Solution: Backup and recreate the space configuration or restore from a known good state.

Debugging

Enable debug mode for detailed diagnostic information:

thothctl --debug check space --space-name development

This provides:

Exit Codes