kops: restructure package to maintain multiple versions in the future

kops versions are bound to the version of the kubernetes cluster they
are targeted to maintain (kops 1.12 -> k8s 1.12, kops 1.13 -> k8s 1.13,
etc). Upgrading kops should therefore be done very deliberately
as it may affect the cluster it is working with in drastic ways.
This change introduces the ability to maintain multiple versions of
kops in nixpkgs, giving the users the ability to pin it to their target
cluster version when installing
This commit is contained in:
Christian Kampka 2019-07-03 13:00:27 +02:00
parent 5aeab0b2dd
commit 4d50ce93aa
2 changed files with 52 additions and 35 deletions

View File

@ -1,44 +1,57 @@
{ stdenv, buildGoPackage, fetchFromGitHub, go-bindata }:
buildGoPackage rec {
name = "kops-${version}";
version = "1.12.1";
{ stdenv, lib, buildGoPackage, fetchFromGitHub, go-bindata }:
let
goPackagePath = "k8s.io/kops";
src = fetchFromGitHub {
rev = version;
owner = "kubernetes";
repo = "kops";
sha256 = "09rmgazdrmnh1lqaayzfbn0ld7mbj9whihs9ijv5gf6si9p0ml9y";
};
generic = { version, sha256, ...}@attrs:
let attrs' = builtins.removeAttrs attrs ["version" "sha256"] ; in
buildGoPackage {
name = "kops-${version}";
buildInputs = [go-bindata];
subPackages = ["cmd/kops"];
inherit goPackagePath;
buildFlagsArray = ''
-ldflags=
-X k8s.io/kops.Version=${version}
-X k8s.io/kops.GitVersion=${version}
'';
src = fetchFromGitHub {
rev = version;
owner = "kubernetes";
repo = "kops";
inherit sha256;
};
preBuild = ''
(cd go/src/k8s.io/kops
go-bindata -o upup/models/bindata.go -pkg models -prefix upup/models/ upup/models/...)
'';
buildInputs = [go-bindata];
subPackages = ["cmd/kops"];
postInstall = ''
mkdir -p $bin/share/bash-completion/completions
mkdir -p $bin/share/zsh/site-functions
$bin/bin/kops completion bash > $bin/share/bash-completion/completions/kops
$bin/bin/kops completion zsh > $bin/share/zsh/site-functions/_kops
'';
buildFlagsArray = ''
-ldflags=
-X k8s.io/kops.Version=${version}
-X k8s.io/kops.GitVersion=${version}
'';
meta = with stdenv.lib; {
description = "Easiest way to get a production Kubernetes up and running";
homepage = https://github.com/kubernetes/kops;
license = licenses.asl20;
maintainers = with maintainers; [offline zimbatm];
platforms = platforms.unix;
preBuild = ''
(cd go/src/k8s.io/kops
go-bindata -o upup/models/bindata.go -pkg models -prefix upup/models/ upup/models/...)
'';
postInstall = ''
mkdir -p $bin/share/bash-completion/completions
mkdir -p $bin/share/zsh/site-functions
$bin/bin/kops completion bash > $bin/share/bash-completion/completions/kops
$bin/bin/kops completion zsh > $bin/share/zsh/site-functions/_kops
'';
meta = with stdenv.lib; {
description = "Easiest way to get a production Kubernetes up and running";
homepage = https://github.com/kubernetes/kops;
license = licenses.asl20;
maintainers = with maintainers; [offline zimbatm];
platforms = platforms.unix;
};
} // attrs';
in rec {
mkKops = generic;
kops_1_12 = mkKops {
version = "1.12.2";
sha256 = "0937crwifnld7r5pf5gvab9ibmf8k44dafr9y3hld2p01ijrari1";
};
}

View File

@ -23635,7 +23635,11 @@ in
kontemplate = callPackage ../applications/networking/cluster/kontemplate { };
kops = callPackage ../applications/networking/cluster/kops { };
inherit (callPackage ../applications/networking/cluster/kops {})
mkKops
kops_1_12
;
kops = kops_1_12;
lguf-brightness = callPackage ../misc/lguf-brightness { };