feat(configuration): name the instance with ARCHIE_INSTANCE and scope default paths by it
This commit is contained in:
9 files changed
+75
-26
No files matched your search
@@ -18,12 +18,7 @@ import (
|
||||
const defaultDrainPollInterval = 5 * time.Second
|
||||
|
||||
// DefaultDrainRequestPath returns the marker file path the daemon watches. It
|
||||
// lives under the config home (${XDG_CONFIG_HOME:-~/.config}/archie) -- the
|
||||
// established convention for archied's per-user paths -- rather than the
|
||||
// epic's literal ~/.archie, which is not a path this daemon ever uses. The
|
||||
// discrepancy is intentional: every other archied path reads from the XDG
|
||||
// config home, so the drain marker must too, or an operator pointing at the
|
||||
// documented location would miss it.
|
||||
// lives in the instance's config directory.
|
||||
func DefaultDrainRequestPath() string {
|
||||
return filepath.Join(configuration.DefaultConfigDir(), drainio.DefaultMarkerFilename)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package archied
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
|
||||
@@ -11,6 +10,7 @@ import (
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/storepkg"
|
||||
"github.com/samcharles93/archie-core/internal/forge"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/extension"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/forgeext"
|
||||
)
|
||||
@@ -27,7 +27,7 @@ type forgeExtensions struct {
|
||||
}
|
||||
|
||||
func newForgeExtensions(source extension.Source, log *slog.Logger) *forgeExtensions {
|
||||
cache, err := os.UserCacheDir()
|
||||
cache, err := configuration.DefaultCacheDir()
|
||||
if err != nil {
|
||||
log.Warn("forge extensions unavailable: no cache directory", "err", err)
|
||||
return nil
|
||||
@@ -35,7 +35,7 @@ func newForgeExtensions(source extension.Source, log *slog.Logger) *forgeExtensi
|
||||
return &forgeExtensions{
|
||||
host: extension.NewHost(hclog.New(&hclog.LoggerOptions{Name: "extension", Level: hclog.Warn})),
|
||||
source: source,
|
||||
cacheDir: filepath.Join(cache, "archie", "extensions", "forge"),
|
||||
cacheDir: filepath.Join(cache, "extensions", "forge"),
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,12 +254,7 @@ func updateStateDir() string {
|
||||
if dir := os.Getenv("ARCHIE_UPDATE_STATE_DIR"); dir != "" {
|
||||
return dir
|
||||
}
|
||||
dir := os.Getenv("XDG_STATE_HOME")
|
||||
if dir == "" {
|
||||
home, _ := os.UserHomeDir()
|
||||
dir = filepath.Join(home, ".local", "state")
|
||||
}
|
||||
return filepath.Join(dir, "archie", "update")
|
||||
return configuration.DefaultUpdateStateDir()
|
||||
}
|
||||
|
||||
// resumeUpdate hands an interrupted transaction to the frozen watchdog and
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
@@ -14,6 +13,7 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/channels"
|
||||
"github.com/samcharles93/archie-core/internal/domain/storepkg"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/channelext"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/extension"
|
||||
"github.com/samcharles93/archie-core/internal/secret"
|
||||
)
|
||||
@@ -26,7 +26,7 @@ const refSuffix = "_ref"
|
||||
// the set takes a restart, as every channel binding does. Running extensions
|
||||
// stop with ctx.
|
||||
func openExtensionChannels(ctx context.Context, source extension.Source, secrets *secret.Registry, log *slog.Logger) []*channelInstance {
|
||||
cache, err := os.UserCacheDir()
|
||||
cache, err := configuration.DefaultCacheDir()
|
||||
if err != nil {
|
||||
log.Warn("channel extensions unavailable: no cache directory", "err", err)
|
||||
return nil
|
||||
@@ -52,7 +52,7 @@ func openExtensionChannels(ctx context.Context, source extension.Source, secrets
|
||||
if index < 0 {
|
||||
continue
|
||||
}
|
||||
ch, err := buildExtensionChannel(ctx, host, source, filepath.Join(cache, "archie", "extensions", "channels"), pkg, pkg.Descriptor.Contributes.Extensions[index].Path, setting.Settings, secrets)
|
||||
ch, err := buildExtensionChannel(ctx, host, source, filepath.Join(cache, "extensions", "channels"), pkg, pkg.Descriptor.Contributes.Extensions[index].Path, setting.Settings, secrets)
|
||||
if err != nil {
|
||||
log.Warn("channel extension not started", "channel", pkg.Name, "err", err)
|
||||
continue
|
||||
|
||||
Reference in new issue
Block a user