Skip to content

Commit

Permalink
Merge pull request #184 from dbathgate/windows-support
Browse files Browse the repository at this point in the history
Added support for buildpack to work on a windows stack
  • Loading branch information
szh authored May 22, 2024
2 parents 9a0fe56 + d4693a0 commit 22730bb
Show file tree
Hide file tree
Showing 20 changed files with 699 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [2.4.0] - 2024-05-17

### Added
- Support for Windows TAS envrionments.
[cyberark/cloudfoundry-conjur-buildpack#184](https://github.com/cyberark/cloudfoundry-conjur-buildpack/pull/184)

### Changed
- Project Go version bumped to 1.22, and support for deprecated Go version 1.20 removed.
[cyberark/cloudfoundry-conjur-buildpack#183](https://github.com/cyberark/cloudfoundry-conjur-buildpack/pull/183)
Expand Down
2 changes: 2 additions & 0 deletions bin/supply.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@echo off
powershell.exe -ExecutionPolicy Unrestricted %~dp0\supply.ps1 %*
33 changes: 33 additions & 0 deletions bin/supply.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

$buildDir=$args[0]
$depsDir=$args[2]
$indexDir=$args[3]

# Validate that secret.yml exists
if (![System.IO.File]::Exists("$buildDir\secrets.yml"))
{
echo "Unable to find a secrets.yml...exiting"
exit 1
}

# Validate that VCAP_SERVICES contains 'cyberark-conjur'
$vcapJson = echo $env:VCAP_SERVICES | ConvertFrom-Json

if ("true" -ne $Env:CONJUR_BUILDPACK_BYPASS_SERVICE_CHECK )
{
if( !("cyberark-conjur" -in $vcapJson.PSobject.Properties.Name) )
{
echo "No credentials for cyberark-conjur service found in VCAP_SERVICES... exit"
exit 1
}
}

pushd $depsDir\$indexDir
mkdir profile.d | Out-Null
copy $PSScriptRoot\..\lib\0001_retrieve-secrets.bat .\profile.d\
popd

pushd $buildDir
mkdir .conjur | Out-Null
copy $PSScriptRoot\..\vendor\conjur-win-env.exe .\.conjur\
popd
5 changes: 5 additions & 0 deletions ci/test_e2e
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ pushd ../tests/integration/apps/java
./bin/build
popd

announce 'Building the Dotnet Windows test application...'
pushd ../tests/integration/apps/dotnet-windows
./build
popd

announce 'Running Cucumber tests...'
# Run tests against latest build of buildpack (including integration tests against remote foundation)
docker compose \
Expand Down
4 changes: 0 additions & 4 deletions conjur-env/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
FROM golang:1.22
MAINTAINER CyberArk Software, Inc.

ENV GOOS=linux \
GOARCH=amd64 \
CGO_ENABLED=0

WORKDIR /conjur-env

COPY go.mod go.sum /conjur-env/
Expand Down
1 change: 1 addition & 0 deletions conjur-env/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ rm -rf ../vendor/conjur-env

docker compose build
docker compose run --rm conjur-env-builder
docker compose run --rm conjur-win-env-builder
15 changes: 15 additions & 0 deletions conjur-env/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@ services:
conjur-env-builder:
build:
context: .
environment:
- GOOS=linux
- GOARCH=amd64
- CGO_ENABLED=0
volumes:
- .:/conjur-env
- ../vendor:/pkg
command: go build -o /pkg/conjur-env -a -ldflags '-extldflags "-static"' .
conjur-win-env-builder:
build:
context: .
environment:
- GOOS=windows
- GOARCH=amd64
- CGO_ENABLED=0
volumes:
- .:/conjur-env
- ../vendor:/pkg
command: go build -o /pkg/conjur-win-env.exe -a -ldflags '-extldflags "-static"' .
9 changes: 9 additions & 0 deletions lib/0001_retrieve-secrets.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@echo off

pushd %USERPROFILE%\app
for /f "tokens=1,2 delims=: " %%a in ('.conjur\conjur-win-env.exe') do (
for /f %%i in ('powershell -executionpolicy Unrestricted -Command "[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('%%b'))"') do (
set %%a=%%i
)
)
popd
4 changes: 4 additions & 0 deletions manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ include_files:
- VERSION
- bin/compile
- bin/supply
- bin/supply.bat
- bin/supply.ps1
- lib/0001_retrieve-secrets.sh
- lib/0001_retrieve-secrets.bat
- lib/install_go.sh
- vendor/conjur-env
- vendor/conjur-win-env.exe
- manifest.yml
language: conjur # used solely to name the .zip
Loading

0 comments on commit 22730bb

Please sign in to comment.