mirror of
https://github.com/cirruslabs/tart.git
synced 2026-10-18 21:47:08 +02:00
* Support pulling/pushing VMs to OCI-compatible registries
* Registry: rename request() to endpointRequest() for clarity
* Registry: include JSON details on HTTP status code mismatch errors
* .cirrus.yml: run tests
* Fix testDigest
* Registry: set Content-{Length,Type} headers when pushing blob
* Refactor Registry.auth() and enrich RegistryError.AuthFailed
* Remove useless comment
* Fix WWWAuthenticate a bit and add tests
* WWWAuthenticate: expect a Bearer scheme
* Registry.auth(): document the passing of ["scope", "service"] parameters
* Clarify unexpected HTTP code error when retrieving auth token
* Make RemoteName parser more relaxed for now
* tart clone: pull the VM if it's OCI-based first
* VMStorageOCI: ensure the old symbolic link is overwritten
* tart push: support multiple remote VM names
* Logging: push/pull progress
* Use 500 MB chunks (instead of 500 MiB) to evenly cut disk
...which also uses powers of 10.
* Credentials: only read credentials labeled "Tart Credentials"
28 lines
471 B
Swift
28 lines
471 B
Swift
import Foundation
|
|
import CryptoKit
|
|
|
|
class Digest {
|
|
var hash: SHA256 = SHA256()
|
|
|
|
func update(_ data: Data) {
|
|
hash.update(data: data)
|
|
}
|
|
|
|
func finalize() -> String {
|
|
hash.finalize().hexdigest()
|
|
}
|
|
|
|
static func hash(_ data: Data) -> String {
|
|
SHA256.hash(data: data).hexdigest()
|
|
}
|
|
}
|
|
|
|
extension SHA256.Digest {
|
|
func hexdigest() -> String {
|
|
"sha256:" + self.map {
|
|
String(format: "%02x", $0)
|
|
}
|
|
.joined()
|
|
}
|
|
}
|