1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-16 15:21:33 +00:00

Initial Commit

This commit is contained in:
Darren Shepherd
2017-10-11 22:48:07 -07:00
commit 6623dd7352
54 changed files with 6626 additions and 0 deletions

10
scripts/build Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
set -e
source $(dirname $0)/version
cd $(dirname $0)/..
mkdir -p bin
[ "$(uname)" != "Darwin" ] && LINKFLAGS="-linkmode external -extldflags -static -s"
CGO_ENABLED=0 go build -ldflags "-X main.VERSION=$VERSION $LINKFLAGS" -o bin/norman

9
scripts/ci Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
set -e
cd $(dirname $0)
./build
./test
./validate
./package

11
scripts/entry Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
set -e
mkdir -p bin dist
if [ -e ./scripts/$1 ]; then
./scripts/"$@"
else
exec "$@"
fi
chown -R $DAPPER_UID:$DAPPER_GID .

24
scripts/package Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/bash
set -e
source $(dirname $0)/version
ARCH=${ARCH:-"amd64"}
SUFFIX=""
[ "${ARCH}" != "amd64" ] && SUFFIX="_${ARCH}"
cd $(dirname $0)/../package
TAG=${TAG:-${VERSION}${SUFFIX}}
REPO=${REPO:-rancher}
if echo $TAG | grep -q dirty; then
TAG=dev
fi
cp ../bin/norman .
IMAGE=${REPO}/norman:${TAG}
docker build -t ${IMAGE} .
echo ${IMAGE} > ../dist/images
echo Built ${IMAGE}

3
scripts/release Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
exec $(dirname $0)/ci

11
scripts/test Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
set -e
cd $(dirname $0)/..
echo Running tests
PACKAGES=". $(find -name '*.go' | xargs -I{} dirname {} | cut -f2 -d/ | sort -u | grep -Ev '(^\.$|.git|.trash-cache|vendor|bin)' | sed -e 's!^!./!' -e 's!$!/...!')"
[ "${ARCH}" == "amd64" ] && RACE=-race
go test ${RACE} -cover -tags=test ${PACKAGES}

20
scripts/validate Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/bash
set -e
cd $(dirname $0)/..
echo Running validation
PACKAGES=". $(find -name '*.go' | xargs -I{} dirname {} | cut -f2 -d/ | sort -u | grep -Ev '(^\.$|.git|.trash-cache|vendor|bin)' | sed -e 's!^!./!' -e 's!$!/...!')"
echo Running: go vet
go vet ${PACKAGES}
echo Running: golint
for i in ${PACKAGES}; do
if [ -n "$(golint $i | grep -v 'should have comment.*or be unexported' | tee /dev/stderr)" ]; then
failed=true
fi
done
test -z "$failed"
echo Running: go fmt
test -z "$(go fmt ${PACKAGES} | tee /dev/stderr)"

18
scripts/version Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
DIRTY="-dirty"
fi
COMMIT=$(git rev-parse --short HEAD)
GIT_TAG=$(git tag -l --contains HEAD | head -n 1)
if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then
VERSION=$GIT_TAG
else
VERSION="${COMMIT}${DIRTY}"
fi
if [ -z "$ARCH" ]; then
ARCH=amd64
fi