mirror of
https://github.com/apple/container.git
synced 2026-09-24 08:35:36 +00:00
Replace scattered defaults subcommands with system property. (#604)
Common subcommands for all defaults. - Closes #384. - Replaces `registry default` and `system dns default` subcommands with `system property`. - Users can use `system property ls` to see details about each supported default value. - `system property set` implements reasonable validation for all properties. - NOTE: Probing of the registry for `registry default set` was removed, which means users will find out about a botched setting when pulling or pushing. - Updates docs. ## Type of Change - [ ] Bug fix - [x] New feature - [x] Breaking change - [x] Documentation update ## Motivation and Context See #384. ## Testing - [x] Tested locally - [x] Added/updated tests - [x] Added/updated docs
This commit is contained in:
@@ -640,4 +640,32 @@ public struct Parser {
|
||||
"invalid publish-socket format \(socketText). Expected: host_path:container_path")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: DNS
|
||||
|
||||
public static func isValidDomainName(_ name: String) -> Bool {
|
||||
guard !name.isEmpty && name.count <= 255 else {
|
||||
return false
|
||||
}
|
||||
return name.components(separatedBy: ".").allSatisfy { Self.isValidDomainNameLabel($0) }
|
||||
}
|
||||
|
||||
public static func isValidDomainNameLabel(_ label: String) -> Bool {
|
||||
guard !label.isEmpty && label.count <= 63 else {
|
||||
return false
|
||||
}
|
||||
let pattern = #/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?$/#
|
||||
return !label.ranges(of: pattern).isEmpty
|
||||
}
|
||||
|
||||
// MARK: Miscellaneous
|
||||
|
||||
public static func parseBool(string: String) -> Bool? {
|
||||
let lower = string.lowercased()
|
||||
switch lower {
|
||||
case "true", "t": return true
|
||||
case "false", "f": return false
|
||||
default: return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user