diff --git a/integrations/inputunifi/.metadata.sh b/integrations/inputunifi/.metadata.sh index b0c2a17d..2ae87146 100755 --- a/integrations/inputunifi/.metadata.sh +++ b/integrations/inputunifi/.metadata.sh @@ -25,13 +25,17 @@ export BINARY GHUSER HBREPO MAINT VENDOR DESC GOLANGCI_LINT_ARGS CONFIG_FILE LIC # Fix the repo if it doesn't match the binary name. # Provide a better URL if one exists. -GHREPO="${GHUSER}/${BINARY}" -URL="https://github.com/${GHREPO}" +# Used as go import path in docker and homebrew builds. +IMPORT_PATH="github.com/${GHUSER}/${BINARY}" +# Used for source links and wiki links. +SOURCE_URL="https://${IMPORT_PATH}" +# Used for documentation links. +URL="${SOURCE_URL}" # This parameter is passed in as -X to go build. Used to override the Version variable in a package. -# This makes a path like github.com/davidnewhall/unifi-poller/unifipoller.Version=1.3.3 +# This makes a path like github.com/user/hello-world/helloworld.Version=1.3.3 # Name the Version-containing library the same as the github repo, without dashes. -VERSION_PATH="github.com/${GHREPO}/$(echo ${BINARY} | tr -d -- -).Version" +VERSION_PATH="${IMPORT_PATH}/$(echo ${BINARY} | tr -d -- -).Version" # Dynamic. Recommend not changing. VVERSION=$(git describe --abbrev=0 --tags $(git rev-list --tags --max-count=1)) @@ -41,4 +45,9 @@ ITERATION=$(git rev-list --count --all || echo 0) DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" COMMIT="$(git rev-parse --short HEAD || echo 0)" -export GHREPO URL VERSION_PATH VERSION ITERATION DATE COMMIT +# Used by homebrew downloads. +#SOURCE_PATH=https://codeload.${IMPORT_PATH}/tar.gz/v${VERSION} +# This is a custom download path for homebrew formula. +SOURCE_PATH=https://code.golift.io/${BINARY}/tar.gz/v${VERSION} + +export IMPORT_PATH SOURCE_URL URL VERSION_PATH VVERSION VERSION ITERATION DATE COMMIT SOURCE_PATH diff --git a/integrations/inputunifi/.secret_files.tar.enc b/integrations/inputunifi/.secret_files.tar.enc index 9a799392..be29d514 100644 Binary files a/integrations/inputunifi/.secret_files.tar.enc and b/integrations/inputunifi/.secret_files.tar.enc differ diff --git a/integrations/inputunifi/Gopkg.lock b/integrations/inputunifi/Gopkg.lock index 1b50da39..8238a21c 100644 --- a/integrations/inputunifi/Gopkg.lock +++ b/integrations/inputunifi/Gopkg.lock @@ -2,12 +2,12 @@ [[projects]] - digest = "1:b414adbcdaa6d8a2f2dd02ad8cc94a57b8bb66480a443e68dc10e6d40540c358" + digest = "1:6a0be013a234fe00d3c080db2b887aee9cd6bc8f3f559b8b7a079150c34ba017" name = "code.golift.io/unifi" packages = ["."] pruneopts = "UT" - revision = "184dbe828623689015fdfa2627f7f6810411b07e" - version = "v3.3.0" + revision = "c998e559a9b52f7e7859de86e7f69b40582d3e37" + version = "v3.3.2" [[projects]] digest = "1:9f3b30d9f8e0d7040f729b82dcbc8f0dead820a133b3147ce355fc451f32d761" diff --git a/integrations/inputunifi/Makefile b/integrations/inputunifi/Makefile index 25349e1d..21b3524e 100644 --- a/integrations/inputunifi/Makefile +++ b/integrations/inputunifi/Makefile @@ -47,7 +47,7 @@ endef all: build # Prepare a release. Called in Travis CI. -release: clean macos arm windows linux_packages +release: clean macos windows linux_packages # Prepareing a release! mkdir -p $@ mv $(BINARY).*.macos $(BINARY).*.linux $@/ @@ -211,7 +211,8 @@ docker: --build-arg "VENDOR=$(VENDOR)" \ --build-arg "AUTHOR=$(MAINT)" \ --build-arg "BINARY=$(BINARY)" \ - --build-arg "GHREPO=$(GHREPO)" \ + --build-arg "IMPORT_PATH=$(IMPORT_PATH)" \ + --build-arg "SOURCE_URL=$(SOURCE_URL)" \ --build-arg "CONFIG_FILE=$(CONFIG_FILE)" \ --tag $(BINARY) . @@ -229,7 +230,9 @@ $(BINARY).rb: v$(VERSION).tar.gz.sha256 init/homebrew/$(FORMULA).rb.tmpl -e "s/{{SHA256}}/$(shell head -c64 $<)/g" \ -e "s/{{Desc}}/$(DESC)/g" \ -e "s%{{URL}}%$(URL)%g" \ - -e "s%{{GHREPO}}%$(GHREPO)%g" \ + -e "s%{{IMPORT_PATH}}%$(IMPORT_PATH)%g" \ + -e "s%{{SOURCE_PATH}}%$(SOURCE_PATH)%g" \ + -e "s%{{SOURCE_URL}}%$(SOURCE_URL)%g" \ -e "s%{{CONFIG_FILE}}%$(CONFIG_FILE)%g" \ -e "s%{{Class}}%$(shell echo $(BINARY) | perl -pe 's/(?:\b|-)(\p{Ll})/\u$$1/g')%g" \ init/homebrew/$(FORMULA).rb.tmpl | tee $(BINARY).rb @@ -260,9 +263,9 @@ deps: install: man readme $(BINARY) @echo - Done Building! - @echo - Local installation with the Makefile is only supported on macOS. - @echo If you wish to install the application manually on Linux, check out the wiki: https://github.com/$(GHREPO)/wiki/Installation + @echo If you wish to install the application manually on Linux, check out the wiki: https://$(SOURCE_URL)/wiki/Installation @echo - Otherwise, build and install a package: make rpm -or- make deb - @echo See the Package Install wiki for more info: https://github.com/$(GHREPO)/wiki/Package-Install + @echo See the Package Install wiki for more info: https://$(SOURCE_URL)/wiki/Package-Install @[ "$(shell uname)" = "Darwin" ] || (echo "Unable to continue, not a Mac." && false) @[ "$(PREFIX)" != "" ] || (echo "Unable to continue, PREFIX not set. Use: make install PREFIX=/usr/local ETC=/usr/local/etc" && false) @[ "$(ETC)" != "" ] || (echo "Unable to continue, ETC not set. Use: make install PREFIX=/usr/local ETC=/usr/local/etc" && false) diff --git a/integrations/inputunifi/init/docker/Dockerfile b/integrations/inputunifi/init/docker/Dockerfile index 57eeb331..0321c55f 100644 --- a/integrations/inputunifi/init/docker/Dockerfile +++ b/integrations/inputunifi/init/docker/Dockerfile @@ -9,21 +9,21 @@ ARG BUILD_DATE=0 ARG COMMIT=0 ARG VERSION=unknown ARG BINARY=application-builder -ARG GHREPO=golift/application-builder +ARG IMPORT_PATH=github.com/golift/application-builder FROM golang:stretch as builder ARG ARCH ARG OS ARG BINARY -ARG GHREPO +ARG IMPORT_PATH -RUN mkdir -p $GOPATH/pkg/mod $GOPATH/bin $GOPATH/src/github.com/${GHREPO} +RUN mkdir -p $GOPATH/pkg/mod $GOPATH/bin $GOPATH/src/${IMPORT_PATH} RUN apt-get update \ && apt-get install -y curl \ && curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh -COPY . $GOPATH/src/github.com/${GHREPO} -WORKDIR $GOPATH/src/github.com/${GHREPO} +COPY . $GOPATH/src/${IMPORT_PATH} +WORKDIR $GOPATH/src/${IMPORT_PATH} RUN dep ensure --vendor-only \ && CGO_ENABLED=0 make ${BINARY}.${ARCH}.${OS} @@ -36,7 +36,8 @@ ARG COMMIT ARG VERSION ARG LICENSE=MIT ARG BINARY -ARG GHREPO +ARG IMPORT_PATH +ARG SOURCE_URL=http://github.com/golift/application-builder ARG URL=http://github.com/golift/application-builder ARG DESC=application-builder ARG VENDOR=golift @@ -46,19 +47,19 @@ ARG CONFIG_FILE=config.conf # Build-time metadata as defined at https://github.com/opencontainers/image-spec/blob/master/annotations.md LABEL org.opencontainers.image.created="${BUILD_DATE}" \ org.opencontainers.image.title="${BINARY}" \ - org.opencontainers.image.documentation="https://github.com/${GHREPO}/wiki/Docker" \ + org.opencontainers.image.documentation="${SOURCE_URL}/wiki/Docker" \ org.opencontainers.image.description="${DESC}" \ org.opencontainers.image.url="${URL}" \ org.opencontainers.image.revision="${COMMIT}" \ - org.opencontainers.image.source="https://github.com/${GHREPO}" \ + org.opencontainers.image.source="${SOURCE_URL}" \ org.opencontainers.image.vendor="${VENDOR}" \ org.opencontainers.image.authors="${AUTHOR}" \ org.opencontainers.image.architecture="${OS} ${ARCH}" \ org.opencontainers.image.licenses="${LICENSE}" \ org.opencontainers.image.version="${VERSION}" -COPY --from=builder /go/src/github.com/${GHREPO}/${BINARY}.${ARCH}.${OS} /image -COPY --from=builder /go/src/github.com/${GHREPO}/examples/${CONFIG_FILE}.example /etc/${BINARY}/${CONFIG_FILE} +COPY --from=builder /go/src/${IMPORT_PATH}/${BINARY}.${ARCH}.${OS} /image +COPY --from=builder /go/src/${IMPORT_PATH}/examples/${CONFIG_FILE}.example /etc/${BINARY}/${CONFIG_FILE} VOLUME [ "/etc/${BINARY}" ] ENTRYPOINT [ "/image" ] diff --git a/integrations/inputunifi/init/docker/hooks/build b/integrations/inputunifi/init/docker/hooks/build index 051c164b..3eb4e50e 100755 --- a/integrations/inputunifi/init/docker/hooks/build +++ b/integrations/inputunifi/init/docker/hooks/build @@ -28,7 +28,8 @@ for build in $BUILDS; do --build-arg "VENDOR=${VENDOR}" \ --build-arg "AUTHOR=${MAINT}" \ --build-arg "BINARY=${BINARY}" \ - --build-arg "GHREPO=${GHREPO}" \ + --build-arg "IMPORT_PATH=${IMPORT_PATH}" \ + --build-arg "SOURCE_URL=${SOURCE_URL}" \ --build-arg "CONFIG_FILE=${CONFIG_FILE}" \ --tag "${IMAGE_NAME}_${os}_${name}" \ --file ${DOCKERFILE_PATH} . diff --git a/integrations/inputunifi/init/homebrew/service.rb.tmpl b/integrations/inputunifi/init/homebrew/service.rb.tmpl index 85427ebc..ff8802d9 100644 --- a/integrations/inputunifi/init/homebrew/service.rb.tmpl +++ b/integrations/inputunifi/init/homebrew/service.rb.tmpl @@ -1,12 +1,13 @@ # Homebrew Formula Template. Built by Makefile: `make fomula` # This is part of Application Builder. # https://github.com/golift/application-builder +# This file is used when FORMULA is set to 'service'. class {{Class}} < Formula desc "{{Desc}}" homepage "{{URL}}" - url "{{URL}}/archive/v{{Version}}.tar.gz" + url "{{SOURCE_PATH}}" sha256 "{{SHA256}}" - head "{{URL}}" + head "{{SOURCE_URL}}" depends_on "go" => :build depends_on "dep" @@ -14,9 +15,9 @@ class {{Class}} < Formula def install ENV["GOPATH"] = buildpath - bin_path = buildpath/"src/github.com/{{GHREPO}}" + bin_path = buildpath/"src/{{IMPORT_PATH}}" # Copy all files from their current location (GOPATH root) - # to $GOPATH/src/github.com/{{GHREPO}} + # to $GOPATH/src/{{IMPORT_PATH}} bin_path.install Dir["*",".??*"] cd bin_path do system "dep", "ensure", "--vendor-only" @@ -49,7 +50,7 @@ class {{Class}} < Formula ProgramArguments #{bin}/#{name} - -c + --config #{etc}/#{name}/{{CONFIG_FILE}} RunAtLoad diff --git a/integrations/inputunifi/scripts/formula-deploy.sh b/integrations/inputunifi/scripts/formula-deploy.sh index a99b6521..843c5139 100755 --- a/integrations/inputunifi/scripts/formula-deploy.sh +++ b/integrations/inputunifi/scripts/formula-deploy.sh @@ -21,7 +21,7 @@ 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}\"}' + \"tags\": [\"${BINARY}\"], \"long_url\": \"${SOURCE_PATH}\"}' # 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 \"\$(