Commit c6ca4344 authored by Emily Gu's avatar Emily Gu Committed by GitHub

Merge pull request #18 from nanliu/pluginsync

Update from Intelsdi-x pluginsync 0.1.5
parents e564bced 52ead64d
<!--
Thanks for filing an issue! Before hitting the button, give this a read.
If you are reporting a new issue, make sure that we do not have any duplicates already open. You can ensure this by searching the issue list for this repository. If there is a duplicate, please close your issue and add a comment to the existing issue instead.
If you suspect your issue is a bug, please add as much context as you can using the template below. If it is not a bug, remove any sections you don't need and explain how we can help.
As a basic rule, if you cannot provide enough information to continue addressing the issue within 7 days, a maintainer will close it. We will, however, reopen it if you later provide the information. Thanks again.
-->
**Snap version** (use `snapctl -v`):
**Environment**:
- **Cloud provider or hardware configuration**:
- **OS** (e.g. from /etc/os-release):
- **Kernel** (e.g. `uname -a`):
- **Relevant tools** (e.g. plugins used with Snap):
- **Others** (e.g. deploying with Ansible):
**What happened**:
**What you expected to happen**:
**Steps to reproduce it** (as minimally and precisely as possible):
1.
2.
3.
**Anything else do we need to know** (e.g. issue happens only occasionally):
<!--
If this is a bug fix, make sure your description includes "fixes #xxxx", or
"closes #xxxx"
Please provide the following information:
-->
Fixes #
Summary of changes:
-
-
-
How to verify it:
-
Testing done:
-
A picture of a snapping turtle (not required but encouraged):
-
# File managed by pluginsync
#
# NOTE: please commit OS/Editor specific settings in your .gitignore_global
# .idea
# .DS_Store
#
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
......@@ -21,17 +27,15 @@ _testmain.go
*.exe
*.test
.idea
tmp/
*.tmp
scratch/
build/
*.swp
*.prof
# Output of the go coverage tool
*.out
profile.cov
gin-bin
# we don't vendor godep _workspace
**/Godeps/_workspace/**
vendor/
# OSX stuff
.DS_Store
# ignore build artifacts
build/
pluginsync_config: '0.1.5'
managed_files:
- .github
- .github/ISSUE_TEMPLATE.md
- .github/PULL_REQUEST_TEMPLATE.md
- .gitignore
- .pluginsync.yml
- .travis.yml
- CONTRIBUTING.md
- LICENSE
- Makefile
- scripts
- scripts/build.sh
- scripts/common.sh
- scripts/deps.sh
- scripts/pre_deploy.sh
- scripts/test.sh
.travis.yml:
deploy:
access_key_id: AKIAINMB43VSSPFZISAA
secret_access_key:
secure: bAkHPM5L7HyZLmsqTjUoGHTNFRQZxjo8DrBR/CLl13c0NfdiopHO1RI8aQ5HViMfCT9f8Xww33SACQLdI1XbeiBEONC0VdOIZB7ZTxgAE+05vKZUHVKVwwxV4Y8SvyZug+TXwHv50iwvLxWxSXNLv6AOOstbJy8vzXQUWl/NgyeiQrf7FbBpK02QjMenwpkjngQAd12dR+ZeKVshOBUZ8XWG/sDjqcthOQmo+x+PqPG+Z93BKXIY+3RCvapwUFETiYk+oikcW8I+ZoX3T6NJhuLE7Nm9ZK3RYzvc5D1i2m1U3McuZgPTB8vyQjLOhfSFTos+Fv+BlUQpyR7v9qXfveSB0IMfDG7GJu5+R45YkKsvmXXC5EPd3Aa8j92mKW12VMkQdO7YSdYBFsHYAYL1Y7zvC9rDc1SAO4Q2UBbrz8x93SIEZWPGrxzgONS1wMFtdWzzDv+6GtwO/1i2WoMyg+nRo47OYY2wUWRz4UTOjmVS2O/RGbbfHCSrWLsVQy++631CprKluhcasr8wCptDMYhlFKEzgZ1PBhNVE+dZ+1A4oDC/nscjN8VkuEGYJkjvfvEry3693y772789yxf2YjOZLsQ7RuuypDagK5I9fHM8JZ7E77xKqn6/g814TlFLHSC4bKtc2I+eKlOUwbIyKoUu4p6K2yEOVKrHcaHB3dM=
api_key:
secure: I2gtRWoC4iQsYAzdnuhkqoBVep740cVD9gEoyROKzklnANqZGYVXcS9pak3Ir5HxM/j+UDwglBW6wzjWLrJFtWW43FVlYwnzxhfWMaEAwVfwrpaORq2Vhofa4z5ES0Y1OQSX34N9QIYXC8gMlygsWUvUTvdCsGwb7Jls2MrHAAtkDAIm3yz7VPDpkcQtfWhjjLn06GroazYebwn14UaALvsFxMveVzyoFVxa67rirj1rZz9aDX/2t60on5J7MGb6kQb4YAu2b+k9sfAXkcFgOFGniK7NUoSHK2j4ddnqUrAFoy55lKeogNQFcAx2sFIM7lK1AsMYjuospcGp+U7x4i6rtsj/+JekZPBITDHjIxlZWitxi9dqEeVGczcx0ieyncoFBnWudmalBcB9K7xNGDit8t0UF8uyRDc7CzkDTHsNH+K7ACJ66mI0+Wz1SyE3c4WzaWEK4wQNtxBA9lyuUIAAJIYYkvCGzPp1Bj3SR1GpDS9hSHONaRRoIzR/+AbYiZ5Qfq4Ghei0i0jJ/2XNC1sut4g+UyEXnRlRoXkRLfWiQBkSd9sw06AF0+IULF1P2F5PA9jb4SCVtlmodFImGaCjtY/ywEiwCBVcp/P9F7HuFKOOSmTHv10neCyeFShno/w/DFkSW2NdQG3nQK/p7Tnh/njCaXFMjlArnBecRHE=
scripts/deps.sh:
packages:
- github.com/smartystreets/goconvey # NOTE: this should be moved to godep/glide
- github.com/stretchr/testify/mock
sudo: required
# File managed by pluginsync
sudo: false
language: go
go:
- 1.5.3
- 1.6
- 1.6.3
- 1.7.1
env:
global:
- SNAP_PLUGIN_SOURCE=/home/travis/gopath/src/github.com/intelsdi-x/snap-plugin-collector-df
- ORG_PATH=/home/travis/gopath/src/github.com/intelsdi-x
- SNAP_PLUGIN_SOURCE=/home/travis/gopath/src/github.com/${TRAVIS_REPO_SLUG}
matrix:
- TEST=unit
- TEST_TYPE=small
- TEST_TYPE=build
matrix:
exclude:
- go: 1.6.3
env: TEST_TYPE=build
before_install:
- go get github.com/tools/godep
- if [ ! -d $SNAP_PLUGIN_SOURCE ]; then mkdir -p $HOME/gopath/src/github.com/intelsdi-x; ln -s $TRAVIS_BUILD_DIR $SNAP_PLUGIN_SOURCE; fi # CI for forks not from intelsdi-x
- "[[ -d $SNAP_PLUGIN_SOURCE ]] || mkdir -p $ORG_PATH && ln -s $TRAVIS_BUILD_DIR $SNAP_PLUGIN_SOURCE"
install:
- export TMPDIR=$HOME/tmp
- mkdir -p $TMPDIR
- cd $SNAP_PLUGIN_SOURCE # change dir into source
- cd $SNAP_PLUGIN_SOURCE
- make deps
script:
- make check TEST=$TEST 2>&1 # Run test suite
- make check 2>&1
notifications:
email: false
slack:
secure: VkbZLIc2RH8yf3PtIAxUNPdAu3rQQ7yQx0GcK124JhbEnZGaHyK615V0rbG7HcVmYKGPdB0cXqZiLBDKGqGKb2zR1NepOe1nF03jxGSpPq8jIFeEXSJGEYGL34ScDzZZGuG6qwbjFcXiW5lqn6t8igzp7v2+URYBaZo5ktCS2xY=
before_deploy:
- "./scripts/pre_deploy.sh"
deploy:
- provider: s3
access_key_id: AKIAINMB43VSSPFZISAA
secret_access_key:
secure: bAkHPM5L7HyZLmsqTjUoGHTNFRQZxjo8DrBR/CLl13c0NfdiopHO1RI8aQ5HViMfCT9f8Xww33SACQLdI1XbeiBEONC0VdOIZB7ZTxgAE+05vKZUHVKVwwxV4Y8SvyZug+TXwHv50iwvLxWxSXNLv6AOOstbJy8vzXQUWl/NgyeiQrf7FbBpK02QjMenwpkjngQAd12dR+ZeKVshOBUZ8XWG/sDjqcthOQmo+x+PqPG+Z93BKXIY+3RCvapwUFETiYk+oikcW8I+ZoX3T6NJhuLE7Nm9ZK3RYzvc5D1i2m1U3McuZgPTB8vyQjLOhfSFTos+Fv+BlUQpyR7v9qXfveSB0IMfDG7GJu5+R45YkKsvmXXC5EPd3Aa8j92mKW12VMkQdO7YSdYBFsHYAYL1Y7zvC9rDc1SAO4Q2UBbrz8x93SIEZWPGrxzgONS1wMFtdWzzDv+6GtwO/1i2WoMyg+nRo47OYY2wUWRz4UTOjmVS2O/RGbbfHCSrWLsVQy++631CprKluhcasr8wCptDMYhlFKEzgZ1PBhNVE+dZ+1A4oDC/nscjN8VkuEGYJkjvfvEry3693y772789yxf2YjOZLsQ7RuuypDagK5I9fHM8JZ7E77xKqn6/g814TlFLHSC4bKtc2I+eKlOUwbIyKoUu4p6K2yEOVKrHcaHB3dM=
bucket: snap.ci.snap-telemetry.io
region: us-west-2
skip_cleanup: true
local-dir: s3
upload-dir: plugins
acl: public_read
on:
repo: intelsdi-x/snap-plugin-collector-df
branch: master
condition: $TEST_TYPE = "build" && $TRAVIS_GO_VERSION = "1.7.1"
- provider: s3
access_key_id: AKIAINMB43VSSPFZISAA
secret_access_key:
secure: bAkHPM5L7HyZLmsqTjUoGHTNFRQZxjo8DrBR/CLl13c0NfdiopHO1RI8aQ5HViMfCT9f8Xww33SACQLdI1XbeiBEONC0VdOIZB7ZTxgAE+05vKZUHVKVwwxV4Y8SvyZug+TXwHv50iwvLxWxSXNLv6AOOstbJy8vzXQUWl/NgyeiQrf7FbBpK02QjMenwpkjngQAd12dR+ZeKVshOBUZ8XWG/sDjqcthOQmo+x+PqPG+Z93BKXIY+3RCvapwUFETiYk+oikcW8I+ZoX3T6NJhuLE7Nm9ZK3RYzvc5D1i2m1U3McuZgPTB8vyQjLOhfSFTos+Fv+BlUQpyR7v9qXfveSB0IMfDG7GJu5+R45YkKsvmXXC5EPd3Aa8j92mKW12VMkQdO7YSdYBFsHYAYL1Y7zvC9rDc1SAO4Q2UBbrz8x93SIEZWPGrxzgONS1wMFtdWzzDv+6GtwO/1i2WoMyg+nRo47OYY2wUWRz4UTOjmVS2O/RGbbfHCSrWLsVQy++631CprKluhcasr8wCptDMYhlFKEzgZ1PBhNVE+dZ+1A4oDC/nscjN8VkuEGYJkjvfvEry3693y772789yxf2YjOZLsQ7RuuypDagK5I9fHM8JZ7E77xKqn6/g814TlFLHSC4bKtc2I+eKlOUwbIyKoUu4p6K2yEOVKrHcaHB3dM=
bucket: snap.ci.snap-telemetry.io
region: us-west-2
skip_cleanup: true
local-dir: s3
upload-dir: plugins
acl: public_read
on:
repo: intelsdi-x/snap-plugin-collector-df
tags: true
condition: $TEST_TYPE = "build" && $TRAVIS_GO_VERSION = "1.7.1"
- provider: releases
api_key:
secure: I2gtRWoC4iQsYAzdnuhkqoBVep740cVD9gEoyROKzklnANqZGYVXcS9pak3Ir5HxM/j+UDwglBW6wzjWLrJFtWW43FVlYwnzxhfWMaEAwVfwrpaORq2Vhofa4z5ES0Y1OQSX34N9QIYXC8gMlygsWUvUTvdCsGwb7Jls2MrHAAtkDAIm3yz7VPDpkcQtfWhjjLn06GroazYebwn14UaALvsFxMveVzyoFVxa67rirj1rZz9aDX/2t60on5J7MGb6kQb4YAu2b+k9sfAXkcFgOFGniK7NUoSHK2j4ddnqUrAFoy55lKeogNQFcAx2sFIM7lK1AsMYjuospcGp+U7x4i6rtsj/+JekZPBITDHjIxlZWitxi9dqEeVGczcx0ieyncoFBnWudmalBcB9K7xNGDit8t0UF8uyRDc7CzkDTHsNH+K7ACJ66mI0+Wz1SyE3c4WzaWEK4wQNtxBA9lyuUIAAJIYYkvCGzPp1Bj3SR1GpDS9hSHONaRRoIzR/+AbYiZ5Qfq4Ghei0i0jJ/2XNC1sut4g+UyEXnRlRoXkRLfWiQBkSd9sw06AF0+IULF1P2F5PA9jb4SCVtlmodFImGaCjtY/ywEiwCBVcp/P9F7HuFKOOSmTHv10neCyeFShno/w/DFkSW2NdQG3nQK/p7Tnh/njCaXFMjlArnBecRHE=
file:
- release/snap-plugin-collector-df_linux_x86_64
skip_cleanup: true
on:
repo: intelsdi-x/snap-plugin-collector-df
tags: true
condition: $TEST_TYPE = "build" && $TRAVIS_GO_VERSION = "1.7.1"
# snap collector plugin - df
# snap plugin collector df
1. [Contributing Code](#contributing-code)
2. [Contributing Examples](#contributing-examples)
......@@ -11,17 +11,17 @@ This repository has dedicated developers from Intel working on updates. The most
**_IMPORTANT_**: We encourage contributions to the project from the community. We ask that you keep the following guidelines in mind when planning your contribution.
* Whether your contribution is for a bug fix or a feature request, **create an [Issue](https://github.com/intelsdi-x/snap-plugin-collector-df/issues)** and let us know what you are thinking.
* **For bugs**, if you have already found a fix, feel free to submit a Pull Request referencing the Issue you created.
* **For feature requests**, we want to improve upon the library incrementally which means small changes at a time. In order ensure your PR can be reviewed in a timely manner, please keep PRs small, e.g. <10 files and <500 lines changed. If you think this is unrealistic, then mention that within the issue and we can discuss it.
* **For bugs**, if you have already found a fix, feel free to submit a Pull Request referencing the Issue you created. Include the `Fixes #` syntax to link it to the issue you're addressing.
* **For feature requests**, we want to improve upon the library incrementally which means small changes at a time. In order to ensure your PR can be reviewed in a timely manner, please keep PRs small, e.g. <10 files and <500 lines changed. If you think this is unrealistic, then mention that within the issue and we can discuss it.
Once you're ready to contribute code back to this repo, start with these steps:
* Fork the appropriate sub-projects that are affected by your change.
* Clone the fork to `$GOPATH/src/github.com/intelsdi-x/`:
```
$ git clone https://github.com/<yourGithubID>/<project>.git
```
```
$ git clone https://github.com/<yourGithubID>/<project>.git
```
* Create a topic branch for your change and checkout that branch:
```
......@@ -31,17 +31,16 @@ Once you're ready to contribute code back to this repo, start with these steps:
* Commit your changes and push them to your fork.
* Open a pull request for the appropriate project.
* Contributors will review your pull request, suggest changes, and merge it when it’s ready and/or offer feedback.
* To report a bug or issue, please open a new issue against this repository.
If you have questions feel free to contact the [maintainers](https://github.com/intelsdi-x/snap/blob/master/README.md#maintainers) by tagging them: @intelsdi-x/plugin-maintainers.
## Contributing Examples
The most immediately helpful way you can benefit this project is by cloning the repository, adding some further examples and submitting a pull request.
Have you written a blog post about how you use Snap? Send it to us [on Gitter](https://gitter.im/intelsdi-x/snap)!
Have you written a blog post about how you use [Snap](http://github.com/intelsdi-x/snap) and/or this plugin? Send it to us [on Slack](http://slack.snap-telemetry.io)!
## Contribute Elsewhere
This repository is one of **many** plugins in **snap**, a powerful telemetry framework. See the full project at http://github.com/intelsdi-x/snap.
This repository is one of **many** plugins in **Snap**, a powerful telemetry framework. See the full project at http://snap-telemetry.io
## Thank You
And **thank you!** Your contribution, through code and participation, is incredibly important to us.
# File managed by pluginsync
# http://www.apache.org/licenses/LICENSE-2.0.txt
#
#
# Copyright 2015 Intel Corporation
#
# 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.
default:
$(MAKE) deps
$(MAKE) all
deps:
bash -c "godep restore"
bash -c "./scripts/deps.sh"
test:
bash -c "./scripts/test.sh $(TEST)"
bash -c "./scripts/test.sh $(TEST_TYPE)"
test-legacy:
bash -c "./scripts/test.sh legacy"
test-small:
bash -c "./scripts/test.sh small"
test-medium:
bash -c "./scripts/test.sh medium"
test-large:
bash -c "./scripts/test.sh large"
check:
$(MAKE) test
all:
......
#!/bin/bash -e
#!/bin/bash
# File managed by pluginsync
GITVERSION=`git describe --always`
SOURCEDIR=$1
BUILDDIR=$SOURCEDIR/build
PLUGIN=`echo $SOURCEDIR | grep -oh "snap-.*"`
ROOTFS=$BUILDDIR/rootfs
BUILDCMD='go build -a -ldflags "-w"'
# http://www.apache.org/licenses/LICENSE-2.0.txt
#
#
# Copyright 2016 Intel Corporation
#
# 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.
echo
echo "**** Snap Plugin Build ****"
echo
set -e
set -u
set -o pipefail
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__proj_dir="$(dirname "$__dir")"
# shellcheck source=scripts/common.sh
. "${__dir}/common.sh"
plugin_name=${__proj_dir##*/}
build_dir="${__proj_dir}/build"
go_build=(go build -ldflags "-w")
_info "project path: ${__proj_dir}"
_info "plugin name: ${plugin_name}"
# Disable CGO for builds
export CGO_ENABLED=0
# Clean build bin dir
rm -rf $ROOTFS/*
# Make dir
mkdir -p $ROOTFS
# rebuild binaries:
_debug "removing: ${build_dir:?}/*"
rm -rf "${build_dir:?}/"*
# Build plugin
echo "Source Dir = $SOURCEDIR"
echo "Building Snap Plugin: $PLUGIN"
$BUILDCMD -o $ROOTFS/$PLUGIN
_info "building plugin: ${plugin_name}"
export GOOS=linux
export GOARCH=amd64
mkdir -p "${build_dir}/${GOOS}/x86_64"
"${go_build[@]}" -o "${build_dir}/${GOOS}/x86_64/${plugin_name}" . || exit 1
#!/bin/bash
# File managed by pluginsync
# http://www.apache.org/licenses/LICENSE-2.0.txt
#
#
# Copyright 2016 Intel Corporation
#
# 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
set -u
set -o pipefail
LOG_LEVEL="${LOG_LEVEL:-6}"
NO_COLOR="${NO_COLOR:-}"
trap_exitcode() {
exit $?
}
trap trap_exitcode SIGINT
_fmt () {
local color_debug="\x1b[35m"
local color_info="\x1b[32m"
local color_notice="\x1b[34m"
local color_warning="\x1b[33m"
local color_error="\x1b[31m"
local colorvar=color_$1
local color="${!colorvar:-$color_error}"
local color_reset="\x1b[0m"
if [ "${NO_COLOR}" = "true" ] || [[ "${TERM:-}" != "xterm"* ]] || [ -t 1 ]; then
# Don't use colors on pipes or non-recognized terminals
color=""; color_reset=""
fi
echo -e "$(date -u +"%Y-%m-%d %H:%M:%S UTC") ${color}$(printf "[%9s]" "${1}")${color_reset}";
}
_debug () { [ "${LOG_LEVEL}" -ge 7 ] && echo "$(_fmt debug) ${*}" 1>&2 || true; }
_info () { [ "${LOG_LEVEL}" -ge 6 ] && echo "$(_fmt info) ${*}" 1>&2 || true; }
_notice () { [ "${LOG_LEVEL}" -ge 5 ] && echo "$(_fmt notice) ${*}" 1>&2 || true; }
_warning () { [ "${LOG_LEVEL}" -ge 4 ] && echo "$(_fmt warning) ${*}" 1>&2 || true; }
_error () { [ "${LOG_LEVEL}" -ge 3 ] && echo "$(_fmt error) ${*}" 1>&2 || true; exit 1; }
_test_dirs() {
local test_dirs=$(find . -type f -name '*.go' -not -path "./.*" -not -path "*/_*" -not -path "./Godeps/*" -not -path "./vendor/*" -print0 | xargs -0 -n1 dirname| sort -u)
_debug "go code directories ${test_dirs}"
echo "${test_dirs}"
}
_go_get() {
local _url=$1
local _util
_util=$(basename "${_url}")
type -p "${_util}" > /dev/null || go get "${_url}" && _debug "go get ${_util} ${_url}"
}
_goimports() {
_go_get golang.org/x/tools/cmd/goimports
test -z "$(goimports -l -d $(find . -type f -name '*.go' -not -path "./vendor/*") | tee /dev/stderr)"
}
_golint() {
_go_get github.com/golang/lint/golint
golint ./...
}
_go_vet() {
go vet $(_test_dirs)
}
_go_race() {
go test -race ./...
}
_go_test() {
_info "running test type: ${TEST_TYPE}"
# Standard go tooling behavior is to ignore dirs with leading underscors
for dir in $(_test_dirs);
do
if [[ -z ${go_cover+x} ]]; then
_debug "running go test with cover in ${dir}"
go test -v --tags="${TEST_TYPE}" -covermode=count -coverprofile="${dir}/profile.tmp" "${dir}"
if [ -f "${dir}/profile.tmp" ]; then
tail -n +2 "${dir}/profile.tmp" >> profile.cov
rm "${dir}/profile.tmp"
fi
else
_debug "running go test without cover in ${dir}"
go test -v --tags="${TEST_TYPE}" "${dir}"
fi
done
}
_go_cover() {
go tool cover -func profile.cov
}
#!/bin/bash
# File managed by pluginsync
# http://www.apache.org/licenses/LICENSE-2.0.txt
#
#
# Copyright 2016 Intel Corporation
#
# 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
set -u
set -o pipefail
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__proj_dir="$(dirname "$__dir")"
# shellcheck source=scripts/common.sh
. "${__dir}/common.sh"
detect_go_dep() {
[[ -f "${__proj_dir}/Godeps/Godeps.json" ]] && _dep='godep'
[[ -f "${__proj_dir}/glide.yaml" ]] && _dep='glide'
[[ -f "${__proj_dir}/vendor/vendor.json" ]] && _dep='govendor'
_info "golang dependency tool: ${_dep}"
echo "${_dep}"
}
install_go_dep() {
local _dep=${_dep:=$(_detect_dep)}
_info "ensuring ${_dep} is available"
case $_dep in
godep)
_go_get github.com/tools/godep
;;
glide)
_go_get github.com/Masterminds/glide
;;
govendor)
_go_get github.com/kardianos/govendor
;;
esac
}
restore_go_dep() {
local _dep=${_dep:=$(_detect_dep)}
_info "restoring dependency with ${_dep}"
case $_dep in
godep)
(cd "${__proj_dir}" && godep restore)
;;
glide)
(cd "${__proj_dir}" && glide install)
;;
govendor)
(cd "${__proj_dir}" && govendor sync)
;;
esac
}
_dep=$(detect_go_dep)
install_go_dep
restore_go_dep
_go_get github.com/smartystreets/goconvey
_go_get github.com/stretchr/testify/mock
#!/bin/bash
# File managed by pluginsync
# http://www.apache.org/licenses/LICENSE-2.0.txt
#
#
# Copyright 2016 Intel Corporation
#
# 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
set -u
set -o pipefail
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__proj_dir="$(dirname "$__dir")"
# shellcheck source=scripts/common.sh
. "${__dir}/common.sh"
build_path="${__proj_dir}/build"
_info "build_path: ${build_path}"
_debug "$(find "${build_path}")"
plugin_name="${__proj_dir##*/}"
git_sha=$(git log --pretty=format:"%H" -1)
s3_path="${__proj_dir}/s3/${plugin_name}"
set +u
if [ -z "$TRAVIS_TAG" ]; then
set -u
git_path="${s3_path}/${git_sha}"
latest_path="${s3_path}/latest_build"
mkdir -p "${git_path}"
mkdir -p "${latest_path}"
_info "copying plugin binaries to ${git_path}"
cp -rp "${build_path}/"* "${git_path}"
_info "copying plugin binaries to ${latest_path}"
cp -rp "${build_path}/"* "${latest_path}"
else
set -u
tag_path="${s3_path}/${TRAVIS_TAG}"
latest_path="${s3_path}/latest"
mkdir -p "${tag_path}"
mkdir -p "${latest_path}"
_info "copying plugin binaries to ${tag_path}"
cp -rp "${build_path}/"* "${tag_path}"
_info "copying plugin binaries to ${latest_path}"
cp -rp "${build_path}/"* "${latest_path}"
fi
release_path="${SNAP_PATH:-"${__proj_dir}/release"}"
mkdir -p "${release_path}"
_info "moving plugin binaries to ${release_path}"
for file in "${build_path}"/**/*/snap-plugin-* ; do
filename="${file##*/}"
parent="${file%/*}"
arch="${parent##*/}"
parent="${parent%/*}"
os="${parent##*/}"
cp "${file}" "${release_path}/${filename}_${os}_${arch}"
done
_debug "$(find "${build_path}")"
_debug "$(find "${s3_path}")"
_debug "$(find "${release_path}")"
#!/bin/bash -e
# The script does automatic checking on a Go package and its sub-packages, including:
# 1. gofmt (http://golang.org/cmd/gofmt/)
# 2. goimports (https://github.com/bradfitz/goimports)
# 3. golint (https://github.com/golang/lint)
# 4. go vet (http://golang.org/cmd/vet)
# 5. race detector (http://blog.golang.org/race-detector)
# 6. test coverage (http://blog.golang.org/cover)
#!/bin/bash
# File managed by pluginsync
# Either command line or environment should be specified
if [ $# -ne 1 ] && [ -z "$TEST_SUITE" ]; then
echo "ERROR; missing TEST_SUITE (Usage: $0 TEST_SUITE)"
exit -2
fi
# Capture what test we should run from command line
if [ -z "$TEST_SUITE" ]; then
TEST_SUITE=$1
fi
# Check validity
if [ "$TEST_SUITE" != "unit" ]; then
echo "Error; invalid TEST_SUITE (value must be one of 'unit'; received $TEST_SUITE)"
exit -1