Merge pull request #83 from davidnewhall/dn2_updates

Update Library and application-builder code.
This commit is contained in:
David Newhall II 2019-07-13 04:04:36 -07:00 committed by GitHub
commit ef6421e935
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 41 additions and 21 deletions

BIN
.secret_files.tar.enc Normal file

Binary file not shown.

View File

@ -16,16 +16,18 @@ go:
services: services:
- docker - docker
install: install:
- mkdir -p $GOPATH/bin - mkdir -p $GOPATH/bin
# Download the `dep` binary to bin folder in $GOPATH # Download the `dep` binary to bin folder in $GOPATH
- curl -sLo $GOPATH/bin/dep https://github.com/golang/dep/releases/download/v0.5.3/dep-linux-amd64 - curl -sLo $GOPATH/bin/dep https://github.com/golang/dep/releases/download/v0.5.3/dep-linux-amd64
- chmod +x $GOPATH/bin/dep - chmod +x $GOPATH/bin/dep
# download super-linter: golangci-lint # download super-linter: golangci-lint
- curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin latest - curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin latest
#- curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin latest - rvm install 2.0.0
- rvm install 2.0.0 - rvm 2.0.0 do gem install --no-document fpm
- rvm 2.0.0 do gem install --no-document fpm
before_script: before_script:
# Create your own deploy key, tar it, and encrypt the file to make this work. Optionally add a bitly_token file to the archive.
- openssl aes-256-cbc -K $encrypted_9f3147001275_key -iv $encrypted_9f3147001275_iv -in .secret_files.tar.enc -out .secret_files.tar -d
- tar -xf .secret_files.tar
- source .metadata.sh - source .metadata.sh
- make vendor - make vendor
script: script:
@ -39,18 +41,20 @@ script:
after_success: after_success:
# Display Release Folder # Display Release Folder
- ls -l release/ - ls -l release/
# Setup the ssh client so we can clone and push to the homebrew formula repo.
# You must put github_deploy_file into .secret_files.tar.enc
# This is an ssh key added to your homebrew forumla repo.
- | - |
mkdir -p $HOME/.ssh mkdir -p $HOME/.ssh
declare -r SSH_FILE="$(mktemp -u $HOME/.ssh/XXXXX)" declare -r SSH_FILE="$(mktemp -u $HOME/.ssh/XXXXX)"
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> $HOME/.ssh/config echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> $HOME/.ssh/config
# Get deploy key for golift/homebrew-mugs. [ ! -f github_deploy_key ] || (mv github_deploy_key $SSH_FILE \
openssl aes-256-cbc -K $encrypted_9f3147001275_key -iv $encrypted_9f3147001275_iv -in ".travis/github_deploy_key.enc" -out "$SSH_FILE" -d && chmod 600 "$SSH_FILE" \
chmod 600 "$SSH_FILE" \ && printf "%s\n" \
&& printf "%s\n" \ "Host github.com" \
"Host github.com" \ " IdentityFile $SSH_FILE" \
" IdentityFile $SSH_FILE" \ " StrictHostKeyChecking no" \
" StrictHostKeyChecking no" \ " LogLevel ERROR" >> $HOME/.ssh/config)
" LogLevel ERROR" >> $HOME/.ssh/config
deploy: deploy:
- provider: releases - provider: releases
api_key: api_key:

Binary file not shown.

6
Gopkg.lock generated
View File

@ -10,12 +10,12 @@
version = "v0.3.1" version = "v0.3.1"
[[projects]] [[projects]]
digest = "1:5dcb91bc89c052e58690416fafaf919def6e8e9ba018e143ffcfb10be961ba21" digest = "1:b414adbcdaa6d8a2f2dd02ad8cc94a57b8bb66480a443e68dc10e6d40540c358"
name = "github.com/golift/unifi" name = "github.com/golift/unifi"
packages = ["."] packages = ["."]
pruneopts = "UT" pruneopts = "UT"
revision = "ecadb45c55ef371f3931333238ac9d1c827c684f" revision = "184dbe828623689015fdfa2627f7f6810411b07e"
version = "v3.2.0" version = "v3.3.0"
[[projects]] [[projects]]
branch = "master" branch = "master"

View File

@ -3,7 +3,7 @@
[![pulls](https://badgen.net/docker/pulls/golift/unifi-poller?icon=docker&label=pulls&color=0066ff "Docker Pulls")](https://hub.docker.com/r/golift/unifi-poller) [![pulls](https://badgen.net/docker/pulls/golift/unifi-poller?icon=docker&label=pulls&color=0066ff "Docker Pulls")](https://hub.docker.com/r/golift/unifi-poller)
[![DLs](https://img.shields.io/github/downloads/davidnewhall/unifi-poller/total.svg?logo=github&color=0066ff "GitHub Downloads")](https://www.somsubhra.com/github-release-stats/?username=davidnewhall&repository=unifi-poller) [![DLs](https://img.shields.io/github/downloads/davidnewhall/unifi-poller/total.svg?logo=github&color=0066ff "GitHub Downloads")](https://www.somsubhra.com/github-release-stats/?username=davidnewhall&repository=unifi-poller)
![stars](https://badgen.net/github/stars/davidnewhall/unifi-poller?icon=github&label=stars&color=0066ff "GitHub Stars") ![stars](https://badgen.net/github/stars/davidnewhall/unifi-poller?icon=github&label=stars&color=0066ff "GitHub Stars")
![stars](https://badgen.net/badge/UniFi/5.10.x,5.11.x,UAP,USG,USW?list=|&icon=&color=0099ee "GitHub Stars") ![unifi](https://badgen.net/badge/UniFi/5.10.x,5.11.x,UAP,USG,USW?list=|&icon=&color=0099ee "UniFi")
[![issues](https://badgen.net/github/closed-issues/davidnewhall/unifi-poller?color=green&icon=github "Closed Issues")](https://github.com/davidnewhall/unifi-poller/issues?q=is%3Aissue+is%3Aclosed) [![issues](https://badgen.net/github/closed-issues/davidnewhall/unifi-poller?color=green&icon=github "Closed Issues")](https://github.com/davidnewhall/unifi-poller/issues?q=is%3Aissue+is%3Aclosed)
[![PRs](https://badgen.net/github/prs/davidnewhall/unifi-poller?icon=github&color=green "Pull Requests")](https://github.com/davidnewhall/unifi-poller/pulls?utf8=✓&q=is%3Apr+) [![PRs](https://badgen.net/github/prs/davidnewhall/unifi-poller?icon=github&color=green "Pull Requests")](https://github.com/davidnewhall/unifi-poller/pulls?utf8=✓&q=is%3Apr+)

View File

@ -15,6 +15,23 @@ git config --global user.name "${BINARY}-auto-releaser"
rm -rf homebrew_release_repo rm -rf homebrew_release_repo
git clone git@github.com:${HBREPO}.git homebrew_release_repo git clone git@github.com:${HBREPO}.git homebrew_release_repo
# If a bitly token file exists, we'll use that to shorten the link (and allow download counting).
if [ -f "bitly_token" ]; then
API=https://api-ssl.bitly.com/v4/bitlinks
# Request payload. In single quotes with double quotes escaped. :see_no_evil:
JSON='{\"domain\": \"bit.ly\",\"title\": \"${BINARY}.v${VERSION}-${ITERATION}.tgz\", \
\"tags\": [\"${BINARY}\"], \"long_url\": \"https://codeload.github.com/${GHREPO}/tar.gz/v${VERSION}\"}'
# Request with headers and data. Using bash -c to hide token from bash -x in travis logs.
OUT=$(bash -c "curl -s -X POST -H 'Content-type: application/json' ${API} -H \"\$(<bitly_token)\" -d \"${JSON}\"")
# Extract link from reply.
LINK="$(echo ${OUT} | jq -r .link | sed 's/http:/https:/')?v=v${VERSION}"
# Replace link in formula.
sed "s#^ url.*\$# url \"${LINK}\"#" ${BINARY}.rb > ${BINARY}.rb.new
if [ "$?" = "0" ] && [ "$LINK" != "null?v=v${VERSION}" ] && [ "$LINK" != "?v=v${VERSION}" ]; then
mv ${BINARY}.rb.new ${BINARY}.rb
fi
fi
cp ${BINARY}.rb homebrew_release_repo/Formula cp ${BINARY}.rb homebrew_release_repo/Formula
pushd homebrew_release_repo pushd homebrew_release_repo
git add Formula/${BINARY}.rb git add Formula/${BINARY}.rb

View File

@ -23,7 +23,6 @@ func (u *UnifiPoller) DumpJSONPayload() (err error) {
u.Unifi.ErrorLog = func(m string, v ...interface{}) { u.Unifi.ErrorLog = func(m string, v ...interface{}) {
fmt.Fprintf(os.Stderr, "[ERROR] "+m, v...) fmt.Fprintf(os.Stderr, "[ERROR] "+m, v...)
} // Log all errors to stderr. } // Log all errors to stderr.
switch sites, err := u.GetFilteredSites(); { switch sites, err := u.GetFilteredSites(); {
case err != nil: case err != nil:
return err return err
@ -40,7 +39,7 @@ func (u *UnifiPoller) DumpJSONPayload() (err error) {
} }
} }
func (u *UnifiPoller) dumpSitesJSON(path, name string, sites []unifi.Site) error { func (u *UnifiPoller) dumpSitesJSON(path, name string, sites unifi.Sites) error {
for _, s := range sites { for _, s := range sites {
apiPath := fmt.Sprintf(path, s.Name) apiPath := fmt.Sprintf(path, s.Name)
_, _ = fmt.Fprintf(os.Stderr, "[INFO] Dumping %s: '%s' JSON for site: %s (%s):\n", name, apiPath, s.Desc, s.Name) _, _ = fmt.Fprintf(os.Stderr, "[INFO] Dumping %s: '%s' JSON for site: %s (%s):\n", name, apiPath, s.Desc, s.Name)