config

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

README

Event Type Configuration

Customize Argus for your use case by defining custom event types, actions, and actor/target types. This allows you to tailor audit logging to your specific domain requirements.

Configuration File

File: configs/enums.yaml

When integrating Argus, you can customize the allowed values for:

  • Event Types: Define your own event types (e.g., MANAGEMENT_EVENT, USER_MANAGEMENT)
  • Event Actions: CRUD operations (e.g., CREATE, READ, UPDATE, DELETE)
  • Actor Types: Types of actors in your system (e.g., SERVICE, ADMIN, MEMBER, SYSTEM)
  • Target Types: Types of targets (e.g., SERVICE, RESOURCE, USER, ORDER)

Usage

When you deploy Argus, the configuration is automatically loaded at startup:

  1. Argus looks for configs/enums.yaml in the working directory
  2. If not found, uses sensible defaults
  3. If the file is invalid, logs a warning and uses defaults

For Docker deployments, mount your custom enums.yaml:

docker run -v /path/to/your/enums.yaml:/app/configs/enums.yaml argus
Custom Configuration Path

You can specify a custom path using the AUDIT_ENUMS_CONFIG environment variable:

AUDIT_ENUMS_CONFIG=/path/to/custom/enums.yaml ./argus

Customizing for Your Integration

Add your own event types and values to match your domain:

enums:
  eventTypes:
    - MANAGEMENT_EVENT
    - MANAGEMENT_EVENT
    - ORDER_CREATED          # Your custom event
    - USER_REGISTERED        # Your custom event
  
  actorTypes:
    - SERVICE
    - ADMIN
    - MEMBER
    - SYSTEM
    - CUSTOMER               # Your custom actor type
  
  targetTypes:
    - SERVICE
    - RESOURCE
    - ORDER                  # Your custom target type

After updating configs/enums.yaml, restart Argus to apply changes.

Validation Behavior

When your services send audit events to Argus:

  • Invalid enum values → Rejected with 400 Bad Request
  • Optional fields (eventType, eventAction) → Can be null/empty
  • Required fields (actorType, targetType) → Must match configured values

This ensures data consistency and helps catch integration errors early.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultEnums provides default enum values if config file is not found
	// Generic default event types - customize via enums.yaml for your project
	DefaultEnums = AuditEnums{
		EventTypes: []string{
			"MANAGEMENT_EVENT",
			"USER_MANAGEMENT",
			"DATA_FETCH",
		},
		EventActions: []string{
			"CREATE",
			"READ",
			"UPDATE",
			"DELETE",
		},
		ActorTypes: []string{
			"SERVICE",
			"ADMIN",
			"MEMBER",
			"SYSTEM",
		},
		TargetTypes: []string{
			"SERVICE",
			"RESOURCE",
		},
	}
)

Functions

func GetEnvOrDefault

func GetEnvOrDefault(key, defaultValue string) string

GetEnvOrDefault returns the environment variable value or a default This is a utility function for reading environment variables with defaults

Types

type AuditEnums

type AuditEnums struct {
	EventTypes   []string `yaml:"eventTypes"`
	EventActions []string `yaml:"eventActions"`
	ActorTypes   []string `yaml:"actorTypes"`
	TargetTypes  []string `yaml:"targetTypes"`
	// contains filtered or unexported fields
}

AuditEnums represents the enum configuration for audit service All enum values are configurable via YAML for maximum reusability

func GetDefaultEnums

func GetDefaultEnums() *AuditEnums

GetDefaultEnums creates a new AuditEnums instance with default values Slices are copied to avoid sharing references with the global DefaultEnums

func LoadEnums

func LoadEnums(configPath string) (*AuditEnums, error)

LoadEnums loads enum configuration from YAML file If the file is not found or cannot be read, returns default enums

func (*AuditEnums) InitializeMaps

func (e *AuditEnums) InitializeMaps()

InitializeMaps converts slices to maps for O(1) validation lookups Uses sync.Once to ensure thread-safe initialization that happens only once This is called automatically by LoadEnums, but can be called manually for testing

func (*AuditEnums) IsValidActorType

func (e *AuditEnums) IsValidActorType(actorType string) bool

IsValidActorType checks if the given actor type is valid

func (*AuditEnums) IsValidEventAction

func (e *AuditEnums) IsValidEventAction(action string) bool

IsValidEventAction checks if the given event action is valid

func (*AuditEnums) IsValidEventType

func (e *AuditEnums) IsValidEventType(eventType string) bool

IsValidEventType checks if the given event type is valid

func (*AuditEnums) IsValidTargetType

func (e *AuditEnums) IsValidTargetType(targetType string) bool

IsValidTargetType checks if the given target type is valid

type Config

type Config struct {
	Enums AuditEnums `yaml:"enums"`
}

Config holds the audit service configuration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL