Skip to content

Commit 9da3975

Browse files
committed
Replace SystemRuntimeOptions with PathUtils + ConfigurationLoader
Separates path resolution (PathUtils) from TOML loading (ConfigurationLoader) in ContainerPersistence. - PathUtils: resolves base paths for .home (XDG priority) and .appRoot - ConfigurationLoader: load() reads from appRoot, copyConfigToAppRoot() syncs user config with non-throwing error logging - ContainerSystemConfig: now non-final with Initable conformance - All ~17 callsites simplified to ConfigurationLoader.load()
1 parent 560f395 commit 9da3975

25 files changed

Lines changed: 258 additions & 450 deletions

Sources/APIServer/APIServer+Start.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ extension APIServer {
5050
var logRoot = LogRoot.path
5151

5252
func run() async throws {
53-
let containerSystemConfig: ContainerSystemConfig = try SystemRuntimeOptions.loadConfig(
54-
configFile: SystemRuntimeOptions.configFileFromAppRoot(ApplicationRoot.url)
55-
)
53+
let containerSystemConfig: ContainerSystemConfig = try ConfigurationLoader.load()
5654
let commandName = APIServer._commandName
5755
let logPath = logRoot.map { $0.appending("\(commandName).log") }
5856
let log = ServiceLogger.bootstrap(category: "APIServer", debug: debug, logPath: logPath)

Sources/ContainerCommands/BuildCommand.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,7 @@ extension Application {
149149
var pull: Bool = false
150150

151151
public func run() async throws {
152-
let containerSystemConfig: ContainerSystemConfig = try SystemRuntimeOptions.loadConfig(
153-
configFile: SystemRuntimeOptions.configFileFromAppRoot(ApplicationRoot.url)
154-
)
152+
let containerSystemConfig: ContainerSystemConfig = try ConfigurationLoader.load()
155153
do {
156154
let timeout: Duration = .seconds(300)
157155
let progressConfig = try ProgressConfig(

Sources/ContainerCommands/Builder/BuilderStart.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ extension Application {
5555
public init() {}
5656

5757
public func run() async throws {
58-
let containerSystemConfig: ContainerSystemConfig = try SystemRuntimeOptions.loadConfig(
59-
configFile: SystemRuntimeOptions.configFileFromAppRoot(ApplicationRoot.url)
60-
)
58+
let containerSystemConfig: ContainerSystemConfig = try ConfigurationLoader.load()
6159
let progressConfig = try ProgressConfig(
6260
showTasks: true,
6361
showItems: true,

Sources/ContainerCommands/Container/ContainerCreate.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ extension Application {
5656
var arguments: [String] = []
5757

5858
public func run() async throws {
59-
let containerSystemConfig: ContainerSystemConfig = try SystemRuntimeOptions.loadConfig(
60-
configFile: SystemRuntimeOptions.configFileFromAppRoot(ApplicationRoot.url)
61-
)
59+
let containerSystemConfig: ContainerSystemConfig = try ConfigurationLoader.load()
6260
let progressConfig = try ProgressConfig(
6361
showTasks: true,
6462
showItems: true,

Sources/ContainerCommands/Container/ContainerRun.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ extension Application {
6363
var arguments: [String] = []
6464

6565
public func run() async throws {
66-
let containerSystemConfig: ContainerSystemConfig = try SystemRuntimeOptions.loadConfig(
67-
configFile: SystemRuntimeOptions.configFileFromAppRoot(ApplicationRoot.url)
68-
)
66+
let containerSystemConfig: ContainerSystemConfig = try ConfigurationLoader.load()
6967
var exitCode: Int32 = 127
7068
let id = Utility.createContainerID(name: self.managementFlags.name)
7169

Sources/ContainerCommands/Image/ImageDelete.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ extension Application {
109109
}
110110

111111
public mutating func run() async throws {
112-
let containerSystemConfig: ContainerSystemConfig = try SystemRuntimeOptions.loadConfig(
113-
configFile: SystemRuntimeOptions.configFileFromAppRoot(ApplicationRoot.url)
114-
)
112+
let containerSystemConfig: ContainerSystemConfig = try ConfigurationLoader.load()
115113
try await DeleteImageImplementation.removeImage(options: options, containerSystemConfig: containerSystemConfig, log: log)
116114
}
117115
}

Sources/ContainerCommands/Image/ImageInspect.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ extension Application {
4545
}
4646

4747
public func run() async throws {
48-
let containerSystemConfig: ContainerSystemConfig = try SystemRuntimeOptions.loadConfig(
49-
configFile: SystemRuntimeOptions.configFileFromAppRoot(ApplicationRoot.url)
50-
)
48+
let containerSystemConfig: ContainerSystemConfig = try ConfigurationLoader.load()
5149
var printable: [ImageDetail] = []
5250
var succeededImages: [String] = []
5351
var allErrors: [(String, Error)] = []

Sources/ContainerCommands/Image/ImageList.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ extension Application {
4545
public var logOptions: Flags.Logging
4646

4747
public mutating func run() async throws {
48-
let containerSystemConfig: ContainerSystemConfig = try SystemRuntimeOptions.loadConfig(
49-
configFile: SystemRuntimeOptions.configFileFromAppRoot(ApplicationRoot.url)
50-
)
48+
let containerSystemConfig: ContainerSystemConfig = try ConfigurationLoader.load()
5149
try Self.validate(format: format, quiet: quiet, verbose: verbose)
5250

5351
var images = try await ClientImage.list().filter { img in

Sources/ContainerCommands/Image/ImagePull.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ extension Application {
6969
}
7070

7171
public func run() async throws {
72-
let containerSystemConfig: ContainerSystemConfig = try SystemRuntimeOptions.loadConfig(
73-
configFile: SystemRuntimeOptions.configFileFromAppRoot(ApplicationRoot.url)
74-
)
72+
let containerSystemConfig: ContainerSystemConfig = try ConfigurationLoader.load()
7573
let p = try DefaultPlatform.resolve(platform: platform, os: os, arch: arch, log: log)
7674

7775
let scheme = try RequestScheme(registry.scheme)

Sources/ContainerCommands/Image/ImagePush.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ extension Application {
5757
public init() {}
5858

5959
public func run() async throws {
60-
let containerSystemConfig: ContainerSystemConfig = try SystemRuntimeOptions.loadConfig(
61-
configFile: SystemRuntimeOptions.configFileFromAppRoot(ApplicationRoot.url)
62-
)
60+
let containerSystemConfig: ContainerSystemConfig = try ConfigurationLoader.load()
6361
let p = try DefaultPlatform.resolve(platform: platform, os: os, arch: arch, log: log)
6462

6563
let scheme = try RequestScheme(registry.scheme)

0 commit comments

Comments
 (0)