-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update deps update build script add version.go fix parameter type changes in hostnic and utils.
- Loading branch information
1 parent
678d531
commit 5095464
Showing
1,606 changed files
with
242,712 additions
and
43,970 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,6 @@ | ||
bin | ||
*.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
Icon | ||
._* | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
*.exe | ||
*.dll | ||
*.so | ||
*.dylib | ||
*.test | ||
*.out | ||
|
||
.glide/ | ||
[._]*.s[a-v][a-z] | ||
[._]*.sw[a-p] | ||
[._]s[a-v][a-z] | ||
[._]sw[a-p] | ||
Session.vim | ||
.netrwhist | ||
*~ | ||
tags | ||
.idea/ | ||
*.iws | ||
glide.lock | ||
*.iml | ||
/out/ | ||
.idea_modules/ | ||
atlassian-ide-plugin.xml | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
.metadata | ||
tmp/ | ||
*.tmp | ||
*.bak | ||
*.swp | ||
*~.nib | ||
local.properties | ||
.settings/ | ||
.loadpath | ||
.recommenders | ||
.project | ||
.externalToolBuilders/ | ||
*.launch | ||
*.pydevproject | ||
.cproject | ||
.classpath | ||
.factorypath | ||
.buildpath | ||
.target | ||
.tern-project | ||
.texlipse | ||
.springBeans | ||
.recommenders/ | ||
.cache-main | ||
.scala_dependencies | ||
.worksheet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# tab space is 4 | ||
# GitHub viewer defaults to 8, change with ?ts=4 in URL | ||
|
||
# Vars describing project | ||
NAME = hostnic-cni | ||
GIT_REPOSITORY = github.com/yunify/hostnic-cni | ||
|
||
# Generate vars to be included from external script | ||
# Allows using bash to generate complex vars, such as project versions | ||
GENERATE_VERSION_INFO_SCRIPT = ./generate_version.sh | ||
GENERATE_VERSION_INFO_OUTPUT = version_info | ||
|
||
# Define newline needed for subsitution to allow evaluating multiline script output | ||
define newline | ||
|
||
|
||
endef | ||
|
||
# Call the version_info script with keyvalue option and evaluate the output | ||
# Will import the keyvalue pairs and make available as Makefile variables | ||
# Use dummy variable to only have execute once | ||
$(eval $(subst #,$(newline),$(shell $(GENERATE_VERSION_INFO_SCRIPT) keyvalue | tr '\n' '#'))) | ||
|
||
# Call the verson_info script with json option and store result into output file and variable | ||
# Will only execute once due to ':=' | ||
#GENERATE_VERSION_INFO := $(shell $(GENERATE_VERSION_INFO_SCRIPT) json | tee $(GENERATE_VERSION_INFO_OUTPUT)) | ||
|
||
# Set defaults for needed vars in case version_info script did not set | ||
# Revision set to number of commits ahead | ||
VERSION ?= 0.0 | ||
COMMITS ?= 0 | ||
REVISION ?= $(COMMITS) | ||
BUILD_LABEL ?= unknown_build | ||
BUILD_DATE ?= $(shell date -u +%Y%m%d.%H%M%S) | ||
GIT_SHA1 ?= unknown_sha1 | ||
|
||
# Vars for export ; generate list of ENV vars based on matching export prefix | ||
# Use strip to get rid of excessive spaces due to the foreach / filter / if logic | ||
EXPORT_VAR_PREFIX = EXPORT_VAR_ | ||
EXPORT_VARS = $(strip $(foreach v,$(filter $(EXPORT_VAR_PREFIX)%,$(.VARIABLES)),$(if $(filter environment%,$(origin $(v))),$(v)))) | ||
|
||
# Vars for go phase | ||
# All vars which being with prefix will be included in ldflags | ||
# Defaulting to full static build | ||
GO_VARIABLE_PREFIX = GO_VAR_ | ||
GO_VAR_BUILD_LABEL := $(BUILD_LABEL) | ||
GO_VAR_VERSION := $(VERSION) | ||
GO_VAR_GIT_SHA1 := $(GIT_SHA1) | ||
GO_VAR_BUILD_LABEL := $(BUILD_LABEL) | ||
GO_LDFLAGS = $(foreach v,$(filter $(GO_VARIABLE_PREFIX)%, $(.VARIABLES)),-X github.com/yunify/hostnic-cni/pkg.$(patsubst $(GO_VARIABLE_PREFIX)%,%,$(v))=$(value $(value v))) | ||
GO_BUILD_FLAGS = -a -tags netgo -installsuffix nocgo -ldflags "$(GO_LDFLAGS)" | ||
|
||
# Define targets | ||
|
||
# default just build binary | ||
default : go-build | ||
|
||
# target for debugging / printing variables | ||
print-% : | ||
@echo '$*=$($*)' | ||
|
||
# perform go build on project | ||
go-build : | ||
go build -o bin/hostnic $(GO_BUILD_FLAGS) $(GIT_REPOSITORY)/cmd/hostnic/ | ||
go build -o bin/nicclearner $(GO_BUILD_FLAGS) $(GIT_REPOSITORY)/cmd/niccleaner/ | ||
|
||
|
||
.PHONY : default all go-build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
#!/bin/bash | ||
# Define the project string to be used | ||
PROJECT=hostnic-cni | ||
|
||
# Use `git describe` to get parts for version information and state | ||
GIT_DESCRIBE=$(git describe --long --dirty --tags) | ||
if [[ $? != 0 ]]; then | ||
echo "No tags!" | ||
exit | ||
fi | ||
|
||
# Parse the output of `git describe` | ||
# VERSION: The latest `git tag` | ||
# COMMITS: The number of commits ahead workspace is of `git tag` | ||
# SHA1: Unique SHA1 reference of current commit state | ||
# DIRTY: Whether this workspace contains uncommitted / local changes | ||
IFS='-' read -a myarray <<< "$GIT_DESCRIBE" | ||
|
||
VERSION=${myarray[0]} | ||
COMMITS=${myarray[1]} | ||
SHA1=${myarray[2]} | ||
|
||
if [ -z ${myarray[3]} ]; then | ||
DIRTY=false | ||
else | ||
DIRTY=true | ||
fi | ||
|
||
if [[ $(git ls-files --directory --exclude-standard --others -t) ]]; then | ||
DIRTY=true | ||
fi | ||
|
||
# Which branch was the git workspace tracking | ||
BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
|
||
# Generate a well known label based on branch | ||
# Unknown branches will go by their SHA1 | ||
case $BRANCH in | ||
master) | ||
LABEL="ga" | ||
;; | ||
develop) | ||
LABEL="dev" | ||
;; | ||
release/*) | ||
LABEL="rc" | ||
;; | ||
*) | ||
LABEL=$SHA1 | ||
esac | ||
|
||
# Generate a label to represent this build | ||
# Combination of various information about the git workspace | ||
# Can be used for a filename of the package | ||
BUILD_LABEL="${PROJECT}-${VERSION}-${COMMITS}-${LABEL}" | ||
|
||
if [ "$DIRTY" = true ]; then | ||
BUILD_LABEL=${BUILD_LABEL}-dirty | ||
fi | ||
|
||
# Generate a build date if was not passed into the env or present in parent env | ||
BUILD_DATE=${BUILD_DATE:=$(date -u +%Y%m%d.%H%M%S)} | ||
|
||
# Set the variables to be outputted | ||
# All vars that begin with the prefix will be outputted | ||
# Allows callers of the script to inject new vars through ENV | ||
# e.g. Jenkins can set EXPORT_JENKINS_SERVER=build-server | ||
VAR_PREFIX=EXPORT_VAR_ | ||
|
||
EXPORT_VAR_GIT_DESCRIBE="$GIT_DESCRIBE" | ||
EXPORT_VAR_BRANCH="$BRANCH" | ||
EXPORT_VAR_LABEL="$LABEL" | ||
EXPORT_VAR_VERSION="$VERSION" | ||
EXPORT_VAR_COMMITS="$COMMITS" | ||
EXPORT_VAR_GIT_SHA1="$SHA1" | ||
EXPORT_VAR_DIRTY="$DIRTY" | ||
EXPORT_VAR_BUILD_LABEL="$BUILD_LABEL" | ||
EXPORT_VAR_BUILD_DATE="$BUILD_DATE" | ||
|
||
|
||
# Get a list of all ENV vars and internal defined vars that begin with prefix | ||
VAR_LIST=$(eval "set -o posix ; set | grep '^$VAR_PREFIX'") | ||
|
||
# Generate a JSON document for version_info containing the vars | ||
# Using HERE documents to allow pretty printing | ||
JSON=$(cat <<EOF | ||
{ | ||
"version_info": { | ||
EOF | ||
) | ||
|
||
# Generate key value pair for each exported var | ||
# Make the keys lower case | ||
while IFS='=' read -r name value ; do | ||
JSON+=" | ||
" | ||
JSON+=" " | ||
# Strip prefix and make lower case | ||
JSON+=\"$(echo ${name#$VAR_PREFIX} | tr '[:upper:]' '[:lower:]')\" | ||
# Value of variable, same as $value also | ||
JSON+=": \"${!name}\"," | ||
done <<< "$VAR_LIST" | ||
|
||
# Eliminate trailing comma | ||
# Only trim the comma from last matching line, JSON var contains newlines | ||
JSON=$(echo "$JSON" | sed '$ s/,$//') | ||
|
||
# End the JSON document | ||
JSON+=$(cat <<-EOF | ||
} | ||
} | ||
EOF | ||
) | ||
|
||
# Based on parameter, output key value pairs or JSON document | ||
case "$1" in | ||
keyvalue) | ||
|
||
# For each exported var, output key value pair | ||
# Allows sourcing the output to be used in Makefile | ||
while IFS='=' read -r name value ; do | ||
# Strip prefix | ||
echo "${name#$VAR_PREFIX}=${!name}" | ||
done <<< "$VAR_LIST" | ||
|
||
# Also output the JSON document in single line format for completeness | ||
echo VERSION_INFO_JSON=\'$JSON\' | ||
;; | ||
|
||
json) | ||
# Output the JSON variable, wrap in quotes to preserve newlines | ||
echo "$JSON" | ||
;; | ||
|
||
*) | ||
echo "Usage: $0 [keyvalue|json]" | ||
exit 1 | ||
;; | ||
esac |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.