feat: add header for mirror mode (#644)

Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
Gaius 2024-08-02 17:48:35 +08:00 committed by GitHub
parent 0bc8ce9529
commit aee6a66c08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 17 deletions

16
Cargo.lock generated
View File

@ -1118,7 +1118,7 @@ dependencies = [
[[package]] [[package]]
name = "dragonfly-client" name = "dragonfly-client"
version = "0.1.92" version = "0.1.93"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"blake3", "blake3",
@ -1188,7 +1188,7 @@ dependencies = [
[[package]] [[package]]
name = "dragonfly-client-backend" name = "dragonfly-client-backend"
version = "0.1.92" version = "0.1.93"
dependencies = [ dependencies = [
"dragonfly-api", "dragonfly-api",
"dragonfly-client-core", "dragonfly-client-core",
@ -1210,7 +1210,7 @@ dependencies = [
[[package]] [[package]]
name = "dragonfly-client-config" name = "dragonfly-client-config"
version = "0.1.92" version = "0.1.93"
dependencies = [ dependencies = [
"bytesize", "bytesize",
"bytesize-serde", "bytesize-serde",
@ -1231,7 +1231,7 @@ dependencies = [
[[package]] [[package]]
name = "dragonfly-client-core" name = "dragonfly-client-core"
version = "0.1.92" version = "0.1.93"
dependencies = [ dependencies = [
"hyper 1.4.0", "hyper 1.4.0",
"hyper-util", "hyper-util",
@ -1246,7 +1246,7 @@ dependencies = [
[[package]] [[package]]
name = "dragonfly-client-init" name = "dragonfly-client-init"
version = "0.1.92" version = "0.1.93"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",
@ -1262,7 +1262,7 @@ dependencies = [
[[package]] [[package]]
name = "dragonfly-client-storage" name = "dragonfly-client-storage"
version = "0.1.92" version = "0.1.93"
dependencies = [ dependencies = [
"base16ct", "base16ct",
"blake3", "blake3",
@ -1286,7 +1286,7 @@ dependencies = [
[[package]] [[package]]
name = "dragonfly-client-util" name = "dragonfly-client-util"
version = "0.1.92" version = "0.1.93"
dependencies = [ dependencies = [
"base16ct", "base16ct",
"blake3", "blake3",
@ -1755,7 +1755,7 @@ dependencies = [
[[package]] [[package]]
name = "hdfs" name = "hdfs"
version = "0.1.92" version = "0.1.93"
dependencies = [ dependencies = [
"dragonfly-client-backend", "dragonfly-client-backend",
"dragonfly-client-core", "dragonfly-client-core",

View File

@ -12,7 +12,7 @@ members = [
] ]
[workspace.package] [workspace.package]
version = "0.1.92" version = "0.1.93"
authors = ["The Dragonfly Developers"] authors = ["The Dragonfly Developers"]
homepage = "https://d7y.io/" homepage = "https://d7y.io/"
repository = "https://github.com/dragonflyoss/client.git" repository = "https://github.com/dragonflyoss/client.git"
@ -22,13 +22,13 @@ readme = "README.md"
edition = "2021" edition = "2021"
[workspace.dependencies] [workspace.dependencies]
dragonfly-client = { path = "dragonfly-client", version = "0.1.92" } dragonfly-client = { path = "dragonfly-client", version = "0.1.93" }
dragonfly-client-core = { path = "dragonfly-client-core", version = "0.1.92" } dragonfly-client-core = { path = "dragonfly-client-core", version = "0.1.93" }
dragonfly-client-config = { path = "dragonfly-client-config", version = "0.1.92" } dragonfly-client-config = { path = "dragonfly-client-config", version = "0.1.93" }
dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.1.92" } dragonfly-client-storage = { path = "dragonfly-client-storage", version = "0.1.93" }
dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.1.92" } dragonfly-client-backend = { path = "dragonfly-client-backend", version = "0.1.93" }
dragonfly-client-util = { path = "dragonfly-client-util", version = "0.1.92" } dragonfly-client-util = { path = "dragonfly-client-util", version = "0.1.93" }
dragonfly-client-init = { path = "dragonfly-client-init", version = "0.1.92" } dragonfly-client-init = { path = "dragonfly-client-init", version = "0.1.93" }
thiserror = "1.0" thiserror = "1.0"
dragonfly-api = "2.0.141" dragonfly-api = "2.0.141"
reqwest = { version = "0.12.4", features = ["stream", "native-tls", "default-tls", "rustls-tls"] } reqwest = { version = "0.12.4", features = ["stream", "native-tls", "default-tls", "rustls-tls"] }

View File

@ -204,11 +204,16 @@ impl Containerd {
// Add endpoints to the mirror configuration. // Add endpoints to the mirror configuration.
let mut endpoints = Array::default(); let mut endpoints = Array::default();
endpoints.push(Value::from(proxy_config.addr.clone())); endpoints.push(Value::from(proxy_config.addr.clone()));
endpoints.push(Value::from(registry.server_addr)); endpoints.push(Value::from(registry.server_addr.clone()));
let mut mirror_table = Table::new(); let mut mirror_table = Table::new();
mirror_table.insert("endpoint", value(endpoints)); mirror_table.insert("endpoint", value(endpoints));
// Add X-Dragonfly-Registry header to the mirror configuration.
let mut headers_table = Table::new();
headers_table.insert(DRAGONFLY_REGISTRY_HEADER, value(registry.server_addr));
mirror_table.insert("header", Item::Table(headers_table));
mirrors_table.insert(&registry.host_namespace, Item::Table(mirror_table)); mirrors_table.insert(&registry.host_namespace, Item::Table(mirror_table));
} }