Skip to content

Commit 2dc824a

Browse files
committed
rename memoryString to memoryStringAsMiB
1 parent 3d6bdec commit 2dc824a

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

Sources/ContainerCommands/System/Property/PropertySet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ extension Application {
7575
}
7676
DefaultsStore.set(value: value, key: key)
7777
case .defaultContainerMemory:
78-
guard let memoryMiB = try? Parser.memoryString(value), memoryMiB > 0 else {
78+
guard let memoryMiB = try? Parser.memoryStringAsMiB(value), memoryMiB > 0 else {
7979
throw ContainerizationError(.invalidArgument, message: "invalid memory value: \(value)")
8080
}
8181
DefaultsStore.set(value: value, key: key)

Sources/Services/ContainerAPIService/Client/Parser.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public enum VolumeOrFilesystem {
4545
}
4646

4747
public struct Parser {
48-
public static func memoryString(_ memory: String) throws -> Int64 {
48+
public static func memoryStringAsMiB(_ memory: String) throws -> Int64 {
4949
let ram = try Measurement.parse(parsing: memory)
5050
let mb = ram.converted(to: .mebibytes)
5151
return Int64(mb.value)
@@ -97,9 +97,9 @@ public struct Parser {
9797
resource.cpus = cpuVal
9898
}
9999
if let memory {
100-
resource.memoryInBytes = try Parser.memoryString(memory).mib()
100+
resource.memoryInBytes = try Parser.memoryStringAsMiB(memory).mib()
101101
} else if let memStr = DefaultsStore.getOptional(key: .defaultContainerMemory) {
102-
resource.memoryInBytes = try Parser.memoryString(memStr).mib()
102+
resource.memoryInBytes = try Parser.memoryStringAsMiB(memStr).mib()
103103
}
104104
return resource
105105
}
@@ -403,7 +403,7 @@ public struct Parser {
403403
throw ContainerizationError(.invalidArgument, message: "unsupported option size for \(type) mount")
404404
}
405405
var overflow: Bool
406-
var memory = try Parser.memoryString(val)
406+
var memory = try Parser.memoryStringAsMiB(val)
407407
(memory, overflow) = memory.multipliedReportingOverflow(by: 1024 * 1024)
408408
if overflow {
409409
throw ContainerizationError(.invalidArgument, message: "overflow encountered when parsing memory string: \(val)")

0 commit comments

Comments
 (0)