# -*- 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/kubernetes-sigs/krew 0.5.0 v
go.package          sigs.k8s.io/krew
revision            0

description         Find and install kubectl plugins

long_description    Krew is the package manager for kubectl plugins. Krew \
                    helps you discover plugins, install and manage them on \
                    your machine. It is similar to tools like apt, dnf or \
                    brew. Today, over 70 kubectl plugins are available on Krew.

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

checksums           rmd160  eaadcd96811411384f2ef1ca899e5d8fae601097 \
                    sha256  2a9a751d63f67dfc21998774ec9cccf19aa5f1a22596f43226e211578f9f6469 \
                    size    562063

depends_build-append \
                    port:gox

# Allow Go to fetch dependencies at build time
go.offline_build no

build.env-append    OSARCH=${goos}/${goarch}

build.cmd           ./hack/make-binaries.sh
build.target

patch {
    reinplace "s|^git_tag=.*|git_tag=${version}|"   ${build.cmd}
    reinplace {s|^git_rev=.*|git_rev=""|}           ${build.cmd}
}

destroot {
    xinstall -m 0755 ${worksrcpath}/out/bin/${name}-${goos}_${goarch} \
        ${destroot}${prefix}/bin/${name}

    set krew_doc_dir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${krew_doc_dir}
    copy {*}[glob ${worksrcpath}/docs/*] ${destroot}${krew_doc_dir}/
}

notes "
To initialize ${name} as a kubectl plugin, run:

    ${name} install krew

Then add the \$HOME/.krew/bin directory to your PATH environment variable.
"
