Merge pull request 'upgrade Nix toolchain' (#400) from upgrade-toolchain into main

Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/400
This commit is contained in:
Alex 2022-10-18 14:16:52 +00:00
commit 7bc9fd34b2
16 changed files with 2395 additions and 2277 deletions

View file

@ -19,9 +19,11 @@ steps:
- name: unit + func tests - name: unit + func tests
image: nixpkgs/nix:nixos-22.05 image: nixpkgs/nix:nixos-22.05
environment: environment:
GARAGE_TEST_INTEGRATION_EXE: result/bin/garage GARAGE_TEST_INTEGRATION_EXE: result-bin/bin/garage
commands: commands:
- nix-build --no-build-output --attr clippy.amd64 --argstr git_version ${DRONE_TAG:-$DRONE_COMMIT}
- nix-build --no-build-output --attr test.amd64 - nix-build --no-build-output --attr test.amd64
- ./result/bin/garage_db-*
- ./result/bin/garage_api-* - ./result/bin/garage_api-*
- ./result/bin/garage_model-* - ./result/bin/garage_model-*
- ./result/bin/garage_rpc-* - ./result/bin/garage_rpc-*
@ -30,6 +32,7 @@ steps:
- ./result/bin/garage_web-* - ./result/bin/garage_web-*
- ./result/bin/garage-* - ./result/bin/garage-*
- ./result/bin/integration-* - ./result/bin/integration-*
- rm result
- name: integration tests - name: integration tests
image: nixpkgs/nix:nixos-22.05 image: nixpkgs/nix:nixos-22.05
@ -58,7 +61,7 @@ steps:
image: nixpkgs/nix:nixos-22.05 image: nixpkgs/nix:nixos-22.05
commands: commands:
- nix-build --no-build-output --attr pkgs.amd64.release --argstr git_version ${DRONE_TAG:-$DRONE_COMMIT} - nix-build --no-build-output --attr pkgs.amd64.release --argstr git_version ${DRONE_TAG:-$DRONE_COMMIT}
- nix-shell --attr rust --run "./script/not-dynamic.sh result/bin/garage" - nix-shell --attr rust --run "./script/not-dynamic.sh result-bin/bin/garage"
- name: integration - name: integration
image: nixpkgs/nix:nixos-22.05 image: nixpkgs/nix:nixos-22.05
@ -109,7 +112,7 @@ steps:
image: nixpkgs/nix:nixos-22.05 image: nixpkgs/nix:nixos-22.05
commands: commands:
- nix-build --no-build-output --attr pkgs.i386.release --argstr git_version ${DRONE_TAG:-$DRONE_COMMIT} - nix-build --no-build-output --attr pkgs.i386.release --argstr git_version ${DRONE_TAG:-$DRONE_COMMIT}
- nix-shell --attr rust --run "./script/not-dynamic.sh result/bin/garage" - nix-shell --attr rust --run "./script/not-dynamic.sh result-bin/bin/garage"
- name: integration - name: integration
image: nixpkgs/nix:nixos-22.05 image: nixpkgs/nix:nixos-22.05
@ -159,7 +162,7 @@ steps:
image: nixpkgs/nix:nixos-22.05 image: nixpkgs/nix:nixos-22.05
commands: commands:
- nix-build --no-build-output --attr pkgs.arm64.release --argstr git_version ${DRONE_TAG:-$DRONE_COMMIT} - nix-build --no-build-output --attr pkgs.arm64.release --argstr git_version ${DRONE_TAG:-$DRONE_COMMIT}
- nix-shell --attr rust --run "./script/not-dynamic.sh result/bin/garage" - nix-shell --attr rust --run "./script/not-dynamic.sh result-bin/bin/garage"
- name: push static binary - name: push static binary
image: nixpkgs/nix:nixos-22.05 image: nixpkgs/nix:nixos-22.05
@ -204,7 +207,7 @@ steps:
image: nixpkgs/nix:nixos-22.05 image: nixpkgs/nix:nixos-22.05
commands: commands:
- nix-build --no-build-output --attr pkgs.arm.release --argstr git_version ${DRONE_TAG:-$DRONE_COMMIT} - nix-build --no-build-output --attr pkgs.arm.release --argstr git_version ${DRONE_TAG:-$DRONE_COMMIT}
- nix-shell --attr rust --run "./script/not-dynamic.sh result/bin/garage" - nix-shell --attr rust --run "./script/not-dynamic.sh result-bin/bin/garage"
- name: push static binary - name: push static binary
image: nixpkgs/nix:nixos-22.05 image: nixpkgs/nix:nixos-22.05
@ -280,6 +283,6 @@ trigger:
--- ---
kind: signature kind: signature
hmac: 103a04785c98f5376a63ce22865c2576963019bbc4d828f200d2a470a3c821ea hmac: ac09a5a8c82502f67271f93afa1e1e21ce66383b8e24a6deb26b285cc1c378ba
... ...

534
Cargo.lock generated

File diff suppressed because it is too large Load diff

3846
Cargo.nix

File diff suppressed because it is too large Load diff

View file

@ -3,5 +3,5 @@ FROM scratch
ENV RUST_BACKTRACE=1 ENV RUST_BACKTRACE=1
ENV RUST_LOG=garage=info ENV RUST_LOG=garage=info
COPY result/bin/garage / COPY result-bin/bin/garage /
CMD [ "/garage", "server"] CMD [ "/garage", "server"]

View file

@ -8,10 +8,23 @@ with import ./nix/common.nix;
let let
pkgs = import pkgsSrc { }; pkgs = import pkgsSrc { };
compile = import ./nix/compile.nix; compile = import ./nix/compile.nix;
build_debug_and_release = (target: { build_debug_and_release = (target: {
debug = (compile { inherit target git_version; release = false; }).workspace.garage { compileMode = "build"; }; debug = (compile {
release = (compile { inherit target git_version; release = true; }).workspace.garage { compileMode = "build"; }; inherit target git_version;
release = false;
}).workspace.garage {
compileMode = "build";
};
release = (compile {
inherit target git_version;
release = true;
}).workspace.garage {
compileMode = "build";
};
}); });
test = (rustPkgs: pkgs.symlinkJoin { test = (rustPkgs: pkgs.symlinkJoin {
name ="garage-tests"; name ="garage-tests";
paths = builtins.map (key: rustPkgs.workspace.${key} { compileMode = "test"; }) (builtins.attrNames rustPkgs.workspace); paths = builtins.map (key: rustPkgs.workspace.${key} { compileMode = "test"; }) (builtins.attrNames rustPkgs.workspace);
@ -25,9 +38,25 @@ in {
arm = build_debug_and_release "armv6l-unknown-linux-musleabihf"; arm = build_debug_and_release "armv6l-unknown-linux-musleabihf";
}; };
test = { test = {
amd64 = test (compile { inherit git_version; target = "x86_64-unknown-linux-musl"; }); amd64 = test (compile {
inherit git_version;
target = "x86_64-unknown-linux-musl";
features = [
"garage/bundled-libs"
"garage/k2v"
"garage/sled"
"garage/lmdb"
"garage/sqlite"
];
});
}; };
clippy = { clippy = {
amd64 = (compile { inherit git_version; compiler = "clippy"; }).workspace.garage { compileMode = "build"; } ; amd64 = (compile {
inherit git_version;
target = "x86_64-unknown-linux-musl";
compiler = "clippy";
}).workspace.garage {
compileMode = "build";
};
}; };
} }

View file

@ -3,20 +3,20 @@ rec {
* Fixed dependencies * Fixed dependencies
*/ */
pkgsSrc = fetchTarball { pkgsSrc = fetchTarball {
# As of 2021-10-04 # As of 2022-10-13
url = "https://github.com/NixOS/nixpkgs/archive/b27d18a412b071f5d7991d1648cfe78ee7afe68a.tar.gz"; url = "https://github.com/NixOS/nixpkgs/archive/a3073c49bc0163fea6a121c276f526837672b555.zip";
sha256 = "1xy9zpypqfxs5gcq5dcla4bfkhxmh5nzn9dyqkr03lqycm9wg5cr"; sha256 = "1bz632psfbpmicyzjb8b4265y50shylccvfm6ry6mgnv5hvz324s";
}; };
cargo2nixSrc = fetchGit { cargo2nixSrc = fetchGit {
# As of 2022-08-29, stacking two patches: superboum@dedup_propagate and Alexis211@fix_fetchcrategit # As of 2022-10-18: two small patches over unstable branch, one for clippy and one to fix feature detection
url = "https://github.com/Alexis211/cargo2nix"; url = "https://github.com/Alexis211/cargo2nix";
ref = "fix_fetchcrategit"; ref = "custom_unstable";
rev = "4b31c0cc05b6394916d46e9289f51263d81973b9"; rev = "a7a61179b66054904ef6a195d8da736eaaa06c36";
}; };
/* /*
* Shared objects * Shared objects
*/ */
cargo2nix = import cargo2nixSrc; cargo2nix = import cargo2nixSrc;
cargo2nixOverlay = import "${cargo2nixSrc}/overlay"; cargo2nixOverlay = cargo2nix.overlays.default;
} }

View file

@ -1,9 +1,10 @@
{ {
system ? builtins.currentSystem, system ? builtins.currentSystem,
target ? null, target,
compiler ? "rustc", compiler ? "rustc",
release ? false, release ? false,
git_version ? null, git_version ? null,
features ? null,
}: }:
with import ./common.nix; with import ./common.nix;
@ -13,23 +14,18 @@ let
pkgs = import pkgsSrc { pkgs = import pkgsSrc {
inherit system; inherit system;
${ if target == null then null else "crossSystem" } = { config = target; }; crossSystem = {
config = target;
isStatic = true;
};
overlays = [ cargo2nixOverlay ]; overlays = [ cargo2nixOverlay ];
}; };
/*
Rust and Nix triples are not the same. Cargo2nix has a dedicated library
to convert Nix triples to Rust ones. We need this conversion as we want to
set later options linked to our (rust) target in a generic way. Not only
the triple terminology is different, but also the "roles" are named differently.
Nix uses a build/host/target terminology where Nix's "host" maps to Cargo's "target".
*/
rustTarget = log (pkgs.rustBuilder.rustLib.rustTriple pkgs.stdenv.hostPlatform);
/* /*
Cargo2nix is built for rustOverlay which installs Rust from Mozilla releases. Cargo2nix is built for rustOverlay which installs Rust from Mozilla releases.
We want our own Rust to avoid incompatibilities, like we had with musl 1.2.0. This is fine for 64-bit platforms, but for 32-bit platforms, we need our own Rust
rustc was built with musl < 1.2.0 and nix shipped musl >= 1.2.0 which lead to compilation breakage. to avoid incompatibilities with time_t between different versions of musl
(>= 1.2.0 shipped by NixOS, < 1.2.0 with which rustc was built), which lead to compilation breakage.
So we want a Rust release that is bound to our Nix repository to avoid these problems. So we want a Rust release that is bound to our Nix repository to avoid these problems.
See here for more info: https://musl.libc.org/time64.html See here for more info: https://musl.libc.org/time64.html
Because Cargo2nix does not support the Rust environment shipped by NixOS, Because Cargo2nix does not support the Rust environment shipped by NixOS,
@ -37,46 +33,21 @@ let
In practise, rustOverlay ships rustc+cargo in a single derivation while In practise, rustOverlay ships rustc+cargo in a single derivation while
NixOS ships them in separate ones. We reunite them with symlinkJoin. NixOS ships them in separate ones. We reunite them with symlinkJoin.
*/ */
rustChannel = { toolchainOptions =
rustc = pkgs.symlinkJoin { if target == "x86_64-unknown-linux-musl" || target == "aarch64-unknown-linux-musl" then {
name = "rust-channel"; rustVersion = "1.63.0";
extraRustComponents = [ "clippy" ];
} else {
rustToolchain = pkgs.symlinkJoin {
name = "rust-static-toolchain-${target}";
paths = [ paths = [
pkgs.rustPlatform.rust.cargo pkgs.rustPlatform.rust.cargo
pkgs.rustPlatform.rust.rustc pkgs.rustPlatform.rust.rustc
# clippy not needed, it only runs on amd64
]; ];
}; };
clippy = pkgs.symlinkJoin {
name = "clippy-channel";
paths = [
pkgs.rustPlatform.rust.cargo
pkgs.rustPlatform.rust.rustc
pkgs.clippy
];
}; };
}.${compiler};
clippyBuilder = pkgs.writeScriptBin "clippy" ''
#!${pkgs.stdenv.shell}
. ${cargo2nixSrc + "/overlay/utils.sh"}
isBuildScript=
args=("$@")
for i in "''${!args[@]}"; do
if [ "xmetadata=" = "x''${args[$i]::9}" ]; then
args[$i]=metadata=$NIX_RUST_METADATA
elif [ "x--crate-name" = "x''${args[$i]}" ] && [ "xbuild_script_" = "x''${args[$i+1]::13}" ]; then
isBuildScript=1
fi
done
if [ "$isBuildScript" ]; then
args+=($NIX_RUST_BUILD_LINK_FLAGS)
else
args+=($NIX_RUST_LINK_FLAGS)
fi
touch invoke.log
echo "''${args[@]}" >>invoke.log
exec ${rustChannel}/bin/clippy-driver --deny warnings "''${args[@]}"
'';
buildEnv = (drv: { buildEnv = (drv: {
rustc = drv.setBuildEnv; rustc = drv.setBuildEnv;
@ -86,7 +57,8 @@ let
echo --- BUILDING WITH CLIPPY --- echo --- BUILDING WITH CLIPPY ---
echo echo
export RUSTC=${clippyBuilder}/bin/clippy export NIX_RUST_BUILD_FLAGS="''${NIX_RUST_BUILD_FLAGS} --deny warnings"
export RUSTC="''${CLIPPY_DRIVER}"
''; '';
}.${compiler}); }.${compiler});
@ -97,7 +69,7 @@ let
You can have a complete list of the available options by looking at the overriden object, mkcrate: You can have a complete list of the available options by looking at the overriden object, mkcrate:
https://github.com/cargo2nix/cargo2nix/blob/master/overlay/mkcrate.nix https://github.com/cargo2nix/cargo2nix/blob/master/overlay/mkcrate.nix
*/ */
overrides = pkgs.rustBuilder.overrides.all ++ [ packageOverrides = pkgs: pkgs.rustBuilder.overrides.all ++ [
/* /*
[1] We add some logic to compile our crates with clippy, it provides us many additional lints [1] We add some logic to compile our crates with clippy, it provides us many additional lints
@ -113,12 +85,7 @@ let
As we do not want to consider the .git folder as part of the input source, As we do not want to consider the .git folder as part of the input source,
we ask the user (the CI often) to pass the value to Nix. we ask the user (the CI often) to pass the value to Nix.
[4] We ship some parts of the code disabled by default by putting them behind a flag. [4] We don't want libsodium-sys and zstd-sys to try to use pkgconfig to build against a system library.
It speeds up the compilation (when the feature is not required) and released crates have less dependency by default (less attack surface, disk space, etc.).
But we want to ship these additional features when we release Garage.
In the end, we chose to exclude all features from debug builds while putting (all of) them in the release builds.
[5] We don't want libsodium-sys and zstd-sys to try to use pkgconfig to build against a system library.
However the features to do so get activated for some reason (due to a bug in cargo2nix?), However the features to do so get activated for some reason (due to a bug in cargo2nix?),
so disable them manually here. so disable them manually here.
*/ */
@ -136,10 +103,6 @@ let
/* [1] */ setBuildEnv = (buildEnv drv); /* [1] */ setBuildEnv = (buildEnv drv);
/* [2] */ hardeningDisable = [ "pie" ]; /* [2] */ hardeningDisable = [ "pie" ];
}; };
overrideArgs = old: {
/* [4] */ features = [ "bundled-libs" "sled" "metrics" "k2v" ]
++ (if release then [ "kubernetes-discovery" "telemetry-otlp" "lmdb" "sqlite" ] else []);
};
}) })
(pkgs.rustBuilder.rustLib.makeOverride { (pkgs.rustBuilder.rustLib.makeOverride {
@ -190,18 +153,38 @@ let
(pkgs.rustBuilder.rustLib.makeOverride { (pkgs.rustBuilder.rustLib.makeOverride {
name = "libsodium-sys"; name = "libsodium-sys";
overrideArgs = old: { overrideArgs = old: {
features = [ ]; /* [5] */ features = [ ]; /* [4] */
}; };
}) })
(pkgs.rustBuilder.rustLib.makeOverride { (pkgs.rustBuilder.rustLib.makeOverride {
name = "zstd-sys"; name = "zstd-sys";
overrideArgs = old: { overrideArgs = old: {
features = [ ]; /* [5] */ features = [ ]; /* [4] */
}; };
}) })
]; ];
/*
We ship some parts of the code disabled by default by putting them behind a flag.
It speeds up the compilation (when the feature is not required) and released crates have less dependency by default (less attack surface, disk space, etc.).
But we want to ship these additional features when we release Garage.
In the end, we chose to exclude all features from debug builds while putting (all of) them in the release builds.
*/
rootFeatures = if features != null then features else
([
"garage/bundled-libs"
"garage/sled"
"garage/k2v"
] ++ (if release then [
"garage/kubernetes-discovery"
"garage/metrics"
"garage/telemetry-otlp"
"garage/lmdb"
"garage/sqlite"
] else []));
packageFun = import ../Cargo.nix; packageFun = import ../Cargo.nix;
/* /*
@ -222,23 +205,15 @@ let
"x86_64-unknown-linux-musl" = [ "target-feature=+crt-static" "link-arg=-static-pie" ]; "x86_64-unknown-linux-musl" = [ "target-feature=+crt-static" "link-arg=-static-pie" ];
}; };
in
/* /*
The following definition is not elegant as we use a low level function of Cargo2nix NixOS and Rust/Cargo triples do not match for ARM, fix it here.
that enables us to pass our custom rustChannel object. We need this low level definition
to pass Nix's Rust toolchains instead of Mozilla's one.
target is mandatory but must be kept to null to allow cargo2nix to set it to the appropriate value
for each crate.
*/ */
pkgs.rustBuilder.makePackageSet { rustTarget = if target == "armv6l-unknown-linux-musleabihf"
inherit packageFun rustChannel release codegenOpts; then "arm-unknown-linux-musleabihf"
packageOverrides = overrides; else target;
target = null;
buildRustPackages = pkgs.buildPackages.rustBuilder.makePackageSet { in
inherit rustChannel packageFun codegenOpts; pkgs.rustBuilder.makePackageSet ({
packageOverrides = overrides; inherit release packageFun packageOverrides codegenOpts rootFeatures;
target = null; target = rustTarget;
}; } // toolchainOptions)
}

View file

@ -6,19 +6,24 @@ with import ./common.nix;
let let
platforms = [ platforms = [
"x86_64-unknown-linux-musl" #"x86_64-unknown-linux-musl"
"i686-unknown-linux-musl" "i686-unknown-linux-musl"
"aarch64-unknown-linux-musl" #"aarch64-unknown-linux-musl"
"armv6l-unknown-linux-musleabihf" "armv6l-unknown-linux-musleabihf"
]; ];
pkgsList = builtins.map (target: import pkgsSrc { pkgsList = builtins.map (target: import pkgsSrc {
inherit system; inherit system;
crossSystem = { config = target; }; crossSystem = {
config = target;
isStatic = true;
};
overlays = [ cargo2nixOverlay ];
}) platforms; }) platforms;
pkgsHost = import pkgsSrc {}; pkgsHost = import pkgsSrc {};
lib = pkgsHost.lib; lib = pkgsHost.lib;
kaniko = (import ./kaniko.nix) pkgsHost; kaniko = (import ./kaniko.nix) pkgsHost;
winscp = (import ./winscp.nix) pkgsHost; winscp = (import ./winscp.nix) pkgsHost;
manifestTool = (import ./manifest-tool.nix) pkgsHost;
in in
lib.flatten (builtins.map (pkgs: [ lib.flatten (builtins.map (pkgs: [
pkgs.rustPlatform.rust.rustc pkgs.rustPlatform.rust.rustc
@ -27,5 +32,6 @@ in
]) pkgsList) ++ [ ]) pkgsList) ++ [
kaniko kaniko
winscp winscp
manifestTool
] ]

View file

@ -8,7 +8,7 @@ SCRIPT_FOLDER="`dirname \"$0\"`"
REPO_FOLDER="${SCRIPT_FOLDER}/../" REPO_FOLDER="${SCRIPT_FOLDER}/../"
GARAGE_DEBUG="${REPO_FOLDER}/target/debug/" GARAGE_DEBUG="${REPO_FOLDER}/target/debug/"
GARAGE_RELEASE="${REPO_FOLDER}/target/release/" GARAGE_RELEASE="${REPO_FOLDER}/target/release/"
NIX_RELEASE="${REPO_FOLDER}/result/bin/" NIX_RELEASE="${REPO_FOLDER}/result/bin/:${REPO_FOLDER}/result-bin/bin/"
PATH="${GARAGE_DEBUG}:${GARAGE_RELEASE}:${NIX_RELEASE}:$PATH" PATH="${GARAGE_DEBUG}:${GARAGE_RELEASE}:${NIX_RELEASE}:$PATH"
CMDOUT=/tmp/garage.cmd.tmp CMDOUT=/tmp/garage.cmd.tmp

View file

@ -15,20 +15,10 @@ let
in in
{ {
/* --- Rust Shell --- /* --- Rust Shell ---
* Use it to compile Garage * Use it to compile Garage
*/ */
rust = pkgs.mkShell { rust = pkgs.mkShell {
shellHook = ''
function refresh_toolchain {
nix copy \
--to 's3://nix?endpoint=garage.deuxfleurs.fr&region=garage&secret-key=/etc/nix/signing-key.sec' \
$(nix-store -qR \
$(nix-build --quiet --no-build-output --no-out-link nix/toolchain.nix))
}
'';
nativeBuildInputs = [ nativeBuildInputs = [
#pkgs.rustPlatform.rust.rustc #pkgs.rustPlatform.rust.rustc
pkgs.rustPlatform.rust.cargo pkgs.rustPlatform.rust.cargo
@ -67,12 +57,33 @@ function refresh_toolchain {
*/ */
release = pkgs.mkShell { release = pkgs.mkShell {
shellHook = '' shellHook = ''
function refresh_toolchain {
pass show deuxfleurs/nix_priv_key > /tmp/nix-signing-key.sec
nix copy \
--to 's3://nix?endpoint=garage.deuxfleurs.fr&region=garage&secret-key=/tmp/nix-signing-key.sec' \
$(nix-store -qR \
$(nix-build --no-build-output --no-out-link nix/toolchain.nix))
rm /tmp/nix-signing-key.sec
}
function refresh_cache {
pass show deuxfleurs/nix_priv_key > /tmp/nix-signing-key.sec
for attr in clippy.amd64 test.amd64 pkgs.{amd64,i386,arm,arm64}.{debug,release}; do
echo "Updating cache for ''${attr}"
derivation=$(nix-instantiate --attr ''${attr})
nix copy \
--to 's3://nix?endpoint=garage.deuxfleurs.fr&region=garage&secret-key=/tmp/nix-signing-key.sec' \
$(nix-store -qR ''${derivation%\!bin})
done
rm /tmp/nix-signing-key.sec
}
function to_s3 { function to_s3 {
aws \ aws \
--endpoint-url https://garage.deuxfleurs.fr \ --endpoint-url https://garage.deuxfleurs.fr \
--region garage \ --region garage \
s3 cp \ s3 cp \
./result/bin/garage \ ./result-bin/bin/garage \
s3://garagehq.deuxfleurs.fr/_releases/''${DRONE_TAG:-$DRONE_COMMIT}/''${TARGET}/garage s3://garagehq.deuxfleurs.fr/_releases/''${DRONE_TAG:-$DRONE_COMMIT}/''${TARGET}/garage
} }

View file

@ -36,7 +36,7 @@ sha2 = "0.10"
futures = "0.3" futures = "0.3"
futures-util = "0.3" futures-util = "0.3"
pin-project = "1.0" pin-project = "1.0.11"
tokio = { version = "1.0", default-features = false, features = ["rt", "rt-multi-thread", "io-util", "net", "time", "macros", "sync", "signal", "fs"] } tokio = { version = "1.0", default-features = false, features = ["rt", "rt-multi-thread", "io-util", "net", "time", "macros", "sync", "signal", "fs"] }
tokio-stream = "0.1" tokio-stream = "0.1"

View file

@ -1,9 +1,5 @@
use crate::*; use crate::*;
use crate::lmdb_adapter::LmdbDb;
use crate::sled_adapter::SledDb;
use crate::sqlite_adapter::SqliteDb;
fn test_suite(db: Db) { fn test_suite(db: Db) {
let tree = db.open_tree("tree").unwrap(); let tree = db.open_tree("tree").unwrap();
@ -80,7 +76,10 @@ fn test_suite(db: Db) {
} }
#[test] #[test]
#[cfg(feature = "lmdb")]
fn test_lmdb_db() { fn test_lmdb_db() {
use crate::lmdb_adapter::LmdbDb;
let path = mktemp::Temp::new_dir().unwrap(); let path = mktemp::Temp::new_dir().unwrap();
let db = heed::EnvOpenOptions::new() let db = heed::EnvOpenOptions::new()
.max_dbs(100) .max_dbs(100)
@ -92,7 +91,10 @@ fn test_lmdb_db() {
} }
#[test] #[test]
#[cfg(feature = "sled")]
fn test_sled_db() { fn test_sled_db() {
use crate::sled_adapter::SledDb;
let path = mktemp::Temp::new_dir().unwrap(); let path = mktemp::Temp::new_dir().unwrap();
let db = SledDb::init(sled::open(path.to_path_buf()).unwrap()); let db = SledDb::init(sled::open(path.to_path_buf()).unwrap());
test_suite(db); test_suite(db);
@ -100,7 +102,10 @@ fn test_sled_db() {
} }
#[test] #[test]
#[cfg(feature = "sqlite")]
fn test_sqlite_db() { fn test_sqlite_db() {
use crate::sqlite_adapter::SqliteDb;
let db = SqliteDb::init(rusqlite::Connection::open_in_memory().unwrap()); let db = SqliteDb::init(rusqlite::Connection::open_in_memory().unwrap());
test_suite(db); test_suite(db);
} }

View file

@ -58,7 +58,7 @@ opentelemetry-otlp = { version = "0.10", optional = true }
prometheus = { version = "0.13", optional = true } prometheus = { version = "0.13", optional = true }
[dev-dependencies] [dev-dependencies]
aws-sdk-s3 = "0.8" aws-sdk-s3 = "0.19"
chrono = "0.4" chrono = "0.4"
http = "0.2" http = "0.2"
hmac = "0.12" hmac = "0.12"

View file

@ -12,7 +12,7 @@ readme = "../../README.md"
base64 = "0.13.0" base64 = "0.13.0"
http = "0.2.6" http = "0.2.6"
log = "0.4" log = "0.4"
rusoto_core = "0.48.0" rusoto_core = { version = "0.48.0", default-features = false, features = ["rustls"] }
rusoto_credential = "0.48.0" rusoto_credential = "0.48.0"
rusoto_signature = "0.48.0" rusoto_signature = "0.48.0"
serde = "1.0.137" serde = "1.0.137"

View file

@ -31,9 +31,8 @@ serde_bytes = "0.11"
serde_json = "1.0" serde_json = "1.0"
# newer version requires rust edition 2021 # newer version requires rust edition 2021
kube = { version = "0.62", features = ["runtime", "derive"], optional = true } kube = { version = "0.75", default-features = false, features = ["runtime", "derive", "client", "rustls-tls"], optional = true }
k8s-openapi = { version = "0.13", features = ["v1_22"], optional = true } k8s-openapi = { version = "0.16", features = ["v1_22"], optional = true }
openssl = { version = "0.10", features = ["vendored"], optional = true }
schemars = { version = "0.8", optional = true } schemars = { version = "0.8", optional = true }
# newer version requires rust edition 2021 # newer version requires rust edition 2021
@ -51,5 +50,5 @@ hyper = { version = "0.14", features = ["client", "http1", "runtime", "tcp"] }
[features] [features]
kubernetes-discovery = [ "kube", "k8s-openapi", "openssl", "schemars" ] kubernetes-discovery = [ "kube", "k8s-openapi", "schemars" ]
system-libs = [ "sodiumoxide/use-pkg-config" ] system-libs = [ "sodiumoxide/use-pkg-config" ]

View file

@ -318,7 +318,7 @@ fn path_to_key<'a>(path: &'a str, index: &str) -> Result<Cow<'a, str>, Error> {
} }
Some(_) => match path_utf8 { Some(_) => match path_utf8 {
Cow::Borrowed(pu8) => Ok((&pu8[1..]).into()), Cow::Borrowed(pu8) => Ok((&pu8[1..]).into()),
Cow::Owned(pu8) => Ok((&pu8[1..]).to_string().into()), Cow::Owned(pu8) => Ok(pu8[1..].to_string().into()),
}, },
} }
} }