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

# UPDATE THESE IN SYNC!
set version         0.7.11
set commit          7e87c3700b409f5560249c29a90200de4828a1db

go.setup            github.com/kubernetes-sigs/aws-iam-authenticator ${version} v
revision            0
go.package          sigs.k8s.io/aws-iam-authenticator
go.offline_build    no

description         AWS IAM Authenticator for Kubernetes
long_description    Use IAM credentials to authenticate to Kubernetes.

categories          sysutils
license             Apache-2

maintainers         @asobrien \
                    openmaintainer

checksums           rmd160  79749b66aae2c9fb5704e1e44757f812b26d9775 \
                    sha256  1869fd23eb19e8276ee6a4d4bdf1334cf82c7baee849eab7a9f85519d4318221 \
                    size    181827


build.args          -ldflags=\"-s -w \
                    -X ${go.package}/pkg.Version=${version} \
                    -X ${go.package}/pkg.CommitID=${commit}\"
build.args-append   ./cmd/${name}

# Do not build on macOS 10.10 and earlier
if {${os.platform} eq "darwin" && ${os.major} < 15} {
    known_fail yes

    pre-fetch {
        ui_error "${name} does not build on macOS 10.10 and earlier"
        return -code error "unsupported platform version"
    }
}

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

    # Install shell completions
    set bash_completions_dir ${destroot}${prefix}/share/bash-completion/completions
    set fish_completions_dir ${destroot}${prefix}/share/fish/vendor_completions.d
    set zsh_completions_dir ${destroot}${prefix}/share/zsh/site-functions
    xinstall -d ${bash_completions_dir} ${fish_completions_dir} ${zsh_completions_dir}
    system "${worksrcpath}/${name} completion bash > ${bash_completions_dir}/${name}"
    system "${worksrcpath}/${name} completion fish > ${fish_completions_dir}/${name}.fish"
    system "${worksrcpath}/${name} completion zsh > ${zsh_completions_dir}/_${name}"
}
