Class: Archsight::Import::Handlers::GoGrapher

Inherits:
Grapher show all
Includes:
GoModuleParser
Defined in:
lib/archsight/import/handlers/go_grapher.rb

Overview

GoGrapher handler - analyses a Go repository and generates a GraphViz DOT graph of its module/package structure, stored as architecture/go/modules on the TechnologyArtifact so it can be rendered in the frontend.

Also emits one ApplicationComponent per go.mod module, linked to the repo artifact via realizedThrough. If OpenAPI spec files are found in a module directory, the component gains an exposes relation to the matching interface.

dependsOn relations between components are resolved in a second pass by the GoDepResolver handler, which runs after all graphers have seeded the database.

Configuration:

import/config/path                 - Path to the Go repository root (go.mod or go.work)
import/config/ranksep              - Horizontal gap between rank columns (default: 0.6)
import/config/nodesep              - Vertical gap between nodes in a column (default: 0.15)
import/config/interface_visibility - Visibility prefix for detected interfaces (default: Private)

Constant Summary collapse

OPENAPI_FILENAMES =
%w[openapi.yaml openapi.yml openapi.json swagger.yaml swagger.yml swagger.json].freeze
OPENAPI_SUBDIRS =
%w[api docs spec].freeze

Constants inherited from Grapher

Archsight::Import::Handlers::Grapher::PALETTE

Instance Attribute Summary

Attributes inherited from Archsight::Import::Handler

#database, #import_resource, #progress, #resources_dir, #shared_writer

Class Method Summary collapse

Methods included from GoModuleParser

#component_name, #discover_modules, #go_mod_requires, #read_module_name, #same_origin_prefix

Methods inherited from Grapher

#dot_graph, #execute, #safe_glob

Methods inherited from Archsight::Import::Handler

#compute_config_hash, #config, #config_all, #execute, #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

Class Method Details

.applicable?(path) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
38
39
# File 'lib/archsight/import/handlers/go_grapher.rb', line 33

def self.applicable?(path)
  File.exist?(File.join(path, "go.work")) ||
    File.exist?(File.join(path, "go.mod")) ||
    Dir.glob(File.join(path, "**/go.mod")).any?
rescue Errno::ELOOP, Errno::ENOTDIR
  false
end

.language_nameObject



31
# File 'lib/archsight/import/handlers/go_grapher.rb', line 31

def self.language_name = "go"