### Set Up Go Runtime Environment (Windows) Source: https://context7.com/cloudfoundry/bosh-package-golang-release/llms.txt Source the `runtime.ps1` script in your BOSH job scripts for Windows to configure Go environment variables for runtime execution. ```powershell # job script that needs to run Go at runtime on Windows # Source the Go runtime environment . C:\var\vcap\packages\golang-1.26-windows\bosh\runtime.ps1 # Run a Go program directly go run C:\var\vcap\packages\mypackage\scripts\maintenance.go # Execute go commands go version ``` -------------------------------- ### Set Up Go Compilation Environment (Windows) Source: https://context7.com/cloudfoundry/bosh-package-golang-release/llms.txt Source the `compile.ps1` script in your BOSH packaging script for Windows to configure Go environment variables for compilation. ```powershell # packaging script for your BOSH package on Windows # Source the Go compilation environment . C:\var\vcap\packages\golang-1.26-windows\bosh\compile.ps1 # Environment variables now set: # GOROOT=C:\var\vcap\packages\golang-1.26-windows\go # GOPATH=$PWD # GOCACHE=C:\var\vcap\data\golang-1.26-windows\cache # GOTOOLCHAIN=local # PATH includes GOROOT\bin and GOPATH\bin # Build your Go application Set-Location "${env:BOSH_COMPILE_TARGET}\src\myapp" go build -o "${env:BOSH_INSTALL_TARGET}\bin\myapp.exe" .\cmd\myapp ``` -------------------------------- ### Set Up Go Runtime Environment (Linux/macOS) Source: https://context7.com/cloudfoundry/bosh-package-golang-release/llms.txt Source the `runtime.env` script in your BOSH job scripts to configure Go environment variables for runtime execution of Go programs. ```bash #!/bin/bash -eu # job script that needs to run Go at runtime # Source the Go runtime environment source /var/vcap/packages/golang-1.26-linux/bosh/runtime.env # Environment variables now set: # GOROOT=/var/vcap/packages/golang-1.26-linux # GOCACHE=/var/vcap/data/golang-1.26-linux/cache # GOPATH=$PWD # PATH includes GOROOT/bin and GOPATH/bin # Run a Go program directly go run /var/vcap/packages/mypackage/scripts/maintenance.go # Execute go commands go version go env GOROOT ``` -------------------------------- ### Set Up Go Compilation Environment (Linux/macOS) Source: https://context7.com/cloudfoundry/bosh-package-golang-release/llms.txt Source the `compile.env` script in your BOSH packaging script to configure Go environment variables like GOROOT, GOPATH, GOCACHE, and PATH for compilation. ```bash #!/bin/bash -eu # packaging script for your BOSH package # Source the Go compilation environment source /var/vcap/packages/golang-1.26-linux/bosh/compile.env # Environment variables now set: # GOROOT=/var/vcap/packages/golang-1.26-linux # GOPATH=$PWD # GOCACHE=/var/vcap/data/golang-1.26-linux/cache # GOTOOLCHAIN=local # PATH includes $GOROOT/bin and $GOPATH/bin # Build your Go application cd ${BOSH_COMPILE_TARGET}/src/myapp go build -o ${BOSH_INSTALL_TARGET}/bin/myapp ./cmd/myapp # Build with specific flags go build -ldflags="-s -w" -o ${BOSH_INSTALL_TARGET}/bin/myapp-slim ./cmd/myapp ``` -------------------------------- ### Run Golang Package Tests (Windows) Source: https://context7.com/cloudfoundry/bosh-package-golang-release/llms.txt Execute the test suite for Golang packages on Windows. Set the required environment variables for BOSH environment, stemcell path and version, OS, job name, and VM extensions before running the script. ```bash # For Windows testing export STEMCELL_PATH="/path/to/windows/stemcell.zip" export STEMCELL_VERSION="2019.43" export OS="windows2019" export JOB_NAME="test-windows" export VM_EXTENSIONS="[50GB_ephemeral_disk]" ./run.sh ``` -------------------------------- ### Run Golang Package Tests (Linux) Source: https://context7.com/cloudfoundry/bosh-package-golang-release/llms.txt Execute the test suite for Golang packages on Linux. Set the required environment variables for BOSH environment, stemcell path and version, OS, job name, and VM extensions before running the script. ```bash # Set required environment variables export BOSH_ENVIRONMENT=vbox export STEMCELL_PATH="/path/to/stemcell.tgz" export STEMCELL_VERSION="621.125" export OS="ubuntu-jammy" export JOB_NAME="test" export VM_EXTENSIONS="[]" # Run the test suite cd tests/ ./run.sh ``` -------------------------------- ### Configure runtime environment for Golang Source: https://github.com/cloudfoundry/bosh-package-golang-release/blob/main/README.md Source the runtime environment script in your job scripts to ensure the Go toolchain is available at runtime. ```bash #!/bin/bash -eu source /var/vcap/packages/golang-1.26-linux/bosh/runtime.env go run ... ``` ```powershell . C:\var\vcap\packages\golang-1.26-windows\bosh\runtime.ps1 go run ... ``` -------------------------------- ### Configure compilation environment for Golang Source: https://github.com/cloudfoundry/bosh-package-golang-release/blob/main/README.md Source the compile environment script in your packaging script to set up the Go toolchain. ```bash #!/bin/bash -eu source /var/vcap/packages/golang-1.26-linux/bosh/compile.env go build ... ``` ```powershell . C:\var\vcap\packages\golang-1.26-windows\bosh\compile.ps1 go build ... ``` -------------------------------- ### BOSH Job Template for Golang Testing (Windows) Source: https://context7.com/cloudfoundry/bosh-package-golang-release/llms.txt PowerShell script for a BOSH job template to test Golang compile-time and runtime compatibility on Windows. It executes a compiled test executable and then runs a Go program using the package's runtime environment. ```powershell try { Write-Host "Testing compile compatibility" & "C:\var\vcap\packages\golang-1.26-windows-test\bin\test.exe" Write-Host "Testing runtime compatibility" . C:\var\vcap\packages\golang-1.26-windows\bosh\runtime.ps1 go run C:\var\vcap\packages\golang-1.26-windows-test\test.go } catch { Write-Host "$_.Exception.Message" Exit 1 } Exit 0 ``` -------------------------------- ### BOSH Job Template for Golang Testing (Linux) Source: https://context7.com/cloudfoundry/bosh-package-golang-release/llms.txt Bash script for a BOSH job template to test Golang compile-time and runtime compatibility on Linux. It executes a compiled test binary and then runs a Go program using the package's runtime environment. ```bash #!/bin/bash set -eux echo "Testing compile compatibility" /var/vcap/packages/golang-1.26-linux-test/bin/test echo "Testing runtime compatibility" source /var/vcap/packages/golang-1.26-linux/bosh/runtime.env go run /var/vcap/packages/golang-1.26-linux-test/test.go ``` -------------------------------- ### Vendor Golang package into a BOSH release Source: https://github.com/cloudfoundry/bosh-package-golang-release/blob/main/README.md Use the BOSH CLI to clone the repository and vendor a specific Golang package into your local release workspace. ```bash $ git clone https://github.com/cloudfoundry/bosh-package-golang-release $ cd ~/workspace/your-release $ bosh vendor-package golang-1.26-linux ~/workspace/bosh-package-golang-release ``` -------------------------------- ### Vendor Golang Packages into BOSH Release Source: https://context7.com/cloudfoundry/bosh-package-golang-release/llms.txt Use the `bosh vendor-package` command to integrate Go toolchains into your BOSH release. Specify the desired Go version and platform, along with the path to the cloned golang release repository. ```bash # Clone the golang release repository git clone https://github.com/cloudfoundry/bosh-package-golang-release cd ~/workspace/your-release # Vendor the golang package for Linux (Go 1.26.x) bosh vendor-package golang-1.26-linux ~/workspace/bosh-package-golang-release # Vendor additional platform packages as needed bosh vendor-package golang-1.26-darwin ~/workspace/bosh-package-golang-release bosh vendor-package golang-1.26-windows ~/workspace/bosh-package-golang-release # Alternative: use the rolling 1.x version (always latest stable Go) bosh vendor-package golang-1-linux ~/workspace/bosh-package-golang-release ``` -------------------------------- ### Run tests Source: https://github.com/cloudfoundry/bosh-package-golang-release/blob/main/README.md Execute the test suite within the tests directory. ```bash cd tests/ && BOSH_ENVIRONMENT=vbox ./run.sh ``` -------------------------------- ### Configure bump-golang-package task Source: https://context7.com/cloudfoundry/bosh-package-golang-release/llms.txt Defines the task configuration for automatically vendoring updated Go packages into a BOSH release. ```yaml # Concourse pipeline task configuration - task: bump-golang-package file: golang-release/ci/tasks/shared/bump-golang-package.yml params: GIT_USER_NAME: "CI Bot" GIT_USER_EMAIL: "ci-bot@example.com" PACKAGES: '["golang-1.26-linux", "golang-1.26-darwin"]' PACKAGES_TO_REMOVE: '["golang-1.25-linux", "golang-1.25-darwin"]' PRIVATE_YML: | --- blobstore: provider: s3 options: access_key_id: ((aws_access_key)) secret_access_key: ((aws_secret_key)) RELEASE_DIR: my-release input_mapping: input_repo: my-release-repo ``` ```yaml # Full pipeline example resources: - name: golang-release type: git source: uri: https://github.com/cloudfoundry/bosh-package-golang-release branch: main - name: my-release-repo type: git source: uri: git@github.com:myorg/my-release.git private_key: ((git_private_key)) jobs: - name: bump-golang plan: - in_parallel: - get: golang-release trigger: true - get: my-release-repo - task: bump-golang-package file: golang-release/ci/tasks/shared/bump-golang-package.yml params: GIT_USER_NAME: "CI Bot" GIT_USER_EMAIL: "ci-bot@example.com" PACKAGES: '["golang-1.26-linux"]' PACKAGES_TO_REMOVE: '[]' PRIVATE_YML: ((private_yml)) RELEASE_DIR: . input_mapping: input_repo: my-release-repo - put: my-release-repo params: repository: output_repo ``` -------------------------------- ### Test Deployment Manifest Source: https://context7.com/cloudfoundry/bosh-package-golang-release/llms.txt A sample BOSH deployment manifest used to validate Golang packages. Configure releases, stemcells, and instance groups as needed for your test environment. ```yaml --- name: test releases: - name: golang version: create url: file://. stemcells: - alias: default os: ((os)) version: latest update: canaries: 2 max_in_flight: 1 canary_watch_time: 5000-60000 update_watch_time: 5000-60000 instance_groups: - name: golang-1.26-test azs: [z1] instances: 1 jobs: - name: golang-1.26-((job-name)) release: golang properties: {} vm_type: default vm_extensions: ((ephemeral-disk)) stemcell: default networks: - name: default ``` -------------------------------- ### Golang Package Spec File Structure (Windows) Source: https://context7.com/cloudfoundry/bosh-package-golang-release/llms.txt Defines the structure of a Golang package spec file for Windows, listing required blobs and source files. ```yaml --- name: golang-1.26-windows files: - compile.env.windows - runtime.env.windows - exiter.ps1 - go1.26*.windows-amd64.zip ``` -------------------------------- ### Configure check-for-updated-golang-package task Source: https://context7.com/cloudfoundry/bosh-package-golang-release/llms.txt Defines the task configuration for detecting updated Go packages and generating release notes. ```yaml # Concourse pipeline task configuration - task: check-for-updated-golang-package file: golang-release/ci/tasks/shared/check-for-updated-golang-package.yml params: PACKAGES: '["golang-1.26-linux", "golang-1.26-windows"]' input_mapping: input_repo: my-release-repo version: release-version ``` ```yaml # Pipeline job to check and create release jobs: - name: check-golang-updates plan: - in_parallel: - get: golang-release - get: my-release-repo trigger: true - get: release-version - task: check-for-updated-golang-package file: golang-release/ci/tasks/shared/check-for-updated-golang-package.yml params: PACKAGES: '["golang-1.26-linux"]' input_mapping: input_repo: my-release-repo version: release-version - task: create-release # Only runs if golang packages were updated file: my-release-repo/ci/tasks/create-release.yml ``` -------------------------------- ### Set Windows environment variables Source: https://github.com/cloudfoundry/bosh-package-golang-release/blob/main/README.md Define required environment variables for Windows stemcell configuration. ```bash export STEMCELL_PATH="/path/to/windows/stemcell.zip" export STEMCELL_VERSION="" export OS="windows2019" export JOB_NAME="test-windows" export VM_EXTENSIONS="[50GB_ephemeral_disk]" ``` -------------------------------- ### Configure bump-deps task Source: https://context7.com/cloudfoundry/bosh-package-golang-release/llms.txt Defines the task configuration for updating Go module dependencies and the Go version in go.mod. ```yaml # Concourse pipeline task configuration - task: bump-deps file: golang-release/ci/tasks/shared/bump-deps.yml params: GIT_USER_NAME: "CI Bot" GIT_USER_EMAIL: "ci-bot@example.com" GO_PACKAGE: golang-1.26-linux SOURCE_PATH: src/myapp GOOS_LIST: "linux,darwin,windows" DESIRED_GO_MAJOR_MINOR: "1.25" # Optional: defaults to previous minor version input_mapping: input_repo: my-release-repo ``` ```yaml # Full pipeline example for dependency bumping jobs: - name: bump-go-deps plan: - in_parallel: - get: golang-release - get: my-release-repo - get: weekly-timer trigger: true - task: bump-deps file: golang-release/ci/tasks/shared/bump-deps.yml params: GIT_USER_NAME: "Dependency Bot" GIT_USER_EMAIL: "deps-bot@example.com" GO_PACKAGE: golang-1.26-linux SOURCE_PATH: src/bosh-dns GOOS_LIST: "linux" input_mapping: input_repo: my-release-repo - put: my-release-repo params: repository: output_repo rebase: true ``` -------------------------------- ### Golang Package Spec File Structure (Linux) Source: https://context7.com/cloudfoundry/bosh-package-golang-release/llms.txt Defines the structure of a Golang package spec file for Linux, listing required blobs and source files. ```yaml --- name: golang-1.26-linux files: - compile.env.unix - runtime.env.unix - go1.26*.linux-amd64.tar.gz ``` -------------------------------- ### Add New Golang Version Line Script Source: https://context7.com/cloudfoundry/bosh-package-golang-release/llms.txt Use this bash script to automate the addition of a new Go version line. Ensure you edit the version variables at the top before running. After execution, commit and push changes, then update the Concourse pipeline. ```bash # Edit the version variables at the top of dev/add-line # old=1.24 # Version to remove # last=1.25 # Current version # new=1.26 # New version to add # Run the script from the repository root cd ~/workspace/bosh-package-golang-release ./dev/add-line # Output: # added 1.26, removed 1.24 # please commit changes and push # when pushed run ./ci/configure.sh to update pipeline # the pipeline will add the required blobs # Commit and push changes git add -A git commit -m "Add golang 1.26 version line, remove 1.24" git push # Update the Concourse pipeline ./ci/configure.sh ``` -------------------------------- ### Configure check-for-patched-cves task Source: https://context7.com/cloudfoundry/bosh-package-golang-release/llms.txt Defines the task configuration for scanning security vulnerabilities using Trivy. ```yaml # Concourse pipeline task configuration - task: check-for-patched-cves file: golang-release/ci/tasks/shared/check-for-patched-cves.yml params: GIT_PRIVATE_KEY: ((git_private_key)) SEVERITY: "CRITICAL,HIGH,MEDIUM" SOURCE_PATH: src/myapp input_mapping: input_repo: my-release-repo version: release-version ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.