diff --git a/.secret_files.tar.enc b/.secret_files.tar.enc new file mode 100644 index 00000000..9a799392 Binary files /dev/null and b/.secret_files.tar.enc differ diff --git a/.travis.yml b/.travis.yml index 4382a921..f8ec6b19 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,16 +16,18 @@ go: services: - docker install: -- mkdir -p $GOPATH/bin + - mkdir -p $GOPATH/bin # 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 -- chmod +x $GOPATH/bin/dep + - curl -sLo $GOPATH/bin/dep https://github.com/golang/dep/releases/download/v0.5.3/dep-linux-amd64 + - chmod +x $GOPATH/bin/dep # 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 -- rvm install 2.0.0 -- rvm 2.0.0 do gem install --no-document fpm + - 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 2.0.0 do gem install --no-document fpm 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 - make vendor script: @@ -39,18 +41,20 @@ script: after_success: # Display Release Folder - 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 declare -r SSH_FILE="$(mktemp -u $HOME/.ssh/XXXXX)" echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> $HOME/.ssh/config - # Get deploy key for golift/homebrew-mugs. - 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" \ - && printf "%s\n" \ - "Host github.com" \ - " IdentityFile $SSH_FILE" \ - " StrictHostKeyChecking no" \ - " LogLevel ERROR" >> $HOME/.ssh/config + [ ! -f github_deploy_key ] || (mv github_deploy_key $SSH_FILE \ + && chmod 600 "$SSH_FILE" \ + && printf "%s\n" \ + "Host github.com" \ + " IdentityFile $SSH_FILE" \ + " StrictHostKeyChecking no" \ + " LogLevel ERROR" >> $HOME/.ssh/config) deploy: - provider: releases api_key: diff --git a/.travis/github_deploy_key.enc b/.travis/github_deploy_key.enc deleted file mode 100644 index bf0a7bf7..00000000 Binary files a/.travis/github_deploy_key.enc and /dev/null differ diff --git a/Gopkg.lock b/Gopkg.lock index dcba33f6..ccc103e9 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -10,12 +10,12 @@ version = "v0.3.1" [[projects]] - digest = "1:5dcb91bc89c052e58690416fafaf919def6e8e9ba018e143ffcfb10be961ba21" + digest = "1:b414adbcdaa6d8a2f2dd02ad8cc94a57b8bb66480a443e68dc10e6d40540c358" name = "github.com/golift/unifi" packages = ["."] pruneopts = "UT" - revision = "ecadb45c55ef371f3931333238ac9d1c827c684f" - version = "v3.2.0" + revision = "184dbe828623689015fdfa2627f7f6810411b07e" + version = "v3.3.0" [[projects]] branch = "master" diff --git a/README.md b/README.md index 0056d888..6fae649e 100644 --- a/README.md +++ b/README.md @@ -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) [![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/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) [![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+) diff --git a/scripts/formula-deploy.sh b/scripts/formula-deploy.sh index 52b6df18..80d7ebd5 100755 --- a/scripts/formula-deploy.sh +++ b/scripts/formula-deploy.sh @@ -15,6 +15,23 @@ git config --global user.name "${BINARY}-auto-releaser" rm -rf 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 \"\$( ${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 pushd homebrew_release_repo git add Formula/${BINARY}.rb diff --git a/unifipoller/dumper.go b/unifipoller/dumper.go index 18f4b50a..fe983407 100644 --- a/unifipoller/dumper.go +++ b/unifipoller/dumper.go @@ -23,7 +23,6 @@ func (u *UnifiPoller) DumpJSONPayload() (err error) { u.Unifi.ErrorLog = func(m string, v ...interface{}) { fmt.Fprintf(os.Stderr, "[ERROR] "+m, v...) } // Log all errors to stderr. - switch sites, err := u.GetFilteredSites(); { case err != nil: 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 { 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)