From 2a5dba54af1cf4cf6df0585b0d24cbbfc5d61323 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 7 Jul 2019 16:38:46 -0700 Subject: [PATCH 1/8] Update unifi library. --- integrations/inputunifi/Gopkg.lock | 6 +++--- integrations/inputunifi/unifipoller/start.go | 6 +----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/integrations/inputunifi/Gopkg.lock b/integrations/inputunifi/Gopkg.lock index c3e3b5fb..d6f8347f 100644 --- a/integrations/inputunifi/Gopkg.lock +++ b/integrations/inputunifi/Gopkg.lock @@ -10,12 +10,12 @@ version = "v0.3.1" [[projects]] - digest = "1:fb7469e7ecb83c711771777f348ed800d021b92fbae4cc6eb894d8e0f548fbf9" + digest = "1:2ef18d78259244526a58ed0970fab5d6a720c846913fe097d380b1203887d062" name = "github.com/golift/unifi" packages = ["."] pruneopts = "UT" - revision = "c726b0edc272822b879ced5060d19556f7e1a1e3" - version = "v3.0.0" + revision = "91cdba178bb856d3081a63d25540d78c919f9352" + version = "v3.1.0" [[projects]] branch = "master" diff --git a/integrations/inputunifi/unifipoller/start.go b/integrations/inputunifi/unifipoller/start.go index 9d368f64..bb6d8fb8 100644 --- a/integrations/inputunifi/unifipoller/start.go +++ b/integrations/inputunifi/unifipoller/start.go @@ -125,11 +125,7 @@ func (u *UnifiPoller) GetUnifi() (err error) { } u.Unifi.ErrorLog = u.LogErrorf // Log all errors. u.Unifi.DebugLog = u.LogDebugf // Log debug messages. - v, err := u.GetServer() - if err != nil { - return err - } - u.Logf("Authenticated to UniFi Controller at %s version %s as user %s", u.UnifiBase, v.ServerVersion, u.UnifiUser) + u.Logf("Authenticated to UniFi Controller at %s version %s as user %s", u.UnifiBase, u.ServerVersion, u.UnifiUser) if err := u.CheckSites(); err != nil { return err } From 8b107e968575a6617939d862f1df15693c9d17f5 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 7 Jul 2019 16:44:46 -0700 Subject: [PATCH 2/8] do not build release from branches. --- integrations/inputunifi/init/docker/hooks/push | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integrations/inputunifi/init/docker/hooks/push b/integrations/inputunifi/init/docker/hooks/push index c1aa530d..47a4afe2 100755 --- a/integrations/inputunifi/init/docker/hooks/push +++ b/integrations/inputunifi/init/docker/hooks/push @@ -21,7 +21,7 @@ done echo "Annotating Images: ${IMAGES}" # Build all the Docker tags if the github branch is a release and not master. -[ "$SOURCE_BRANCH" == "master" ] || TAGS="latest $VERSION $SHORTVER stable" +[ "v$VERSION" != "$SOURCE_BRANCH" ] || TAGS="latest $VERSION $SHORTVER stable" echo "Version: $VERSION, Source: $SOURCE_BRANCH, Building tags: ${TAGS}" # Create multi-architecture manifests for each tag with all the built images. From 4b2e8c2ee20ff1df12f69d01e4fdf4a00d558290 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 7 Jul 2019 17:05:33 -0700 Subject: [PATCH 3/8] dont update latest from a branch --- integrations/inputunifi/init/docker/hooks/push | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integrations/inputunifi/init/docker/hooks/push b/integrations/inputunifi/init/docker/hooks/push index 47a4afe2..632eee95 100755 --- a/integrations/inputunifi/init/docker/hooks/push +++ b/integrations/inputunifi/init/docker/hooks/push @@ -7,7 +7,7 @@ set -e -o pipefail VERSION=$(git tag -l --merged | tail -n1 | tr -d v) # 1.2.3 SHORTVER=$(echo $VERSION | cut -d. -f1,2) # 1.2 if [ "$BUILDS" != "" ] && [ "$VERSION" != "" ]; then - TAGS=latest + TAGS=$DOCKER_TAG fi # Push the extra custom images that were created. From 28722c0af0341a45e2c4a15e60aa2f73fda0f2c0 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 7 Jul 2019 17:08:04 -0700 Subject: [PATCH 4/8] udpate comment. --- integrations/inputunifi/init/docker/hooks/push | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integrations/inputunifi/init/docker/hooks/push b/integrations/inputunifi/init/docker/hooks/push index 632eee95..b324e9e9 100755 --- a/integrations/inputunifi/init/docker/hooks/push +++ b/integrations/inputunifi/init/docker/hooks/push @@ -20,7 +20,7 @@ for build in $BUILDS; do done echo "Annotating Images: ${IMAGES}" -# Build all the Docker tags if the github branch is a release and not master. +# Build all the Docker tags if the source branch is a release and not a branch. [ "v$VERSION" != "$SOURCE_BRANCH" ] || TAGS="latest $VERSION $SHORTVER stable" echo "Version: $VERSION, Source: $SOURCE_BRANCH, Building tags: ${TAGS}" From 503821105bb730211f67ebb99d3ee0b71a7006a2 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 7 Jul 2019 17:18:26 -0700 Subject: [PATCH 5/8] Fix Dockerfile. --- integrations/inputunifi/.travis.yml | 2 +- integrations/inputunifi/init/docker/Dockerfile | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/integrations/inputunifi/.travis.yml b/integrations/inputunifi/.travis.yml index 5cbb840d..da2fea15 100644 --- a/integrations/inputunifi/.travis.yml +++ b/integrations/inputunifi/.travis.yml @@ -26,7 +26,7 @@ install: - make docker script: # Test built docker image. -- docker run golift/unifi-poller 2>&1 | grep -Eq "Loading Configuration File[:] /etc/unifi-poller/up.conf" +- docker run golift/unifi-poller:local 2>&1 | grep -Eq "Loading Configuration File[:] /etc/unifi-poller/up.conf" # test and build everything - rvm 2.0.0 do make release after_success: diff --git a/integrations/inputunifi/init/docker/Dockerfile b/integrations/inputunifi/init/docker/Dockerfile index 80c3cbab..00c9b9fe 100644 --- a/integrations/inputunifi/init/docker/Dockerfile +++ b/integrations/inputunifi/init/docker/Dockerfile @@ -1,13 +1,11 @@ # # building static go binary with Debian golang container # -ARG BINARY=unifi-poller -ARG REPO=github.com/davidnewhall/${BINARY} +ARG REPO=github.com/davidnewhall/unifi-poller FROM golang:stretch as builder ARG ARCH=amd64 ARG OS=linux -ARG BINARY ARG REPO RUN mkdir -p $GOPATH/pkg/mod $GOPATH/bin $GOPATH/src/${REPO} @@ -19,8 +17,8 @@ COPY . $GOPATH/src/${REPO} WORKDIR $GOPATH/src/${REPO} RUN dep ensure --vendor-only \ - && CGO_ENABLED=0 make ${BINARY}.${ARCH}.${OS} \ - && mv ${BINARY}.${ARCH}.${OS} ${BINARY} + && CGO_ENABLED=0 make unifi-poller.${ARCH}.${OS} \ + && mv unifi-poller.${ARCH}.${OS} unifi-poller # # creating container for run @@ -33,10 +31,9 @@ RUN dep ensure --vendor-only \ FROM scratch ARG REPO -ARG BINARY -COPY --from=builder /go/src/${REPO}/${BINARY} /${BINARY} -COPY --from=builder /go/src/${REPO}/examples/up.conf.example /etc/${BINARY}/up.conf +COPY --from=builder /go/src/${REPO}/unifi-poller /unifi-poller +COPY --from=builder /go/src/${REPO}/examples/up.conf.example /etc/unifi-poller}/up.conf -VOLUME [ "/etc/${BINARY}" ] -ENTRYPOINT [ "/${BINARY}" ] +VOLUME [ "/etc/unifi-poller" ] +ENTRYPOINT [ "/unifi-poller" ] From 23d5d069e583c567fc82fe3977f5b8ed9759d584 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 7 Jul 2019 17:21:47 -0700 Subject: [PATCH 6/8] just remove repo, it was a bad idea. --- integrations/inputunifi/init/docker/Dockerfile | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/integrations/inputunifi/init/docker/Dockerfile b/integrations/inputunifi/init/docker/Dockerfile index 00c9b9fe..aaa7050b 100644 --- a/integrations/inputunifi/init/docker/Dockerfile +++ b/integrations/inputunifi/init/docker/Dockerfile @@ -1,20 +1,18 @@ # # building static go binary with Debian golang container # -ARG REPO=github.com/davidnewhall/unifi-poller FROM golang:stretch as builder ARG ARCH=amd64 ARG OS=linux -ARG REPO -RUN mkdir -p $GOPATH/pkg/mod $GOPATH/bin $GOPATH/src/${REPO} +RUN mkdir -p $GOPATH/pkg/mod $GOPATH/bin $GOPATH/src/github.com/davidnewhall/unifi-poller RUN apt-get update \ && apt-get install -y curl \ && curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh -COPY . $GOPATH/src/${REPO} -WORKDIR $GOPATH/src/${REPO} +COPY . $GOPATH/src/github.com/davidnewhall/unifi-poller +WORKDIR $GOPATH/src/github.com/davidnewhall/unifi-poller RUN dep ensure --vendor-only \ && CGO_ENABLED=0 make unifi-poller.${ARCH}.${OS} \ @@ -30,10 +28,9 @@ RUN dep ensure --vendor-only \ # FROM scratch -ARG REPO -COPY --from=builder /go/src/${REPO}/unifi-poller /unifi-poller -COPY --from=builder /go/src/${REPO}/examples/up.conf.example /etc/unifi-poller}/up.conf +COPY --from=builder /go/src/github.com/davidnewhall/unifi-poller/unifi-poller /unifi-poller +COPY --from=builder /go/src/github.com/davidnewhall/unifi-poller/examples/up.conf.example /etc/unifi-poller}/up.conf VOLUME [ "/etc/unifi-poller" ] ENTRYPOINT [ "/unifi-poller" ] From ce443387770e4088b76cfc7b61a8c69c4533ad4d Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 7 Jul 2019 17:24:07 -0700 Subject: [PATCH 7/8] Update comments. --- integrations/inputunifi/Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/integrations/inputunifi/Makefile b/integrations/inputunifi/Makefile index e321a1e8..8fc1e1d8 100644 --- a/integrations/inputunifi/Makefile +++ b/integrations/inputunifi/Makefile @@ -81,35 +81,35 @@ $(BINARY): linux: $(BINARY).amd64.linux $(BINARY).amd64.linux: - # Building linux binary. + # Building linux 64-bit x86 binary. GOOS=linux GOARCH=amd64 go build -o $@ -ldflags "-w -s -X $(VERSION_PATH)" linux386: $(BINARY).i386.linux $(BINARY).i386.linux: - # Building linux binary. + # Building linux 32-bit x86 binary. GOOS=linux GOARCH=386 go build -o $@ -ldflags "-w -s -X $(VERSION_PATH)" arm: arm64 armhf arm64: $(BINARY).arm64.linux $(BINARY).arm64.linux: - # Building linux binary. + # Building linux 64-bit ARM binary. GOOS=linux GOARCH=arm64 go build -o $@ -ldflags "-w -s -X $(VERSION_PATH)" armhf: $(BINARY).armhf.linux $(BINARY).armhf.linux: - # Building linux binary. + # Building linux 32-bit ARM binary. GOOS=linux GOARCH=arm GOARM=6 go build -o $@ -ldflags "-w -s -X $(VERSION_PATH)" macos: $(BINARY).amd64.macos $(BINARY).amd64.macos: - # Building darwin binary. + # Building darwin 64-bit x86 binary. GOOS=darwin GOARCH=amd64 go build -o $@ -ldflags "-w -s -X $(VERSION_PATH)" exe: $(BINARY).amd64.exe windows: $(BINARY).amd64.exe $(BINARY).amd64.exe: - # Building windows binary. + # Building windows 64-bit x86 binary. GOOS=windows GOARCH=amd64 go build -o $@ -ldflags "-w -s -X $(VERSION_PATH)" # Packages From 0cc4a73b9e50496868fba749093a7d1efc2ad0d0 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sun, 7 Jul 2019 17:33:21 -0700 Subject: [PATCH 8/8] udpate file. --- integrations/inputunifi/CONTRIBUTING.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/integrations/inputunifi/CONTRIBUTING.md b/integrations/inputunifi/CONTRIBUTING.md index c3e07e47..004875b7 100644 --- a/integrations/inputunifi/CONTRIBUTING.md +++ b/integrations/inputunifi/CONTRIBUTING.md @@ -41,8 +41,9 @@ in how it works for you. ### Docker Docker is built automatically by Docker Cloud using the Dockerfile in the path -[init/docker/Dockerfile](init/docker/Dockerfile). Other than the Dockerfile, all -the configuration is done in the Cloud service under my personal account `golift`. +[init/docker/Dockerfile](init/docker/Dockerfile). Some of the configuration is +done in the Cloud service under my personal account `golift`, but the majority +happens in the build files in the [init/docker/hooks/](init/docker/hooks/) directory. If you have need to change the Dockerfile, please clearly explain what problem your changes are solving, and how it has been tested and validated. As far as I'm