Skip to content

Instantly share code, notes, and snippets.

@liangrog
Created December 20, 2018 04:37
Show Gist options
  • Save liangrog/ad7bc6b56a028d0a27b2f5d711800912 to your computer and use it in GitHub Desktop.
Save liangrog/ad7bc6b56a028d0a27b2f5d711800912 to your computer and use it in GitHub Desktop.
#!/bin/bash -e
CURRENT_DIR=$(pwd)
GEN_DIR=$(dirname $0)
REPO_DIR="$CURRENT_DIR/$GEN_DIR/../.."
PROJECT_MODULE="github.com/superman/demo"
IMAGE_NAME="kubernetes-codegen:latest"
CUSTOM_RESOURCE_NAME="foo"
CUSTOM_RESOURCE_VERSION="v1"
echo "Building codegen Docker image..."
docker build -f "${GEN_DIR}/Dockerfile" \
-t "${IMAGE_NAME}" \
"${REPO_DIR}"
cmd="./generate-groups.sh all \
"$PROJECT_MODULE/pkg/client" \
"$PROJECT_MODULE/pkg/apis" \
$CUSTOM_RESOURCE_NAME:$CUSTOM_RESOURCE_VERSION"
echo "Generating client codes..."
docker run --rm \
-v "${REPO_DIR}:/go/src/${PROJECT_MODULE}" \
"${IMAGE_NAME}" $cmd
sudo chown $USER:$USER -R $REPO_DIR/pkg
@leopay
Copy link

leopay commented Aug 16, 2019

as this file is location in kce/bin/gen, the REPO_DIR should be "$CURRENT_DIR/$GEN_DIR/.."?
kce/
├── bin
│   ├── Dockerfile
│   └── kce-bin-gen.sh
└── pkg
└── apis
└── foo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment