How nezumisannn/goemon works
Project Type and Purpose
• Project Type: A standalone command-line application.
• Purpose: To monitor AWS maintenance events using specified AWS credentials/configurations and notify a chat (like Chatwork) when events occur. The functionality is invoked via CLI commands (e.g., “check” and “help”) with a YAML configuration guiding its behavior.
File Structure
• Key Files and Directories:
• main.go – The main entry point of the application.
• cmd directory – Contains command implementations (e.g., check.go and root.go) where command-line parsing and execution is handled.
• goemon directory – Likely includes core logic (e.g., goemon/check.go) that performs the AWS event checking and notification work.
• example.config.yaml – Provides an example configuration to illustrate required fields like notification mechanism, AWS region, profiles, and chat settings.
• The structure reveals a separation between command line interface code and core business logic, which is typical for a CLI tool.
Main Components
a. CLI Interface Component
• Represented by the main.go entry point and the cmd package.
• Handles parsing of commands and flags (including the “help” and “check” commands).
b. Configuration Loader/Parser
• Reads the YAML configuration file (example.config.yaml) that specifies details for AWS connections, role assumptions, and notification methods.
c. AWS Maintenance Events Checker
• Core logic (in goemon package or within “cmd/check.go”) that interacts with AWS APIs to retrieve maintenance events.
• Handles AWS-specific components such as region, profile, and role assumptions.
d. Notification Module
• Deals with notifying external chat services such as Chatwork as defined in the configuration file.
• It encapsulates the logic to format and send notifications based on the retrieved events.
e. External Services/Dependencies
• AWS API (for both EC2 and RDS maintenance events).
• Chat Service API (Chatwork API) used for sending out notifications.
Interactions and Data Flow
• Once loaded, the configuration is provided to the AWS Maintenance Events Checker, which communicates with the AWS API (annotate this external dependency).
• After checking for maintenance events, the AWS Checker forwards relevant event data to the Notification Module.
• The Notification Module then sends the notifications to the external chat service (e.g., Chatwork), which is another external component.
Architectural Patterns or Design Principles
• Separation of Concerns: Different components (CLI parsing, configuration, AWS interaction, and notification) discretely handle responsibilities.
• Modularity: Each component is loosely coupled, facilitating potential future extensions (e.g., adding more notification channels or additional AWS resource checks).
• Clear Data Flow: The pathway from command invocation to configuration loading, event checking, and notification dispatch is straightforward and easy to follow.
• CLI Interface Component (main.go and cmd package)
• Configuration Loader/Parser
• AWS Maintenance Event Checker
• Notification Module (with Chatwork specifics)
• External dependencies marked for AWS and Chat service
• CLI Command → Config Loader → AWS Checker → Notification Module → External Chat Service
• Optional: Error handling or feedback loops (if such components exist in the code)