# -*- 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           github 1.0

github.setup        GoogleContainerTools skaffold 2.19.0 v
revision            0

categories          devel
maintainers         {breun @breun} openmaintainer
platforms           darwin
license             Apache-2

description         Skaffold is a command line tool that facilitates continuous development for Kubernetes applications

long_description    Skaffold is a command line tool that facilitates continuous development for Kubernetes applications. \
                    You can iterate on your application source code locally then deploy to local or remote Kubernetes clusters. \
                    Skaffold handles the workflow for building, pushing and deploying your application. \
                    It also provides building blocks and describe customizations for a CI/CD pipeline.

homepage            https://skaffold.dev

github.tarball_from archive

checksums           rmd160  b7a34591e2b9c643887147f143ffa7d6572f5680 \
                    sha256  c8dc955a77f9696d16e3c1fd6970784bc5c37f1375907a83a1b67aa937bc7c29 \
                    size    63900602

depends_build       port:go

use_configure       no

build.env-append    VERSION=${version} LOCAL=true
build.target

test.run    yes
test.cmd    out/${name}
test.target
test.args   version

destroot {
    set binary_dir ${prefix}/share/${name}
    set binary ${binary_dir}/skaffold

    # Install binary
    xinstall -d ${destroot}${binary_dir}
    xinstall -m 0755 ${worksrcpath}/out/${name} ${destroot}${binary}

    # Create launch script
    # Disable update check: https://skaffold.dev/docs/references/privacy/#update-check
    set launch_script [open ${destroot}${prefix}/bin/skaffold w 0755]
    puts $launch_script "#!/bin/sh"
    puts $launch_script "SKAFFOLD_UPDATE_CHECK=false ${binary} $@"
    close $launch_script

    # bash completion
    xinstall -d ${destroot}${prefix}/etc/bash_completion.d
    system "${destroot}${binary} completion bash > ${destroot}${prefix}/etc/bash_completion.d/${name}"

    # zsh completion
    xinstall -d ${destroot}${prefix}/share/zsh/site-functions
    system "${destroot}${binary} completion zsh > ${destroot}${prefix}/share/zsh/site-functions/_${name}"
}
