kops: use buildGoModule (#176050)

This commit is contained in:
Aaron Jheng 2022-06-03 18:54:35 +08:00 committed by GitHub
parent c09782950f
commit 99aebae94f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,16 +1,12 @@
{ lib, buildGoPackage, fetchFromGitHub, go-bindata, installShellFiles }:
{ lib, buildGoModule, fetchFromGitHub, installShellFiles }:
let
goPackagePath = "k8s.io/kops";
generic = { version, sha256, rev ? version, ... }@attrs:
let attrs' = builtins.removeAttrs attrs [ "version" "sha256" "rev" ]; in
buildGoPackage
buildGoModule
{
pname = "kops";
inherit version;
inherit goPackagePath;
src = fetchFromGitHub {
rev = rev;
owner = "kubernetes";
@ -18,24 +14,26 @@ let
inherit sha256;
};
nativeBuildInputs = [ go-bindata installShellFiles ];
vendorSha256 = null;
nativeBuildInputs = [ installShellFiles ];
subPackages = [ "cmd/kops" ];
ldflags = [
"-s"
"-w"
"-X k8s.io/kops.Version=${version}"
"-X k8s.io/kops.GitVersion=${version}"
];
preBuild = ''
(cd go/src/k8s.io/kops
go-bindata -o upup/models/bindata.go -pkg models -prefix upup/models/ upup/models/...)
'';
doCheck = false;
postInstall = ''
for shell in bash zsh; do
$out/bin/kops completion $shell > kops.$shell
installShellCompletion kops.$shell
done
installShellCompletion --cmd kops \
--bash <($GOPATH/bin/kops completion bash) \
--fish <($GOPATH/bin/kops completion fish) \
--zsh <($GOPATH/bin/kops completion zsh)
'';
meta = with lib; {
@ -49,7 +47,6 @@ let
} // attrs';
in
rec {
mkKops = generic;
kops_1_21 = mkKops rec {