Class: Archsight::Import::Handlers::Gitlab
- Inherits:
-
Archsight::Import::Handler
- Object
- Archsight::Import::Handler
- Archsight::Import::Handlers::Gitlab
- Defined in:
- lib/archsight/import/handlers/gitlab.rb
Overview
GitLab handler - lists repositories from a GitLab instance and generates child Import resources
Configuration:
import/config/host - GitLab host (e.g., gitlab.company.com)
import/config/exploreGroups - If "true", explore all visible groups (default: false)
import/config/perPage - API pagination page size (default: 100)
import/config/verifySSL - If "false", disable SSL verification (default: true)
import/config/sslFingerprint - SSL certificate fingerprint for pinning (SHA256, colon-separated hex)
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 when API returns none (default: "internal")
Environment:
GITLAB_TOKEN - GitLab personal access token (required)
Output:
Generates Import:Repo:* resources for each repository
The repository handler will clone/sync the actual git repositories (via SSH)
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
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 60 61 62 63 64 65 |
# File 'lib/archsight/import/handlers/gitlab.rb', line 34 def execute @host = config("host") raise "Missing required config: host" unless @host @token = ENV.fetch("GITLAB_TOKEN", nil) raise "Missing required environment variable: GITLAB_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", "gitlab") @explore_groups = config("exploreGroups") == "true" @per_page = config("perPage", default: "100").to_i @verify_ssl = config("verifySSL") != "false" @ssl_fingerprint = config("sslFingerprint") # Fetch all projects progress.update("Fetching projects from #{@host}") projects = fetch_all_projects if projects.empty? progress.warn("No projects found on GitLab") return end # Generate Import resources for each repository progress.update("Generating #{projects.size} import resources") generate_repository_imports(projects) end |