#!/usr/bin/env sh

# This script is used in the multiple Dockerfiles for caching
# some of the slow-to-build go dependencies.

set -eu

bindir=$( cd "${0%/*}" && pwd )
rootdir=$( cd "$bindir"/.. && pwd )
arch=${1:-amd64}
cd "$rootdir"

CGO_ENABLED=0 GOOS=linux GOARCH=$arch go install -mod=readonly \
    github.com/golang/protobuf/jsonpb \
    github.com/grpc-ecosystem/go-grpc-prometheus \
    github.com/prometheus/client_golang/api \
    github.com/prometheus/client_golang/api/prometheus/v1 \
    github.com/prometheus/client_golang/prometheus \
    github.com/prometheus/client_golang/prometheus/promhttp \
    github.com/prometheus/client_model/go \
    github.com/prometheus/common/expfmt \
    github.com/prometheus/common/model \
    github.com/sirupsen/logrus \
    github.com/containernetworking/cni/pkg/version \
    github.com/containernetworking/cni/pkg/skel \
    github.com/containernetworking/cni/pkg/types \
    github.com/containernetworking/cni/pkg/invoke \
    google.golang.org/grpc \
    k8s.io/client-go/discovery \
    k8s.io/client-go/kubernetes \
    k8s.io/client-go/kubernetes/scheme \
    k8s.io/client-go/kubernetes/typed/admissionregistration/v1 \
    k8s.io/client-go/kubernetes/typed/apps/v1 \
    k8s.io/client-go/kubernetes/typed/apps/v1beta1 \
    k8s.io/client-go/kubernetes/typed/apps/v1beta2 \
    k8s.io/client-go/kubernetes/typed/authentication/v1 \
    k8s.io/client-go/kubernetes/typed/authentication/v1beta1 \
    k8s.io/client-go/kubernetes/typed/authorization/v1 \
    k8s.io/client-go/kubernetes/typed/authorization/v1beta1 \
    k8s.io/client-go/kubernetes/typed/autoscaling/v1 \
    k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1 \
    k8s.io/client-go/kubernetes/typed/batch/v1 \
    k8s.io/client-go/kubernetes/typed/certificates/v1beta1 \
    k8s.io/client-go/kubernetes/typed/core/v1 \
    k8s.io/client-go/kubernetes/typed/events/v1beta1 \
    k8s.io/client-go/kubernetes/typed/extensions/v1beta1 \
    k8s.io/client-go/kubernetes/typed/networking/v1 \
    k8s.io/client-go/kubernetes/typed/policy/v1beta1 \
    k8s.io/client-go/kubernetes/typed/rbac/v1 \
    k8s.io/client-go/kubernetes/typed/rbac/v1alpha1 \
    k8s.io/client-go/kubernetes/typed/rbac/v1beta1 \
    k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1 \
    k8s.io/client-go/kubernetes/typed/storage/v1 \
    k8s.io/client-go/kubernetes/typed/storage/v1alpha1 \
    k8s.io/client-go/kubernetes/typed/storage/v1beta1 \
    k8s.io/client-go/pkg/version \
    k8s.io/client-go/plugin/pkg/client/auth \
    k8s.io/client-go/plugin/pkg/client/auth/azure \
    k8s.io/client-go/plugin/pkg/client/auth/gcp \
    k8s.io/client-go/plugin/pkg/client/auth/oidc \
    k8s.io/client-go/rest \
    k8s.io/client-go/rest/watch \
    k8s.io/client-go/tools/auth \
    k8s.io/client-go/tools/cache \
    k8s.io/client-go/tools/clientcmd \
    k8s.io/client-go/tools/pager \
    k8s.io/client-go/transport \
    k8s.io/client-go/util/cert \
    k8s.io/client-go/util/flowcontrol \
    k8s.io/client-go/util/homedir \
    k8s.io/client-go/util/jsonpath
