Skip to content

Commit

Permalink
Convert to simple powershell
Browse files Browse the repository at this point in the history
  • Loading branch information
dgodd committed Jan 21, 2019
1 parent e185966 commit ec60ccd
Show file tree
Hide file tree
Showing 25 changed files with 99 additions and 441 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
### Go Windows Buildpack User Documentation

### Building the Buildpack
To use this buildpack, run the following command from the buildpack's directory:

1. Build the buildpack
```bash
./scripts/build.ps1
```

1. Use [cfwindowsstager](https://github.com/dgodd/cfwindowsstager/releases) to test the buildpack
```bash
cfwindowsstager.exe --app .\fixtures\simple --buildpack .\go_buildpack-windows2016-v0.0.0.zip
```

1. Use in Cloud Foundry
Upload the buildpack to your Cloud Foundry and optionally specify it by name

```bash
cf create-buildpack [BUILDPACK_NAME] [BUILDPACK_ZIP_FILE_PATH] 1
cf push my_app [-b BUILDPACK_NAME]
```

### Reporting Issues
Open an issue on this project

## Disclaimer
This buildpack is intended purely for educational use and is not intended for production use.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.0
0.0.1
20 changes: 2 additions & 18 deletions bin/compile
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
#!/usr/bin/env bash
# This script is a deprecated but is provided for compatibility with Heroku and older versions of Cloud Foundry
# It is an alternative to bin/supply and bin/finalize

set -euo pipefail

BUILD_DIR=$1
CACHE_DIR=$2
BUILDPACK_PATH=$(dirname $(readlink -f ${BASH_SOURCE%/*}))
DEPS_DIR="$BUILD_DIR/.cloudfoundry"

mkdir -p $CACHE_DIR
mkdir -p "$DEPS_DIR/0"
mkdir -p "$BUILD_DIR/.profile.d"

echo "export DEPS_DIR=\$HOME/.cloudfoundry" > "$BUILD_DIR/.profile.d/0000_set-deps-dir.sh"

$BUILDPACK_PATH/bin/supply "$BUILD_DIR" "$CACHE_DIR" "$DEPS_DIR" 0
$BUILDPACK_PATH/bin/finalize "$BUILD_DIR" "$CACHE_DIR" "$DEPS_DIR" 0
echo "bin/compile is deprecated, but is provided so that CF will accept the zip file"
exit 1
12 changes: 0 additions & 12 deletions bin/detect

This file was deleted.

Empty file modified bin/detect.bat
100755 → 100644
Empty file.
19 changes: 0 additions & 19 deletions bin/finalize

This file was deleted.

3 changes: 3 additions & 0 deletions bin/finalize.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@ECHO OFF
SET ScriptDir=%~dp0
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%ScriptDir%finalize.ps1' %1 %2 %3 %4";
19 changes: 19 additions & 0 deletions bin/finalize.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=1)] [string]$BuildDir,
[Parameter(Mandatory=$True,Position=2)] [string]$CacheDir,
[Parameter(Mandatory=$True,Position=3)] [string]$DepsDir,
[Parameter(Mandatory=$True,Position=4)] [string]$DepsIdx
)

$ErrorActionPreference = "Stop"
$env:PATH += ";$DepsDir/$DepsIdx/bin"

Write-Output "-----> Build app"
Set-Location $BuildDir
go build -o myapp.exe .
if ($lastexitcode -ne 0) {
Write-Output "ERROR building app with go"
Write-Output "EXITCODE: $lastexitcode"
Exit 1
}
5 changes: 0 additions & 5 deletions bin/release

This file was deleted.

4 changes: 3 additions & 1 deletion bin/release.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
@echo off
type c:\tmp\go-buildpack-release-step.yml
echo ---
echo default_process_types:
echo web: .\myapp.exe
17 changes: 0 additions & 17 deletions bin/supply

This file was deleted.

3 changes: 3 additions & 0 deletions bin/supply.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@ECHO OFF
SET ScriptDir=%~dp0
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%ScriptDir%supply.ps1' %1 %2 %3 %4";
33 changes: 33 additions & 0 deletions bin/supply.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=1)] [string]$BuildDir,
[Parameter(Mandatory=$True,Position=2)] [string]$CacheDir,
[Parameter(Mandatory=$True,Position=3)] [string]$DepsDir,
[Parameter(Mandatory=$True,Position=4)] [string]$DepsIdx
)

$ErrorActionPreference = "Stop"

$Version = (Get-Content "$PSScriptRoot/../VERSION" -Raw).Replace("`n","").Replace("`r","")
Write-Output "-----> Go Buildpack (version $Version)"
# Write-Output " BuildDir: $BuildDir"
# Write-Output " CacheDir: $CacheDir"
# Write-Output " DepsDir: $DepsDir"
# Write-Output " DepsIdx: $DepsIdx"
# Write-Output ""


Write-Output "-----> Download go"
$ProgressPreference = 'SilentlyContinue'
(New-Object System.Net.WebClient).DownloadFile('https://dl.google.com/go/go1.11.4.windows-amd64.zip', "$DepsDir/$DepsIdx/go.zip")
$ExpectedSHA = 'eeb20e21702f2b9469d9381df5de85e2f731b64a1f54effe196d0f7d0227fe14'
$ActualSHA = (Get-FileHash "$DepsDir/$DepsIdx/go.zip" -Algorithm SHA256).Hash
If ($ExpectedSHA -ne $ActualSHA) {
Write-Output "go.zip checksum did not match. expected '$ExpectedSHA', found '$ActualSHA'"
Exit 1
}

Write-Output "-----> Extract go"
Expand-Archive -Path "$DepsDir/$DepsIdx/go.zip" -DestinationPath "$DepsDir/$DepsIdx" -Force
Move-Item -Path "$DepsDir/$DepsIdx/go/*" -Destination "$DepsDir/$DepsIdx"
Remove-Item -Path "$DepsDir/$DepsIdx/go"
45 changes: 0 additions & 45 deletions finalize.go

This file was deleted.

60 changes: 0 additions & 60 deletions finalize/main.go

This file was deleted.

3 changes: 0 additions & 3 deletions go.mod

This file was deleted.

53 changes: 0 additions & 53 deletions go.sum

This file was deleted.

28 changes: 0 additions & 28 deletions interfaces.go

This file was deleted.

Loading

0 comments on commit ec60ccd

Please sign in to comment.