# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           golang 1.0

go.setup            github.com/danielfoehrKn/kubeswitch 0.9.3
go.package          github.com/danielfoehrkn/kubeswitch
revision            1

description         The "kubectx" for operators

long_description    {*}${description}. kubeswitch (lazy: switch) takes \
                    Kubeconfig context switching to the next level, catering \
                    to operators of large scale Kubernetes installations. \
                    Designed as a drop-in replacement for kubectx.

categories          sysutils
installs_libs       no
license             Apache-2
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

checksums           rmd160  d0abaa9ddac9c987f08ffa7d3a824da5f2bb6ae8 \
                    sha256  1eaebe6332b07cfe04b804defc02ae89e5e6854fee149f7c4e34015e63391d38 \
                    size    22016477

# Upstream's `make build` cross-compiles for linux, darwin and windows on
# both architectures. The Makefile was previously patched down to a single
# target, but the GOOS=darwin GOARCH=arm64 line survived that edit and fails
# to link on an x86_64 host, where the system libraries carry no arm64 slice.
# Build for this host directly instead.
build.pre_args-append \
    -ldflags \
    \"-w -X ${go.package}/cmd/switcher.version=${version}\"
build.args          -o switcher ./cmd/main.go

# Issues vendoring with go.vendor.  Allow downloading deps at build time.
go.offline_build no
go.toolchain_min    1.22.7

set ks_libexec_path ${prefix}/libexec/${name}

destroot {
    xinstall -d -m 0755 ${destroot}${ks_libexec_path}

    xinstall -m 0755 \
        ${worksrcpath}/switcher ${destroot}${prefix}/bin/

    xinstall ${worksrcpath}/hack/switch/switch.sh ${destroot}${ks_libexec_path}
}

notes "
    Please add the following to your .bashrc/.zshrc:

        source ${ks_libexec_path}/switch.sh
"
