summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 3e0f68b6a1798dfc3afa9d6b3ac0f766314cb90b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Maintainer: Carl Smedstad <carsme@archlinux.org>
# Contributor: William Aass Dahlen <cznk@protonmail.com>

pkgname=azure-kubelogin
pkgver=0.1.4
pkgrel=1
pkgdesc="A Kubernetes credential (exec) plugin implementing azure authentication"
arch=(x86_64)
url="https://github.com/Azure/kubelogin"
license=(MIT)
depends=(glibc)
makedepends=(
  git
  go
)
conflicts=(kubelogin)
source=("$pkgname::git+$url.git#tag=v$pkgver")
sha256sums=('ee1cd07c4d65a6887a944074750db4e5d8b2b4b677da0f1213bebaf600ef2e49')

_archive="$pkgname"

prepare() {
  cd "$_archive"

  GOFLAGS="-mod=readonly" go mod vendor -v
}

build() {
  cd "$_archive"

  export CGO_CPPFLAGS="$CPPFLAGS"
  export CGO_CFLAGS="$CFLAGS"
  export CGO_CXXFLAGS="$CXXFLAGS"
  export CGO_LDFLAGS="$LDFLAGS"
  export GOFLAGS="-buildmode=pie -mod=vendor -modcacherw"
  export GOPATH="$srcdir"

  local ld_flags=" \
    -compressdwarf=false \
    -linkmode=external  \
  "
  go build -v -ldflags "$ld_flags" .

  # Completions
  ./kubelogin completion bash > kubelogin.bash
  ./kubelogin completion fish > kubelogin.fish
  ./kubelogin completion zsh > kubelogin.zsh
}

check() {
  cd "$_archive"

  # Skip tests failing for some users - not sure why
  local unit_tests=$(
    go list ./... \
      | grep -v 'github.com/Azure/kubelogin/pkg/internal/pop' \
      | grep -v 'github.com/Azure/kubelogin/pkg/internal/token'
  )
  # shellcheck disable=SC2086
  go test -v $unit_tests
}

package() {
  cd "$_archive"

  install -Dm755 -t "$pkgdir/usr/bin" kubelogin

  install -Dm644 kubelogin.bash "$pkgdir/usr/share/bash-completion/completions/kubelogin"
  install -Dm644 kubelogin.fish "$pkgdir/usr/share/fish/vendor_completions.d/kubelogin.fish"
  install -Dm644 kubelogin.zsh "$pkgdir/usr/share/zsh/site-functions/_kubelogin"

  install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}