Skip to content

Commit

Permalink
change name of plugin to app-metric-registrar and add build script
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Fuller <[email protected]>
  • Loading branch information
Max Eshleman authored and Ben Fuller committed Aug 20, 2018
1 parent a969ed2 commit b3858e9
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
55 changes: 55 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
set -e

pushd() {
command pushd $@ >/dev/null
}

popd() {
command popd $@ >/dev/null
}

pushd $(dirname $(dirname $0))
PROJECT_ROOT=$(pwd -P)
popd

PLUGIN_OUTPUT=${PLUGIN_DIRECTORY:-${PROJECT_ROOT}/plugins}
mkdir -p ${PLUGIN_OUTPUT}
pushd ${PLUGIN_OUTPUT}
PLUGIN_OUTPUT=$(pwd -P)
popd

function build_for() {
local OS=$1
local ARCH=$2

echo "Building CLI for $OS $ARCH..."

BUILD_NUMBER=${VERSION:-0.0.1}
MAJOR_MINOR_PATCH=( ${BUILD_NUMBER//./ })
VERSION_FLAGS="-X main.Major=${MAJOR_MINOR_PATCH[0]} -X main.Minor=${MAJOR_MINOR_PATCH[1]} -X main.Patch=${MAJOR_MINOR_PATCH[2]}"

GOARCH=${ARCH} GOOS=${OS} go build -o ${PLUGIN_OUTPUT}/app-metrics-registrar-${OS}-${ARCH}-${BUILD_NUMBER} -ldflags "${VERSION_FLAGS}"
}

pushd ${PROJECT_ROOT}
source .envrc

echo "Fetching dependencies..."
[[ -z "${NO_DEP:-}" ]] && go get github.com/golang/dep/cmd/dep

pushd src/cliplugin
[[ -z "${NO_DEP:-}" ]] && dep ensure

if [[ -n "${CLI_BUILD_OS}" ]]; then
build_for ${CLI_BUILD_OS} ${CLI_BUILD_ARCH:-amd64}
else
for OS in windows linux darwin; do
build_for ${OS} amd64
done
for OS in windows linux; do
build_for ${OS} 386
done
fi
popd
popd
2 changes: 1 addition & 1 deletion scripts/reinstall.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

set -e
cf uninstall-plugin pm-please-add-details || true # suppress errors
cf uninstall-plugin app-metric-registrar || true # suppress errors

cd "$(dirname $0)/../src/cliplugin"
go build -o bin/cli
Expand Down
2 changes: 1 addition & 1 deletion src/cliplugin/command/prism_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
)

const pluginName = "pm-please-add-details" // also in scripts/reinstall.sh
const pluginName = "app-metric-registrar"
const registerLogFormatCommand = "register-log-format"
const registerMetricsEndpointCommand = "register-metrics-endpoint"
const registerLogFormatUsage = "cf register-log-format APPNAME FORMAT"
Expand Down

0 comments on commit b3858e9

Please sign in to comment.