# -*- 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.6.20
set commit          774efb85b060370538c2d47576fb3ba3e58b2c38

go.setup            github.com/kubernetes-sigs/aws-iam-authenticator ${version} v
# Delete this on next update to use golang PortGroup's default ('archive')
github.tarball_from tarball
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  70d47260c91ccf6eac55bb9d9f06b18920a973bb \
                    sha256  b902e10cbec693b38a3ed1e65ed3a75a57187782e85eee8e61c4a607cebc5e19 \
                    size    191573


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}"
}
