From 546dc00a13c612df8091449370a212fc00d8e81d Mon Sep 17 00:00:00 2001 From: 06kellyjac Date: Wed, 9 Mar 2022 14:40:06 +0000 Subject: [PATCH] driftctl: 0.20.0 -> 0.23.0 - added ldflags for stripping, version, and telemetry - added shell completions - added some install checks - updated meta - added myself as a maintainer --- .../networking/cluster/driftctl/default.nix | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/pkgs/applications/networking/cluster/driftctl/default.nix b/pkgs/applications/networking/cluster/driftctl/default.nix index 725cd419d083..4c22b9adca5f 100644 --- a/pkgs/applications/networking/cluster/driftctl/default.nix +++ b/pkgs/applications/networking/cluster/driftctl/default.nix @@ -1,56 +1,56 @@ -{ lib, buildGoModule, fetchFromGitHub }: +{ lib, buildGoModule, fetchFromGitHub, installShellFiles }: buildGoModule rec { pname = "driftctl"; - version = "0.20.0"; + version = "0.23.0"; src = fetchFromGitHub { - owner = "cloudskiff"; + owner = "snyk"; repo = "driftctl"; rev = "v${version}"; - sha256 = "sha256-8egkz1wXvdNoTkbhOdvoP4hrBPmuiUvd2QaD6tPH2xU="; + sha256 = "sha256-TUwTvCsWB+n+shVU1hTzLYROG9Wp4ySzJwAnappK7TY="; }; - vendorSha256 = "sha256-lftOTcob8l9dUZkH2MMxzD6FZzLOR/PXEXFVdOaguK4="; + vendorSha256 = "sha256-I0OCRhUvuaF4k5qqPaV6R24mrd9AG5GgQCCF6yodK0E="; - postUnpack = '' - # Without this, tests fail to locate aws/3.19.0.json - for prefix in / \ - /pkg \ - /pkg/analyser \ - /pkg/alerter \ - /pkg/remote \ - /pkg/middlewares \ - /pkg/cmd/scan/output \ - /pkg/iac/terraform/state \ - /pkg/iac/supplier ; do - mkdir -p ./source/$prefix/github.com/cloudskiff - ln -sf $PWD/source ./source/$prefix/github.com/cloudskiff/driftctl - done + nativeBuildInputs = [ installShellFiles ]; - # Disable check for latest version and telemetry, which are opt-out. - # Making it out-in is quite a job, and why bother? - find -name '*.go' \ - | xargs sed -i 's,https://2lvzgmrf2e.execute-api.eu-west-3.amazonaws.com/,https://0.0.0.0/,g' + ldflags = [ + "-s" + "-w" + "-X github.com/snyk/driftctl/pkg/version.version=v${version}" + "-X github.com/snyk/driftctl/build.env=release" + "-X github.com/snyk/driftctl/build.enableUsageReporting=false" + ]; - # and remove corresponding flags from --help, so things look tidy. - find -name driftctl.go | \ - xargs sed -i -e '/("no-version-check"/ d' -e '/("disable-telemetry"/ d' + postInstall = '' + installShellCompletion --cmd driftctl \ + --bash <($out/bin/driftctl completion bash) \ + --fish <($out/bin/driftctl completion fish) \ + --zsh <($out/bin/driftctl completion zsh) + ''; - # Presumably it can be done with ldflags, but I failed to find incantation - # that would work, we here we go old-school. - find -name version.go | xargs sed -i -e 's/"dev"/"${version}"/' - find -name build.go | xargs sed -i -e 's/"dev"/"release"/' + doInstallCheck = true; + installCheckPhase = '' + runHook preInstallCheck - # Fix the tests that checks for dev-dev. - find -name version_test.go | xargs sed -i -e 's/"dev-dev/"${version}/' - find -name driftctl_test.go | xargs sed -i -e 's/"dev-dev/"${version}/' + $out/bin/driftctl --help + $out/bin/driftctl version | grep "v${version}" + # check there's no telemetry flag + $out/bin/driftctl --help | grep -vz "telemetry" + + runHook postInstallCheck ''; meta = with lib; { - description = "Tool to track infrastructure drift"; - homepage = "https://github.com/cloudskiff/driftctl"; + homepage = "https://driftctl.com/"; + changelog = "https://github.com/snyk/driftctl/releases/tag/v${version}"; + description = "Detect, track and alert on infrastructure drift"; + longDescription = '' + driftctl is a free and open-source CLI that warns of infrastructure drift + and fills in the missing piece in your DevSecOps toolbox. + ''; license = licenses.asl20; - maintainers = with maintainers; [ kaction ]; + maintainers = with maintainers; [ kaction jk ]; }; }