# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=k0sctl
pkgver=0.19.4
pkgrel=5
pkgdesc="Bootstrapping and management tool for k0s clusters"
url="https://github.com/k0sproject/k0sctl"
arch="all"
license="Apache-2.0"
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/k0sproject/k0sctl/archive/refs/tags/v$pkgver/k0sctl-$pkgver.tar.gz"
options="chmod-clean"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	make TAG_NAME="v$pkgver" GIT_COMMIT=""

	for shell in bash fish zsh; do
		./$pkgname completion --shell $shell >$pkgname.$shell
	done
}

check() {
	make test
}

package() {
	make PREFIX=/usr DESTDIR="$pkgdir" install

	install -Dm644 $pkgname.bash "$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 $pkgname.fish "$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish
	install -Dm644 $pkgname.zsh "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
00fefdfc07493c3d54c9a7b1620c0d87549f8de2193075683bd2c52a3f70583bd3578521e6258c28a5e74ee94b71174ec4443190c35d1b8690136f3dc16285d6  k0sctl-0.19.4.tar.gz
"
