#!/bin/bash

source ${SCRIPTS_DIR}/lib/debug_functions

K8S_IO_DIR="${GOPATH:-~/go}/src/k8s.io"
CODEGEN_SCRIPT_DIR="${K8S_IO_DIR}/code-generator"
CODEGEN_SCRIPT="${CODEGEN_SCRIPT_DIR}/generate-groups.sh"
CODEGEN_RELEASE_TAG=kubernetes-1.17.0

if [ ! -f "$CODEGEN_SCRIPT" ]; then
    echo "$CODEGEN_SCRIPT does not exist - downloading..."
    git clone --branch $CODEGEN_RELEASE_TAG https://github.com/kubernetes/code-generator "${CODEGEN_SCRIPT_DIR}"
    cd "${CODEGEN_SCRIPT_DIR}"
    go mod vendor
    cd -
    echo "Successsfully checked out release tag $CODEGEN_RELEASE_TAG"
fi

"${CODEGEN_SCRIPT}" all github.com/submariner-io/submariner/pkg/client github.com/submariner-io/submariner/pkg/apis submariner.io:v1
