nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 73 lines 2.0 kB view raw
1{ 2 lib, 3 buildGoModule, 4 fetchFromGitHub, 5 runCommand, 6 cbtemulator, 7 google-cloud-bigtable-tool, 8}: 9 10buildGoModule rec { 11 pname = "cbtemulator"; 12 version = "1.29.0"; 13 14 src = fetchFromGitHub { 15 owner = "googleapis"; 16 repo = "google-cloud-go"; 17 rev = "bigtable/v${version}"; 18 hash = "sha256-prDwy65pxWDrIJOURe2JHo4sY4yP8IE1Rp1pLUL/IAA="; 19 }; 20 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"; 25 26 vendorHash = "sha256-EDfxT56LKEu/iXPp5RJXb4UIRV2jFFNxh3ZINPbwKTM="; 27 28 subPackages = [ "cmd/emulator" ]; 29 30 postInstall = '' 31 mv $out/bin/emulator $out/bin/cbtemulator 32 ''; 33 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=$! 45 46 cleanup() { 47 kill $EMULATOR_PID 48 } 49 50 trap cleanup EXIT 51 52 export BIGTABLE_EMULATOR_HOST=localhost:9000 53 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 58 59 cbt -instance instance-1 -project project-1 read table-1 | grep -q value1 60 61 touch $out; 62 ''; 63 }; 64 65 meta = { 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 = lib.licenses.asl20; 69 maintainers = [ lib.maintainers.flokli ]; 70 mainProgram = "cbtemulator"; 71 platforms = lib.platforms.all; 72 }; 73}