Skip to content

Commit

Permalink
Reworked structure to use latest packit buildpack structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ForestEckhardt committed Jun 30, 2020
1 parent e339091 commit 1136d0d
Show file tree
Hide file tree
Showing 15 changed files with 237 additions and 66 deletions.
2 changes: 1 addition & 1 deletion build.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package entrypoint

import (
"path/filepath"
Expand Down
6 changes: 3 additions & 3 deletions build_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main_test
package entrypoint_test

import (
"errors"
Expand All @@ -9,7 +9,7 @@ import (
"github.com/paketo-buildpacks/packit"
"github.com/sclevine/spec"

main "github.com/ForestEckhardt/entrypoint"
"github.com/ForestEckhardt/entrypoint"

. "github.com/onsi/gomega"
)
Expand All @@ -26,7 +26,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) {
it.Before(func() {
entrypointParser = &fakes.EntrypointParser{}

build = main.Build(entrypointParser)
build = entrypoint.Build(entrypointParser)
})

context("there is an entrypoint.toml in the app dir", func() {
Expand Down
2 changes: 1 addition & 1 deletion detect.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package entrypoint

import (
"os"
Expand Down
7 changes: 3 additions & 4 deletions detect_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package main_test
package entrypoint_test

import (
"io/ioutil"
"os"
"path/filepath"
"testing"

"github.com/ForestEckhardt/entrypoint"
"github.com/paketo-buildpacks/packit"
"github.com/sclevine/spec"

main "github.com/ForestEckhardt/entrypoint"

. "github.com/onsi/gomega"
)

Expand All @@ -28,7 +27,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {
workingDir, err = ioutil.TempDir("", "workingDir")
Expect(err).NotTo(HaveOccurred())

detect = main.Detect()
detect = entrypoint.Detect()
})

it.After(func() {
Expand Down
2 changes: 1 addition & 1 deletion entrypoint_toml_parser.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package entrypoint

import (
"fmt"
Expand Down
9 changes: 4 additions & 5 deletions entrypoint_toml_parser_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package main_test
package entrypoint_test

import (
"io/ioutil"
"os"
"path/filepath"
"testing"

"github.com/ForestEckhardt/entrypoint"
"github.com/paketo-buildpacks/packit"

main "github.com/ForestEckhardt/entrypoint"

. "github.com/onsi/gomega"
"github.com/sclevine/spec"
)
Expand All @@ -19,15 +18,15 @@ func testEntrypointTOMLParser(t *testing.T, context spec.G, it spec.S) {
Expect = NewWithT(t).Expect
workingDir string

entrypointTOMLParser main.EntrypointTOMLParser
entrypointTOMLParser entrypoint.EntrypointTOMLParser
)

it.Before(func() {
var err error
workingDir, err = ioutil.TempDir("", "working-dir")
Expect(err).NotTo(HaveOccurred())

entrypointTOMLParser = main.NewEntrypointTOMLParser()
entrypointTOMLParser = entrypoint.NewEntrypointTOMLParser()
})

it.After(func() {
Expand Down
19 changes: 6 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,12 @@ module github.com/ForestEckhardt/entrypoint
go 1.14

require (
cloud.google.com/go v0.60.0 // indirect
github.com/BurntSushi/toml v0.3.1
github.com/cloudfoundry/dagger v0.0.0-20200507160821-634aab680698
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/golang/protobuf v1.4.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/onsi/ginkgo v1.12.0 // indirect
github.com/onsi/gomega v1.10.0
github.com/paketo-buildpacks/occam v0.0.4
github.com/paketo-buildpacks/packit v0.0.10
github.com/cloudfoundry/dagger v0.0.0-20200626131330-a2c02e949e17
github.com/mitchellh/mapstructure v1.3.2 // indirect
github.com/onsi/gomega v1.10.1
github.com/paketo-buildpacks/occam v0.0.16
github.com/paketo-buildpacks/packit v0.2.0
github.com/sclevine/spec v1.4.0
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e // indirect
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
)
192 changes: 174 additions & 18 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion init_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main_test
package entrypoint_test

import (
"testing"
Expand Down
11 changes: 0 additions & 11 deletions main.go

This file was deleted.

15 changes: 15 additions & 0 deletions run/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main

import (
"github.com/ForestEckhardt/entrypoint"
"github.com/paketo-buildpacks/packit"
)

func main() {
entrypointTOMLParser := entrypoint.NewEntrypointTOMLParser()

packit.Run(
entrypoint.Detect(),
entrypoint.Build(entrypointTOMLParser),
)
}
6 changes: 2 additions & 4 deletions scripts/.util/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ function util::tools::path::export() {
}

function util::tools::jam::install () {
echo "-> Installing v0.0.10 jam..."

local dir
while [[ "${#}" != 0 ]]; do
case "${1}" in
Expand Down Expand Up @@ -55,7 +53,7 @@ function util::tools::jam::install () {

if [[ ! -f "${dir}/jam" ]]; then
local version
version="v0.0.10"
version="v0.0.14"

util::print::title "Installing jam ${version}"
curl "https://github.com/paketo-buildpacks/packit/releases/download/${version}/jam-${os}" \
Expand Down Expand Up @@ -132,6 +130,6 @@ function util::tools::packager::install () {

if [[ ! -f "${dir}/packager" ]]; then
util::print::title "Installing packager"
GOBIN="${dir}" go install github.com/cloudfoundry/libcfbuildpack/packager
GOBIN="${dir}" go get github.com/cloudfoundry/libcfbuildpack/packager
fi
}
22 changes: 22 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@ readonly BUILDPACKDIR="$(cd "${PROGDIR}/.." && pwd)"
function main() {
mkdir -p "${BUILDPACKDIR}/bin"

if [[ -f "${BUILDPACKDIR}/run/main.go" ]]; then
pushd "${BUILDPACKDIR}/bin" > /dev/null || return
printf "%s" "Building run..."

GOOS=linux \
go build \
-ldflags="-s -w" \
-o "run" \
"${BUILDPACKDIR}/run"

echo "Success!"

for name in detect build; do
printf "%s" "Linking ${name}..."

ln -sf "run" "${name}"

echo "Success!"
done
popd > /dev/null || return
fi

if [[ -f "${BUILDPACKDIR}/main.go" ]]; then
pushd "${BUILDPACKDIR}/bin" > /dev/null || return
printf "%s" "Building run..."
Expand Down
2 changes: 1 addition & 1 deletion scripts/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function token::fetch() {
function tests::run() {
util::print::title "Run Buildpack Runtime Integration Tests"
pushd "${BUILDPACKDIR}" > /dev/null
if GOMAXPROCS=4 go test -timeout 0 ./integration/... -v -run Integration; then
if GOMAXPROCS="${GOMAXPROCS:-4}" go test -count=1 -timeout 0 ./integration/... -v -run Integration; then
util::print::success "** GO Test Succeeded **"
else
util::print::error "** GO Test Failed **"
Expand Down
6 changes: 3 additions & 3 deletions scripts/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ function main() {
#use jam
util::tools::jam::install --directory "${BUILDPACKDIR}/.bin"
if [[ -z "${version:-}" ]]; then #version not provided, use latest git tag
git_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
version=${git_tag:1}
git_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)" || echo "v0.0.0")
version=${git_tag:1}
fi

extra_args=""
Expand Down Expand Up @@ -93,7 +93,7 @@ function main() {
fi

if [[ -z "${version:-}" ]]; then
version="$(cd "${BUILDPACKDIR}" && git describe --tags `git rev-list --tags --max-count=1`)"
version="$(cd "${BUILDPACKDIR}" && git describe --tags "$(git rev-list --tags --max-count=1)" || echo "v0.0.0")"
fi

args="${args} -version ${version}"
Expand Down

0 comments on commit 1136d0d

Please sign in to comment.