* Add Virtual Kubelet provider for VIC Initial virtual kubelet provider for VMware VIC. This provider currently handles creating and starting of a pod VM via the VIC portlayer and persona server. Image store handling via the VIC persona server. This provider currently requires the feature/wolfpack branch of VIC. * Added pod stop and delete. Also added node capacity. Added the ability to stop and delete pod VMs via VIC. Also retrieve node capacity information from the VCH. * Cleanup and readme file Some file clean up and added a Readme.md markdown file for the VIC provider. * Cleaned up errors, added function comments, moved operation code 1. Cleaned up error handling. Set standard for creating errors. 2. Added method prototype comments for all interface functions. 3. Moved PodCreator, PodStarter, PodStopper, and PodDeleter to a new folder. * Add mocking code and unit tests for podcache, podcreator, and podstarter Used the unit test framework used in VIC to handle assertions in the provider's unit test. Mocking code generated using OSS project mockery, which is compatible with the testify assertion framework. * Vendored packages for the VIC provider Requires feature/wolfpack branch of VIC and a few specific commit sha of projects used within VIC. * Implementation of POD Stopper and Deleter unit tests (#4) * Updated files for initial PR
121 lines
3.6 KiB
Bash
Executable File
121 lines
3.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# Copyright 2016-2017 VMware, Inc. 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.
|
|
|
|
# Simple script that will check files of type .go, .sh, .bash, .robot, or Makefile
|
|
# for the copyright header.
|
|
#
|
|
# This will be called by the CI system (with no args) to perform checking and
|
|
# fail the job if headers are not correctly set. It can also be called with the
|
|
# 'fix' argument to automatically add headers to the missing files.
|
|
#
|
|
# Check if headers are fine:
|
|
# $ ./scripts/header-check.sh
|
|
# Check and fix headers:
|
|
# All changes must be committed for fix to work
|
|
# $ ./scripts/header-check.sh fix
|
|
|
|
set -e -o pipefail
|
|
|
|
# These header variables MUST match the first two lines of the
|
|
# VMware-copyright file in the scripts directory.
|
|
#
|
|
# These will be evaluated as a regex against the target file
|
|
HEADER[1]="^\/\/ Copyright [0-9]{4}(-[0-9]{4})? VMware, Inc\. All Rights Reserved\.$"
|
|
HEADER[2]="^\/\/$"
|
|
|
|
# Initialize vars
|
|
ERR=false
|
|
FAIL=false
|
|
|
|
all-files() {
|
|
git ls-files |\
|
|
# Check .go files, Makefile, sh files, bash files, and robot files
|
|
grep -e "\.go$" -e "Makefile$" -e "\.sh$" -e "\.bash$" -e "\.robot$" |\
|
|
# Ignore vendor/
|
|
grep -v vendor/ |\
|
|
grep -v lib/apiservers/portlayer/client | grep -v lib/apiservers/portlayer/models
|
|
}
|
|
|
|
for file in $(all-files); do
|
|
# get the file extension / type
|
|
ext=${file##*.}
|
|
|
|
# increment line count in certain cases
|
|
increment=false
|
|
|
|
# should we be incrementing the line count
|
|
if [[ $ext == "sh" ]]; then
|
|
increment=true
|
|
fi
|
|
|
|
for count in $(seq 1 ${#HEADER[@]}); do
|
|
if [[ $ext != "go" ]]; then
|
|
# if not go code assuming # will suffice
|
|
text="${HEADER[$count]/'\/\/'/#}"
|
|
else
|
|
text=${HEADER[$count]}
|
|
fi
|
|
|
|
if [[ "$increment" = true ]]; then
|
|
line=$((count + 1))
|
|
else
|
|
line=$count
|
|
fi
|
|
# do we have a header match?
|
|
if [[ ! $(sed ${line}q\;d ${file}) =~ ${text} ]]; then
|
|
ERR=true
|
|
fi
|
|
done
|
|
|
|
if [ $ERR == true ]; then
|
|
# is there is a fix argument and are all changes committed
|
|
if [[ $# -gt 0 && $1 =~ [[:upper:]fix] ]]; then
|
|
# based on file type fix the copyright
|
|
case "$ext" in
|
|
go)
|
|
cat $(dirname $0)/VMware-copyright ${file} > ${file}.new
|
|
;;
|
|
sh)
|
|
head -1 ${file} > ${file}.new
|
|
cat $(dirname $0)/VMware-copyright | sed 's/\/\//\#/1' >> ${file}.new
|
|
grep -v '#!/bin/bash' ${file} >> ${file}.new
|
|
;;
|
|
*)
|
|
cat $(dirname $0)/VMware-copyright | sed 's/\/\//\#/1' > ${file}.new
|
|
cat ${file} >> ${file}.new
|
|
;;
|
|
esac
|
|
|
|
if [ "$(uname -s)" = "Darwin" ]; then
|
|
permissions=$(stat -f "%OLp" ${file})
|
|
else
|
|
permissions=$(stat --format '%a' ${file})
|
|
fi
|
|
mv ${file}.new ${file}
|
|
# make permissions the same
|
|
chmod $permissions ${file}
|
|
echo "$file.. $(tput -T xterm setaf 3)FIXING$(tput -T xterm sgr0)"
|
|
ERR=false
|
|
else
|
|
echo "$file.. $(tput -T xterm setaf 1)FAIL$(tput -T xterm sgr0)"
|
|
ERR=false
|
|
FAIL=true
|
|
fi
|
|
fi
|
|
done
|
|
|
|
# If we failed one check, return 1
|
|
[ $FAIL == true ] && exit 1 || exit 0
|