From 4d50ce93aa0b20534e8a2e8456e89cfeb58bd422 Mon Sep 17 00:00:00 2001 From: Christian Kampka Date: Wed, 3 Jul 2019 13:00:27 +0200 Subject: 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 --- .../networking/cluster/kops/default.nix | 91 ++++++++++++---------- 1 file changed, 52 insertions(+), 39 deletions(-) (limited to 'pkgs/applications/networking/cluster/kops') diff --git a/pkgs/applications/networking/cluster/kops/default.nix b/pkgs/applications/networking/cluster/kops/default.nix index 96f3354023cf..cd6cd9ee22b2 100644 --- a/pkgs/applications/networking/cluster/kops/default.nix +++ b/pkgs/applications/networking/cluster/kops/default.nix @@ -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"; - }; - - buildInputs = [go-bindata]; - subPackages = ["cmd/kops"]; - - buildFlagsArray = '' - -ldflags= - -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/...) - ''; - - 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; + generic = { version, sha256, ...}@attrs: + let attrs' = builtins.removeAttrs attrs ["version" "sha256"] ; in + buildGoPackage { + name = "kops-${version}"; + + inherit goPackagePath; + + src = fetchFromGitHub { + rev = version; + owner = "kubernetes"; + repo = "kops"; + inherit sha256; + }; + + buildInputs = [go-bindata]; + subPackages = ["cmd/kops"]; + + buildFlagsArray = '' + -ldflags= + -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/...) + ''; + + 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"; }; } -- cgit 1.4.1