# -*- 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            0

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

build.cmd           make
build.pre_args-append \
                    VERSION=v${version}
build.args          build

patch {
    reinplace       {/linux/ d}             ${worksrcpath}/Makefile
    reinplace       {s|GOARCH=amd64 ||g}    ${worksrcpath}/Makefile
    reinplace       {s|_darwin_amd64||g}    ${worksrcpath}/Makefile
}

# 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}/hack/switch/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
"
