python312Packages.llama-index: 0.12.9 -> 0.12.9.post1 (#371957)
[NixPkgs.git] / pkgs / by-name / cb / cbtemulator / package.nix
blob9fdf25879294f21b4669cc0721a19a678329ed76
2   lib,
3   buildGoModule,
4   fetchFromGitHub,
5   runCommand,
6   cbtemulator,
7   google-cloud-bigtable-tool,
8 }:
10 buildGoModule rec {
11   pname = "cbtemulator";
12   version = "1.29.0";
14   src = fetchFromGitHub {
15     owner = "googleapis";
16     repo = "google-cloud-go";
17     rev = "bigtable/v${version}";
18     hash = "sha256-prDwy65pxWDrIJOURe2JHo4sY4yP8IE1Rp1pLUL/IAA=";
19   };
21   # There's a go.{mod,sum} in the root and in the "bigtable" subdir.
22   # We only ever use things in that subdir.
23   sourceRoot = "${src.name}/bigtable";
24   env.GOWORK = "off";
26   vendorHash = "sha256-EDfxT56LKEu/iXPp5RJXb4UIRV2jFFNxh3ZINPbwKTM=";
28   subPackages = [ "cmd/emulator" ];
30   postInstall = ''
31     mv $out/bin/emulator $out/bin/cbtemulator
32   '';
34   passthru = {
35     # Sets up a table and family, then inserts, and ensures it gets back the value.
36     tests.smoketest =
37       runCommand "cbtemulator-smoketest"
38         {
39           nativeBuildInputs = [ google-cloud-bigtable-tool ];
40         }
41         ''
42           # Start the emulator
43           ${lib.getExe cbtemulator} &
44           EMULATOR_PID=$!
46           cleanup() {
47             kill $EMULATOR_PID
48           }
50           trap cleanup EXIT
52           export BIGTABLE_EMULATOR_HOST=localhost:9000
54           cbt -instance instance-1 -project project-1 createtable table-1
55           cbt -instance instance-1 -project project-1 createfamily table-1 cf1
56           cbt -instance instance-1 -project project-1 ls table-1
57           cbt -instance instance-1 -project project-1 set table-1 key1 cf1:c1=value1
59           cbt -instance instance-1 -project project-1 read table-1 | grep -q value1
61           touch $out;
62         '';
63   };
65   meta = with lib; {
66     description = "In-memory Google Cloud Bigtable server";
67     homepage = "https://github.com/googleapis/google-cloud-go/blob/bigtable/v${version}/bigtable/cmd/emulator/cbtemulator.go";
68     license = licenses.asl20;
69     maintainers = [ maintainers.flokli ];
70     mainProgram = "cbtemulator";
71     platforms = platforms.all;
72   };