From 84cd3677ab258343447f88728604e84ae2b6bee7 Mon Sep 17 00:00:00 2001 From: belyshevdenis Date: Wed, 6 Feb 2019 19:51:47 +0200 Subject: [PATCH] NK17: Fixed code generation, updated README.md --- README.md | 34 ++++++++++++++++++++++++++++++++++ scripts/update-codegen.sh | 25 ++++++++++++++----------- 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d61bcc4e0b..fdea631fa3 100644 --- a/README.md +++ b/README.md @@ -9,4 +9,38 @@ A Kubernetes native policy engine # Installation +## Prerequisites + +You need to have go and dep utils installed on your machine. +Ensure that GOPATH environment variable is set to desired location. +Code generation for CRD controller uses kubernetes/hack as a dependency, so before use code generation, execute: + +`go get k8s.io/kubernetes/hack` + +## You can `go get` + +Due to the repository privacy, you should to add SSH key to your github user to clone repository using `go get` command. +Using `go get` you receive correct repository location ad $GOHOME/go/src which is needed to restore dependencies. +Configure SSH key due to this article: https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/ + +After SSH key configured, you must tell git to use SSH. To do it use next command: + +`git config --global url.git@github.com:.insteadOf https://github.com/` + +After this is done, use next command to clone the repo: + +`go get github.com/nirmata/kube-policy` + +## Or `git clone` + +If you don't want to use SSH, you just can clone repo with git, but ensure that repo will be inside this path: $GOPATH/src/. + +`git clone https://github.com/nirmata/kube-policy.git $GOPATH/src/nirmata/kube-policy` + +## Restore dependencies + +Navigate to kube-policy project dir and execute: +`dep restore` +This will install necessary dependencies described in README.md + # Contributing diff --git a/scripts/update-codegen.sh b/scripts/update-codegen.sh index ec2af740ff..331be38ff7 100755 --- a/scripts/update-codegen.sh +++ b/scripts/update-codegen.sh @@ -3,16 +3,19 @@ set -o errexit set -o nounset set -o pipefail -SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/.. -CODEGEN_PKG=${SCRIPT_ROOT}/vendor/k8s.io/code-generator +# get nirmata root +NIRMATA_DIR=$(dirname ${BASH_SOURCE})/.. +NIRMATA_ROOT=$(readlink -f ${NIRMATA_DIR}) -# generate the code with: -# --output-base because this script should also be able to run inside the vendor dir of -# k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir -# instead of the $GOPATH directly. For normal projects this can be dropped. -${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \ - github.com/nirmata/kube-policy/pkg/client github.com/nirmata/kube-policy/pkg/apis \ - policy:v1alpha1 +# get relative path to code generation script +CODEGEN_PKG=${NIRMATA_DIR}/vendor/k8s.io/code-generator -# To use your own boilerplate text use: -# --go-header-file ${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt +# get relative path of nirmata +NIRMATA_PKG=${NIRMATA_ROOT#"${GOPATH}/src/"} + +# perform code generation +${CODEGEN_PKG}/generate-groups.sh \ + "deepcopy,client,informer,lister" \ + ${NIRMATA_PKG}/pkg/client \ + ${NIRMATA_PKG}/pkg/apis \ + policy:v1alpha1