From 0ca211c98395a9d17e115448d019a210b5abfc65 Mon Sep 17 00:00:00 2001 From: anonpenguin23 Date: Tue, 11 Nov 2025 17:08:56 +0200 Subject: [PATCH] refactor: update config paths for gateway.yaml - Changed the default configuration path for gateway.yaml to prioritize the ~/.debros/data/ directory, ensuring better organization and clarity. - Updated related functions to reflect the new path structure, maintaining backward compatibility with existing configurations. - Adjusted service execution commands to align with the new configuration path, enhancing deployment consistency. --- CHANGELOG.md | 14 ++++++++++++++ Makefile | 2 +- cmd/gateway/config.go | 2 +- pkg/config/paths.go | 12 +++++++++++- pkg/environments/production/config.go | 11 +++++++++-- pkg/environments/production/services.go | 2 +- pkg/environments/templates/systemd_gateway.service | 2 +- 7 files changed, 38 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70af0d5..1a75911 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,20 @@ The format is based on [Keep a Changelog][keepachangelog] and adheres to [Semant ### Deprecated ### Fixed +## [0.69.5] - 2025-11-11 + +### Added +\n +### Changed +- Moved the default location for `gateway.yaml` configuration file from `configs/` to the new `data/` directory for better organization. +- Updated configuration path logic to search for `gateway.yaml` in the new `data/` directory first. + +### Deprecated + +### Removed + +### Fixed +\n ## [0.69.4] - 2025-11-11 ### Added diff --git a/Makefile b/Makefile index 5f48f6f..93d3c9a 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ test-e2e: .PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports install-hooks kill -VERSION := 0.69.4 +VERSION := 0.69.5 COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown) DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ) LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)' diff --git a/cmd/gateway/config.go b/cmd/gateway/config.go index 74f6f13..1f76866 100644 --- a/cmd/gateway/config.go +++ b/cmd/gateway/config.go @@ -63,7 +63,7 @@ func parseGatewayConfig(logger *logging.ColoredLogger) *gateway.Config { } } } else { - // Default behavior: look for gateway.yaml in ~/.debros/configs/ or ~/.debros/ + // Default behavior: look for gateway.yaml in ~/.debros/data/, ~/.debros/configs/, or ~/.debros/ configPath, err = config.DefaultPath("gateway.yaml") if err != nil { logger.ComponentError(logging.ComponentGeneral, "Failed to determine config path", zap.Error(err)) diff --git a/pkg/config/paths.go b/pkg/config/paths.go index 249a389..c55b41e 100644 --- a/pkg/config/paths.go +++ b/pkg/config/paths.go @@ -29,7 +29,7 @@ func EnsureConfigDir() (string, error) { // DefaultPath returns the path to the config file for the given component name. // component should be e.g., "node.yaml", "bootstrap.yaml", "gateway.yaml" -// It checks both ~/.debros/ and ~/.debros/configs/ for backward compatibility. +// It checks ~/.debros/data/, ~/.debros/configs/, and ~/.debros/ for backward compatibility. // If component is already an absolute path, it returns it as-is. func DefaultPath(component string) (string, error) { // If component is already an absolute path, return it directly @@ -42,6 +42,16 @@ func DefaultPath(component string) (string, error) { return "", err } + // For gateway.yaml, check data/ directory first (production location) + if component == "gateway.yaml" { + dataPath := filepath.Join(dir, "data", component) + if _, err := os.Stat(dataPath); err == nil { + return dataPath, nil + } + // Return data path as default for gateway.yaml (even if it doesn't exist yet) + return dataPath, nil + } + // First check in ~/.debros/configs/ (production installer location) configsPath := filepath.Join(dir, "configs", component) if _, err := os.Stat(configsPath); err == nil { diff --git a/pkg/environments/production/config.go b/pkg/environments/production/config.go index 7351e90..58ee253 100644 --- a/pkg/environments/production/config.go +++ b/pkg/environments/production/config.go @@ -224,9 +224,16 @@ func (sg *SecretGenerator) EnsureNodeIdentity(nodeType string) (peer.ID, error) // SaveConfig writes a configuration file to disk func (sg *SecretGenerator) SaveConfig(filename string, content string) error { - configDir := filepath.Join(sg.debrosDir, "configs") + var configDir string + // gateway.yaml goes to data/ directory, other configs go to configs/ + if filename == "gateway.yaml" { + configDir = filepath.Join(sg.debrosDir, "data") + } else { + configDir = filepath.Join(sg.debrosDir, "configs") + } + if err := os.MkdirAll(configDir, 0755); err != nil { - return fmt.Errorf("failed to create configs directory: %w", err) + return fmt.Errorf("failed to create config directory: %w", err) } configPath := filepath.Join(configDir, filename) diff --git a/pkg/environments/production/services.go b/pkg/environments/production/services.go index deacb6f..fd6b615 100644 --- a/pkg/environments/production/services.go +++ b/pkg/environments/production/services.go @@ -245,7 +245,7 @@ User=debros Group=debros WorkingDirectory=%s Environment=HOME=%s -ExecStart=%s/bin/gateway --config %s/configs/gateway.yaml + ExecStart=%s/bin/gateway --config %s/data/gateway.yaml Restart=always RestartSec=5 StandardOutput=file:%s diff --git a/pkg/environments/templates/systemd_gateway.service b/pkg/environments/templates/systemd_gateway.service index 4e490f2..1491f87 100644 --- a/pkg/environments/templates/systemd_gateway.service +++ b/pkg/environments/templates/systemd_gateway.service @@ -9,7 +9,7 @@ User=debros Group=debros WorkingDirectory={{.HomeDir}} Environment=HOME={{.HomeDir}} -ExecStart={{.HomeDir}}/bin/gateway --config {{.DebrosDir}}/configs/gateway.yaml +ExecStart={{.HomeDir}}/bin/gateway --config {{.DebrosDir}}/data/gateway.yaml Restart=always RestartSec=5 StandardOutput=journal