Class: Archsight::Import::Handlers::Github
- Inherits:
-
Archsight::Import::Handler
- Object
- Archsight::Import::Handler
- Archsight::Import::Handlers::Github
- Defined in:
- lib/archsight/import/handlers/github.rb
Overview
GitHub handler - lists repositories from a GitHub organization and generates child Import resources
Configuration:
import/config/org - GitHub organization name
import/config/repoOutputPath - Output path for repository handler results (e.g., "generated/repositories.yaml")
import/config/childCacheTime - Cache time for generated child imports (e.g., "1h", "30m")
import/config/fallbackTeam - Default team when no contributor match found (propagated to child imports)
import/config/botTeam - Team for bot-only repositories (propagated to child imports)
import/config/corporateAffixes - Comma-separated corporate username affixes for team matching (propagated to child imports)
import/config/defaultVisibility - Default visibility for non-public repos (default: "internal")
Environment:
GITHUB_TOKEN - GitHub Personal Access Token (required)
Create at: https://github.com/settings/tokens
Required scopes: repo (private repos) or public_repo (public only)
Output:
Generates Import:Repo:* resources for each repository
The repository handler will clone/sync the actual git repositories
Constant Summary collapse
- PER_PAGE =
100
Instance Attribute Summary
Attributes inherited from Archsight::Import::Handler
#database, #import_resource, #progress, #resources_dir, #shared_writer
Instance Method Summary collapse
Methods inherited from Archsight::Import::Handler
#compute_config_hash, #config, #config_all, #import_yaml, #initialize, #resource_yaml, #resources_to_yaml, #self_marker, #write_generates_meta, #write_yaml
Constructor Details
This class inherits a constructor from Archsight::Import::Handler
Instance Method Details
#execute ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/archsight/import/handlers/github.rb', line 33 def execute @org = config("org") raise "Missing required config: org" unless @org @token = ENV.fetch("GITHUB_TOKEN", nil) raise "Missing required environment variable: GITHUB_TOKEN" unless @token @repo_output_path = config("repoOutputPath") @child_cache_time = config("childCacheTime") @default_visibility = config("defaultVisibility", default: "internal") @target_dir = File.join(Dir.home, ".cache", "archsight", "git", "github", @org) # Fetch all repositories with pagination progress.update("Fetching repositories from #{@org}") repos = fetch_all_repos if repos.empty? progress.warn("No repositories found in #{@org}") return end # Generate Import resources for each repository progress.update("Generating #{repos.size} import resources") generate_repository_imports(repos) end |