Merge pull request #73 from davidnewhall/dn2_5_11_support

Update unifi library for controller 5.11.x support.
This commit is contained in:
David Newhall II 2019-07-07 19:35:40 -07:00 committed by GitHub
commit 1b723f2bd4
7 changed files with 26 additions and 35 deletions

View File

@ -26,7 +26,7 @@ install:
- make docker - make docker
script: script:
# Test built docker image. # 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 # test and build everything
- rvm 2.0.0 do make release - rvm 2.0.0 do make release
after_success: after_success:

View File

@ -41,8 +41,9 @@ in how it works for you.
### Docker ### Docker
Docker is built automatically by Docker Cloud using the Dockerfile in the path Docker is built automatically by Docker Cloud using the Dockerfile in the path
[init/docker/Dockerfile](init/docker/Dockerfile). Other than the Dockerfile, all [init/docker/Dockerfile](init/docker/Dockerfile). Some of the configuration is
the configuration is done in the Cloud service under my personal account `golift`. 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 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 changes are solving, and how it has been tested and validated. As far as I'm

View File

@ -10,12 +10,12 @@
version = "v0.3.1" version = "v0.3.1"
[[projects]] [[projects]]
digest = "1:fb7469e7ecb83c711771777f348ed800d021b92fbae4cc6eb894d8e0f548fbf9" digest = "1:2ef18d78259244526a58ed0970fab5d6a720c846913fe097d380b1203887d062"
name = "github.com/golift/unifi" name = "github.com/golift/unifi"
packages = ["."] packages = ["."]
pruneopts = "UT" pruneopts = "UT"
revision = "c726b0edc272822b879ced5060d19556f7e1a1e3" revision = "91cdba178bb856d3081a63d25540d78c919f9352"
version = "v3.0.0" version = "v3.1.0"
[[projects]] [[projects]]
branch = "master" branch = "master"

View File

@ -81,35 +81,35 @@ $(BINARY):
linux: $(BINARY).amd64.linux linux: $(BINARY).amd64.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)" GOOS=linux GOARCH=amd64 go build -o $@ -ldflags "-w -s -X $(VERSION_PATH)"
linux386: $(BINARY).i386.linux linux386: $(BINARY).i386.linux
$(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)" GOOS=linux GOARCH=386 go build -o $@ -ldflags "-w -s -X $(VERSION_PATH)"
arm: arm64 armhf arm: arm64 armhf
arm64: $(BINARY).arm64.linux arm64: $(BINARY).arm64.linux
$(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)" GOOS=linux GOARCH=arm64 go build -o $@ -ldflags "-w -s -X $(VERSION_PATH)"
armhf: $(BINARY).armhf.linux armhf: $(BINARY).armhf.linux
$(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)" GOOS=linux GOARCH=arm GOARM=6 go build -o $@ -ldflags "-w -s -X $(VERSION_PATH)"
macos: $(BINARY).amd64.macos macos: $(BINARY).amd64.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)" GOOS=darwin GOARCH=amd64 go build -o $@ -ldflags "-w -s -X $(VERSION_PATH)"
exe: $(BINARY).amd64.exe exe: $(BINARY).amd64.exe
windows: $(BINARY).amd64.exe windows: $(BINARY).amd64.exe
$(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)" GOOS=windows GOARCH=amd64 go build -o $@ -ldflags "-w -s -X $(VERSION_PATH)"
# Packages # Packages

View File

@ -1,26 +1,22 @@
# #
# building static go binary with Debian golang container # building static go binary with Debian golang container
# #
ARG BINARY=unifi-poller
ARG REPO=github.com/davidnewhall/${BINARY}
FROM golang:stretch as builder FROM golang:stretch as builder
ARG ARCH=amd64 ARG ARCH=amd64
ARG OS=linux ARG OS=linux
ARG BINARY
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 \ RUN apt-get update \
&& apt-get install -y curl \ && apt-get install -y curl \
&& curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh && curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
COPY . $GOPATH/src/${REPO} COPY . $GOPATH/src/github.com/davidnewhall/unifi-poller
WORKDIR $GOPATH/src/${REPO} WORKDIR $GOPATH/src/github.com/davidnewhall/unifi-poller
RUN dep ensure --vendor-only \ RUN dep ensure --vendor-only \
&& CGO_ENABLED=0 make ${BINARY}.${ARCH}.${OS} \ && CGO_ENABLED=0 make unifi-poller.${ARCH}.${OS} \
&& mv ${BINARY}.${ARCH}.${OS} ${BINARY} && mv unifi-poller.${ARCH}.${OS} unifi-poller
# #
# creating container for run # creating container for run
@ -32,11 +28,9 @@ RUN dep ensure --vendor-only \
# #
FROM scratch FROM scratch
ARG REPO
ARG BINARY
COPY --from=builder /go/src/${REPO}/${BINARY} /${BINARY} COPY --from=builder /go/src/github.com/davidnewhall/unifi-poller/unifi-poller /unifi-poller
COPY --from=builder /go/src/${REPO}/examples/up.conf.example /etc/${BINARY}/up.conf COPY --from=builder /go/src/github.com/davidnewhall/unifi-poller/examples/up.conf.example /etc/unifi-poller}/up.conf
VOLUME [ "/etc/${BINARY}" ] VOLUME [ "/etc/unifi-poller" ]
ENTRYPOINT [ "/${BINARY}" ] ENTRYPOINT [ "/unifi-poller" ]

View File

@ -7,7 +7,7 @@ set -e -o pipefail
VERSION=$(git tag -l --merged | tail -n1 | tr -d v) # 1.2.3 VERSION=$(git tag -l --merged | tail -n1 | tr -d v) # 1.2.3
SHORTVER=$(echo $VERSION | cut -d. -f1,2) # 1.2 SHORTVER=$(echo $VERSION | cut -d. -f1,2) # 1.2
if [ "$BUILDS" != "" ] && [ "$VERSION" != "" ]; then if [ "$BUILDS" != "" ] && [ "$VERSION" != "" ]; then
TAGS=latest TAGS=$DOCKER_TAG
fi fi
# Push the extra custom images that were created. # Push the extra custom images that were created.
@ -20,8 +20,8 @@ for build in $BUILDS; do
done done
echo "Annotating Images: ${IMAGES}" 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.
[ "$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}" echo "Version: $VERSION, Source: $SOURCE_BRANCH, Building tags: ${TAGS}"
# Create multi-architecture manifests for each tag with all the built images. # Create multi-architecture manifests for each tag with all the built images.

View File

@ -125,11 +125,7 @@ func (u *UnifiPoller) GetUnifi() (err error) {
} }
u.Unifi.ErrorLog = u.LogErrorf // Log all errors. u.Unifi.ErrorLog = u.LogErrorf // Log all errors.
u.Unifi.DebugLog = u.LogDebugf // Log debug messages. u.Unifi.DebugLog = u.LogDebugf // Log debug messages.
v, err := u.GetServer() u.Logf("Authenticated to UniFi Controller at %s version %s as user %s", u.UnifiBase, u.ServerVersion, u.UnifiUser)
if err != nil {
return err
}
u.Logf("Authenticated to UniFi Controller at %s version %s as user %s", u.UnifiBase, v.ServerVersion, u.UnifiUser)
if err := u.CheckSites(); err != nil { if err := u.CheckSites(); err != nil {
return err return err
} }