# -*- 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.1
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  aedfa8d4bdafb25dd12457e900897505104f3c2e \
                    sha256  b35ae018245283142cdb5c4c3f9c342cb3194dec398cf69f2af955aa373da3a8 \
                    size    19916372

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

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

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

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

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

    xinstall ${worksrcpath}/hack/hooks/hook_gardener_landscape_sync \
        ${destroot}${ks_hooks_path}
}

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

        source ${ks_libexec_path}/switch.sh

    ${name} hooks have been installed to: ${ks_hooks_path}
"
