Clean up Makefile and scripts in scripts dir.

If command is simple command call it from Makefile,
there is no need to have them in separate shell scripts.
This commit is contained in:
Tomas Kral
2017-01-23 11:49:25 +01:00
parent f530f99f02
commit 20b844d6e9
16 changed files with 67 additions and 385 deletions
-19
View File
@@ -1,19 +0,0 @@
#!/bin/bash
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
GITCOMMIT=$(git rev-parse --short HEAD)
BUILD_FLAGS=(-ldflags="-w -X github.com/kubernetes-incubator/kompose/version.GITCOMMIT=${GITCOMMIT}")
-18
View File
@@ -1,18 +0,0 @@
#!/bin/bash
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# all Kompose packages (skip vendor dir)
PKGS=$( go list -e ./... | grep -v '/vendor/' )
-28
View File
@@ -1,28 +0,0 @@
#! /bin/bash
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
: ${PROG:=$(basename ${BASH_SOURCE})}
_cli_bash_autocomplete() {
local cur opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
}
complete -F _cli_bash_autocomplete $PROG
-36
View File
@@ -1,36 +0,0 @@
#!/bin/bash
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
source "$(dirname "$BASH_SOURCE")/.build"
OUT_FILE="./kompose"
# Get rid of existing binary
rm -f $OUT_FILE
# Build binary
go build \
"${BUILD_FLAGS[@]}" \
-o $OUT_FILE \
main.go
if [ $? -eq 0 ]; then
echo "Build successful. Program saved as ${OUT_FILE}"
else
echo "Build failed."
fi
-42
View File
@@ -1,42 +0,0 @@
#!/bin/bash
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
source "$(dirname "$BASH_SOURCE")/.build"
if [ -z "$1" ]; then
OS_PLATFORM_ARG=(-os="darwin linux windows")
else
OS_PLATFORM_ARG=($1)
fi
if [ -z "$2" ]; then
OS_ARCH_ARG=(-arch="386 amd64")
else
OS_ARCH_ARG=($2)
fi
GITCOMMIT=$(git rev-parse --short HEAD)
# Get rid of existing binaries
rm -f kompose*
# Build binaries
gox "${OS_PLATFORM_ARG[@]}" "${OS_ARCH_ARG[@]}" \
-output="bundles/kompose_{{.OS}}-{{.Arch}}/kompose" \
"${BUILD_FLAGS[@]}" \
.
@@ -14,11 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
source "$(dirname "$BASH_SOURCE")/.validate"
# This checks if all go source files in current directory are format using gofmt
GO_FILES=$(find . -path ./vendor -prune -o -name '*.go' -print )
for file in $GO_FILES; do
gofmtOutput=$(gofmt -l "$file")
if [ "$gofmtOutput" ]; then
@@ -27,7 +27,6 @@ for file in $GO_FILES; do
done
if [ ${#errors[@]} -eq 0 ]; then
echo "gofmt OK"
else
@@ -15,9 +15,8 @@ set -e
# See the License for the specific language governing permissions and
# limitations under the License.
source "$(dirname "$BASH_SOURCE")/.validate"
for pkg in $PKGS; do
for pkg in $(glide novendor); do
lintOutput=$(golint "$pkg")
# if lineOutput is not empty, save it to errros array
if [ "$lintOutput" ]; then
@@ -14,12 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Check if there are nested vendor dirs inside Kompose vendor.
# All dependencies should be flattened and there shouldn't be vendor in inside vendor.
function check_nested_vendor() {
echo "Checking if there are nested vendor dirs"
echo "Checking for nested vendor dirs"
# count all vendor directories inside Kompose vendor
NO_NESTED_VENDORS=$(find vendor/ -type d | sed 's/^[^/]*.//g' | grep -E "vendor$" | grep -v _vendor | wc -l)
@@ -41,7 +40,7 @@ function check_glide-vc() {
echo "Checking if vendor was cleaned using glide-vc."
# dry run glide-vc and count how many could be deleted.
NO_DELETED_FILES=$($GOPATH/bin/glide-vc --only-code --no-tests --dryrun | wc -l)
NO_DELETED_FILES=$(glide-vc --only-code --no-tests --dryrun | wc -l)
if [ $NO_DELETED_FILES -ne 0 ]; then
echo "ERROR"
-46
View File
@@ -1,46 +0,0 @@
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
export KOMPOSE_PKG='github.com/kubernetes-incubator/kompose'
# List of bundles to create when no argument is passed
DEFAULT_BUNDLES=(
validate-gofmt
validate-git-marks
validate-lint
validate-vet
binary
)
bundle() {
local bundle="$1"; shift
echo "---> Making bundle: $(basename "$bundle") (in $DEST)"
source "script/$bundle" "$@"
}
if [ $# -lt 1 ]; then
bundles=(${DEFAULT_BUNDLES[@]})
else
bundles=($@)
fi
for bundle in ${bundles[@]}; do
export DEST=.
ABS_DEST="$(cd "$DEST" && pwd -P)"
bundle "$bundle"
echo
done
-17
View File
@@ -1,17 +0,0 @@
#!/bin/bash
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
./script/test/cmd/tests.sh
-21
View File
@@ -1,21 +0,0 @@
#!/bin/bash
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
source "$(dirname "$BASH_SOURCE")/.build"
go test "${BUILD_FLAGS[@]}" -race -cover -v $( go list github.com/kubernetes-incubator/kompose/... | grep -v '/vendor/' )
-27
View File
@@ -1,27 +0,0 @@
#!/bin/bash
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
source "$(dirname "$BASH_SOURCE")/.build"
# Install packages that are dependencies of the test. (this will speed up go test runs)
go test -i -race -cover $( go list github.com/kubernetes-incubator/kompose/... | grep -v '/vendor/' )
# go test doesn't support colleting coverage across multiple packages,
# so this is why this runs go test for each package separately
# generate go test commands using go list and run tests
go list -f '"go test -race -cover -v -coverprofile={{.Dir}}/.coverprofile {{.ImportPath}}"' github.com/kubernetes-incubator/kompose/... | grep -v "vendor" | xargs -L 1 -P4 sh -c
-58
View File
@@ -1,58 +0,0 @@
#!/usr/bin/env bash
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
source "$(dirname "$BASH_SOURCE")/.validate"
# folders=$(find * -type d | egrep -v '^Godeps|bundles|.git')
IFS=$'\n'
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*' | grep -v '^vendor/' || true) )
unset IFS
badFiles=()
for f in "${files[@]}"; do
if [ $(grep -r "^<<<<<<<" $f) ]; then
badFiles+=( "$f" )
continue
fi
if [ $(grep -r "^>>>>>>>" $f) ]; then
badFiles+=( "$f" )
continue
fi
if [ $(grep -r "^=======$" $f) ]; then
badFiles+=( "$f" )
continue
fi
set -e
done
if [ ${#badFiles[@]} -eq 0 ]; then
echo 'Congratulations! There is no conflict.'
else
{
echo "There is trace of conflict(s) in the following files :"
for f in "${badFiles[@]}"; do
echo " - $f"
done
echo
echo 'Please fix the conflict(s) commit the result.'
echo
} >&2
false
fi
-21
View File
@@ -1,21 +0,0 @@
#!/bin/bash
set -e
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
source "$(dirname "$BASH_SOURCE")/.validate"
go vet $PKGS;