### Setup Environment Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/00_START_HERE.md Use this function to set up the application launch environment. ```go CalcEnv() ``` -------------------------------- ### Builder Configuration Example Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/INDEX.md Example of how to configure the builder using command-line flags. Specifies build directory, buildpack order, and output droplet path. ```bash ./builder -buildDir=/app -buildpackOrder=ruby_buildpack -outputDroplet=/out/drop.tgz ``` -------------------------------- ### Platform Options Parsing Examples Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/platform-options.md Demonstrates parsing valid, empty, and invalid JSON strings for platform options using the Get function. ```go // Scenario 1: Valid options with Credhub URI jsonOpts := `{"credhub-uri":"https://credhub.example.com:8844"}` opts, err := platformoptions.Get(jsonOpts) if err != nil { log.Fatal(err) } if opts != nil { fmt.Printf("Credhub URI: %s\n", opts.CredhubURI) // Output: Credhub URI: https://credhub.example.com:8844 } // Scenario 2: Empty options opts, err := platformoptions.Get("") if err != nil { log.Fatal(err) } if opts == nil { fmt.Println("No platform options provided") } // Scenario 3: Invalid JSON opts, err := platformoptions.Get("{invalid json}") if err != nil { fmt.Printf("Parse error: %v\n", err) // err is the JSON unmarshaling error } ``` -------------------------------- ### Builder Integration Example Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/platform-options.md Shows how to get and use platform options in the builder to configure Credhub integration. ```go // In builder/main.go if platformOptions, err := platformoptions.Get(os.Getenv("VCAP_PLATFORM_OPTIONS")); err != nil { fmt.Fprintf(os.Stderr, "Invalid platform options: %v", err) os.Exit(3) } else if platformOptions != nil && platformOptions.CredhubURI != "" { attempts := config.CredhubConnectAttempts() delay := config.CredhubRetryDelay() err = credhub.New(&osshim.OsShim{}, attempts, delay).InterdhubURI() if err != nil { fmt.Fprintf(os.Stderr, "Unable to interpolate credhub refs: %v", err) os.Exit(4) } } ``` -------------------------------- ### Complete Builder Example with Environment Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/configuration.md This example demonstrates the full builder command with various flags and the necessary environment variables for Credhub and VCAP services. ```bash ./builder \ -buildDir=/var/vcap/app \ -buildpacksDir=/var/vcap/buildpacks \ -buildpacksDownloadDir=/var/vcap/buildpackdownloads \ -buildArtifactsCacheDir=/var/vcap/cache \ -outputDroplet=/var/vcap/result/droplet.tgz \ -outputMetadata=/var/vcap/result/result.json \ -outputBuildArtifactsCache=/var/vcap/result/cache.tgz \ -buildpackOrder=ruby_buildpack,nodejs_buildpack \ -skipDetect=false \ -skipCertVerify=false \ -credhubConnectAttempts=3 \ -credhubRetryDelay=1s ``` ```bash export VCAP_PLATFORM_OPTIONS='{"credhub-uri":"https://credhub.example.com:8844"}' export VCAP_SERVICES='{"postgresql":[{"credentials":{"uri":"postgresql://..."}}]}' export CF_INSTANCE_CERT=/var/vcap/instance_certs/cert export CF_INSTANCE_KEY=/var/vcap/instance_certs/key export CF_SYSTEM_CERT_PATH=/var/vcap/certs ``` -------------------------------- ### Launcher Integration Example Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/platform-options.md Illustrates how to obtain and utilize platform options in the launcher for Credhub service reference interpolation. ```go // In env/env.go if platformOptions, err := platformoptions.Get(os.Getenv("VCAP_PLATFORM_OPTIONS")); err != nil { return fmt.Errorf("Invalid platform options: %v", err) } else if platformOptions != nil && platformOptions.CredhubURI != "" { err := credhub.New(&osshim.OsShim{}, attempts, delay).InterpolateServiceRefs( platformOptions.CredhubURI, ) if err != nil { return fmt.Errorf("Unable to interpolate credhub refs: %v", err) } } ``` -------------------------------- ### Setup Build Environment Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/buildpack-runner.md Initializes the filesystem structure required for the build process. This includes creating necessary directories, downloading remote buildpacks, and cleaning the cache directory. ```APIDOC ## Setup Build Environment ### Description Initializes the filesystem structure needed for the build. Creates all necessary directories, downloads remote buildpacks, and cleans the cache directory. ### Signature ```go func (runner *Runner) Setup() error ``` ### Returns - **error** - Error if directory creation, download, or cache cleanup fails ``` -------------------------------- ### Launcher Workflow Entry Points Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/README.md Demonstrates the entry points for the launcher workflow, focusing on environment calculation and process execution. This involves calculating the environment and then executing the start command. ```Go package main import ( "code.cloudfoundry.org/buildpackapplifecycle/env" "syscall" ) func main() { // ... parse arguments, load staging info ... calculatedEnv := env.CalcEnv(stagingInfo, credhubFlags) // ... set up environment variables ... execErr := syscall.Exec(appPath, args, os.Environ()) if execErr != nil { // handle error } } ``` -------------------------------- ### Get Output Metadata Path Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/lifecycle-builder-config.md Returns the absolute path where build metadata JSON will be written. ```go config.OutputMetadata() ``` -------------------------------- ### Launcher Command-Line Arguments Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/configuration.md Use this command to launch an application. It requires the application directory and start command, with optional Credhub flags. ```bash launcher [credhub-flags...] ``` ```bash /tmp/lifecycle/launcher /home/vcap/app "bundle exec rails server" \ -credhubConnectAttempts=3 \ -credhubRetryDelay=1s ``` -------------------------------- ### Write Start Commands Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/buildpack-runner.md Writes result JSON and staging info YAML files. Use this to generate output files containing process definitions and buildpack metadata after a build. ```go resultPath, stagingInfoPath, err := runner.WriteStartCommands( "/tmp/buildpacks/ruby_buildpack", "ruby_buildpack", "Ruby 2.7.2", launchData, ) ``` -------------------------------- ### Get Application Build Directory Path Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/lifecycle-builder-config.md Returns the absolute path to the directory where application bits are staged for building. ```go func (s LifecycleBuilderConfig) BuildDir() string { return s.workingDir } ``` -------------------------------- ### Get Function Signature Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/platform-options.md Defines the signature for the Get function, which parses VCAP_PLATFORM_OPTIONS. ```go func Get(jsonPlatformOptions string) (*PlatformOptions, error) ``` -------------------------------- ### Execute Full Buildpack Lifecycle Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/buildpack-runner.md Runs the complete build pipeline, including setup, detection, supply, compilation, release, and packaging. Returns the path to the staging info YAML file upon success or an error if any phase fails. ```go runner := buildpackrunner.New(&config) deferrunner.CleanUp() stagingInfoPath, err := runner.Run() if err != nil { fmt.Fprintf(os.Stderr, "Build failed: %v", err) os.Exit(buildpackapplifecycle.ExitCodeFromError(err)) } fmt.Printf("Build succeeded. Staging info at: %s\n", stagingInfoPath) ``` -------------------------------- ### Set Up Application Environment Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/README.md Parses CredHub flags and calculates the environment for application execution. This is typically used at the start of the application lifecycle. ```go credhubFlags := credhub_flags.NewCredhubFlags("launcher") if err := credhubFlags.Parse(os.Args[3:]); err != nil { log.Fatal(err) } err := env.CalcEnv( &osshim.OsShim{}, "/home/vcap/app", credhubFlags.ConnectAttempts(), credhubFlags.RetryDelay(), ) if err != nil { log.Fatal(err) } // Environment is now set up for application execution ``` -------------------------------- ### CredHub Integration Example in Builder and Launcher Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/credhub.md Demonstrates typical usage of CredHub flags and client initialization within both the builder and launcher components of a Cloud Foundry application lifecycle. ```go // In builder if platformOptions, err := platformoptions.Get(os.Getenv("VCAP_PLATFORM_OPTIONS")); err != nil { fmt.Fprintf(os.Stderr, "Invalid platform options: %v", err) os.Exit(3) } else if platformOptions != nil && platformOptions.CredhubURI != "" { attempts := config.CredhubConnectAttempts() delay := config.CredhubRetryDelay() err = credhub.New(&osshim.OsShim{}, attempts, delay).InterpolateServiceRefs(platformOptions.CredhubURI) if err != nil { fmt.Fprintf(os.Stderr, "Unable to interpolate credhub refs: %v", err) os.Exit(4) } } // In launcher credhubFlags := credhub_flags.NewCredhubFlags("launcher") if err := credhubFlags.Parse(os.Args[3:]); err != nil { fmt.Fprintf(os.Stderr, "Could not parse credhub flags: %s", err) os.Exit(1) } attempts := credhubFlags.ConnectAttempts() delay := credhubFlags.RetryDelay() if err := env.CalcEnv(&osshim.OsShim{}, dir, attempts, delay); err != nil { fmt.Fprint(os.Stderr, err.Error()) os.Exit(3) } ``` -------------------------------- ### VCAP_APPLICATION JSON Mutation Example Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/environment.md Illustrates the transformation of the VCAP_APPLICATION JSON object, showing how runtime information like host, instance_id, port, and instance_index is added. ```json { "name": "my-app", "version": "1.0.0", "limits": {"mem": 512, "disk": 1024}, "uris": ["my-app.example.com"] } ``` ```json { "name": "my-app", "version": "1.0.0", "limits": {"mem": 512, "disk": 1024}, "uris": ["my-app.example.com"], "host": "0.0.0.0", "instance_id": "abcd1234-5678-90ef-ghij-klmno1234567", "port": 8080, "instance_index": 0 } ``` -------------------------------- ### Get Buildpack Order Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/lifecycle-builder-config.md Retrieves the ordered list of buildpacks to attempt during the build process, as configured by the buildpackOrder flag. ```go order := config.BuildpackOrder() // Might return: ["ruby_buildpack", "nodejs_buildpack"] ``` -------------------------------- ### GoLikeLightning Build Phases Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/buildpack-runner.md Executes the core build phases: detection, supply, finalize/compile, release, and start command resolution. It writes result JSON even on failure to capture buildpack metadata. ```APIDOC ## GoLikeLightning Build Phases ### Description Executes the main build phases: detection (if needed), supply, finalize/compile, release, and start command resolution. ### Signature ```go func (runner *Runner) GoLikeLightning() (string, string, error) ``` ### Returns - **string** - Path to result JSON - **string** - Path to staging info YAML - **error** - Error if build fails ### Note This method writes result JSON even on failure to capture buildpack metadata. ``` -------------------------------- ### Run Build Pipeline Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/buildpack-runner.md Executes the complete build pipeline, including setup, detection, supply, finalize/compile, release, and packaging. Returns the path to the staging info YAML file upon success. ```APIDOC ## Run Build Pipeline ### Description Executes the complete build pipeline: setup, detection/selection, supply, finalize/compile, release, and packaging. ### Signature ```go func (runner *Runner) Run() (string, error) ``` ### Returns - **string** - Path to the staging info YAML file - **error** - Error if any phase fails ### Example ```go runner := buildpackrunner.New(&config) defers runner.CleanUp() stagingInfoPath, err := runner.Run() if err != nil { fmt.Fprintf(os.Stderr, "Build failed: %v", err) os.Exit(buildpackapplifecycle.ExitCodeFromError(err)) } fmt.Printf("Build succeeded. Staging info at: %s\n", stagingInfoPath) ``` ``` -------------------------------- ### Get Output Droplet Path Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/lifecycle-builder-config.md Returns the absolute path where the final compressed droplet will be written. ```go config.OutputDroplet() ``` -------------------------------- ### Get Buildpack Path (MD5 Legacy) Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/lifecycle-builder-config.md Calculates the legacy path for a buildpack using MD5 hashing. This is primarily for compatibility with older cached buildpacks. ```go func (s LifecycleBuilderConfig) LegacyBuildpackPath(buildpackName string) string { return s.buildpackPath(buildpackName, md5.New()) } ``` -------------------------------- ### Get Configured Flags as Arguments Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/lifecycle-builder-config.md Returns all configured flags as a slice of command-line argument strings. This can be used to inspect or pass flags to external processes. ```go args := config.Args() // Might return: ["-buildDir=/tmp/app", "-outputDroplet=/tmp/droplet", ...] ``` -------------------------------- ### VCAP_PLATFORM_OPTIONS Environment Variable Example Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/platform-options.md Shows the bash command to export the VCAP_PLATFORM_OPTIONS environment variable with a JSON-encoded Credhub URI. ```bash export VCAP_PLATFORM_OPTIONS='{"credhub-uri":"https://credhub.internal:8844"}' ``` -------------------------------- ### Get Buildpacks Download Directory Path Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/lifecycle-builder-config.md Returns the absolute path to the directory where downloaded remote buildpacks are stored. ```go config.BuildpacksDownloadDir() ``` -------------------------------- ### Get Output Build Artifacts Cache Path Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/lifecycle-builder-config.md Returns the absolute path where the compressed build artifacts cache will be written. ```go config.OutputBuildArtifactsCache() ``` -------------------------------- ### ExitCodeFromError Function Example Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/errors.md This Go code demonstrates how to use the `ExitCodeFromError` function to map an error returned from the buildpack runner to its corresponding exit code, and then exit the process with that code. ```go config := buildpackapplifecycle.NewLifecycleBuilderConfig([]string{}, false, false) config.Parse(os.Args[1:]) runner := buildpackrunner.New(&config) deferrunner.CleanUp() _, err := runner.Run() if err != nil { exitCode := buildpackapplifecycle.ExitCodeFromError(err) fmt.Fprintf(os.Stderr, "Build failed: %v\n", err) os.Exit(exitCode) } ``` -------------------------------- ### Get Entrypoint Prefix from DeaStagingInfo Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/launch-data.md Retrieve the entrypoint prefix from the `BuildpackConfig` within a `DeaStagingInfo` object. Returns an empty string if no configuration is set. This is useful for legacy DEA compatibility. ```go info := buildpackrunner.DeaStagingInfo{ DetectedBuildpack: "ruby_buildpack", StartCommand: "bundle exec rails server", Config: &buildpackapplifecycle.BuildpackConfig{ EntrypointPrefix: "/bin/sh -c", }, } prefix := info.GetEntrypointPrefix() // Returns: "/bin/sh -c" ``` -------------------------------- ### Get Buildpack Path (XXHash) Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/lifecycle-builder-config.md Calculates the absolute path for a buildpack, using XXHash for consistent naming. Handles both local and remote buildpack references. ```go // For local buildpack path1 := config.BuildpackPath("ruby_buildpack") // Returns: /tmp/buildpacks/3f8d2a5c4b1e9f76 // For remote buildpack (URL) path2 := config.BuildpackPath("https://github.com/cloudfoundry/ruby-buildpack/releases/download/v1.8.0/ruby-buildpack-v1.8.0.zip") // Returns: /tmp/buildpackdownloads/a1b2c3d4e5f6g7h8 ``` -------------------------------- ### Get Supply Buildpacks Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/lifecycle-builder-config.md Retrieves all buildpacks except the last one, which are used to run their supply scripts for dependency provision. Returns an empty list if skipDetect is false or only one buildpack is configured. ```go // If buildpackOrder is ["ruby_buildpack", "nodejs_buildpack"] supply := config.SupplyBuildpacks() // Returns: ["ruby_buildpack"] ``` -------------------------------- ### Get Platform Options Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/platform-options.md Parses the VCAP_PLATFORM_OPTIONS JSON string and returns a PlatformOptions struct. Handles valid JSON, empty input, and invalid JSON scenarios. ```APIDOC ## Get Platform Options ### Description Parses the VCAP_PLATFORM_OPTIONS JSON string and returns a PlatformOptions struct. This function is used to retrieve and interpret platform-specific configuration settings. ### Method Go Function Call ### Signature ```go func Get(jsonPlatformOptions string) (*PlatformOptions, error) ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **jsonPlatformOptions** (string) - Required - JSON-encoded platform options string (typically from VCAP_PLATFORM_OPTIONS environment variable) ### Returns - **`*PlatformOptions`** — Parsed options, nil if input is empty. - **`error`** — JSON parsing error if input is invalid. ### Behavior - If input is empty string: Returns (nil, nil) - If input is valid JSON: Parses and returns (*PlatformOptions, nil) - If input is invalid JSON: Returns (nil, error) ### Example ```go // Scenario 1: Valid options with Credhub URI jsonOpts := `{"credhub-uri":"https://credhub.example.com:8844"}` opts, err := platformoptions.Get(jsonOpts) if err != nil { log.Fatal(err) } if opts != nil { fmt.Printf("Credhub URI: %s\n", opts.CredhubURI) // Output: Credhub URI: https://credhub.example.com:8844 } // Scenario 2: Empty options opts, err := platformoptions.Get("") if err != nil { log.Fatal(err) } if opts == nil { fmt.Println("No platform options provided") } // Scenario 3: Invalid JSON opts, err := platformoptions.Get("{invalid json}") if err != nil { fmt.Printf("Parse error: %v\n", err) // err is the JSON unmarshaling error } ``` ``` -------------------------------- ### Run Buildpack Lifecycle Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/README.md This Go code demonstrates how to initialize and run the buildpack lifecycle builder. It includes configuration parsing, validation, and error handling using exit codes. Ensure necessary imports are present. ```go config := buildpackapplifecycle.NewLifecycleBuilderConfig( []string{"ruby_buildpack"}, false, // perform detection false, // verify SSL certs ) if err := config.Parse(os.Args[1:]); err != nil { log.Fatal(err) } if err := config.Validate(); err != nil { log.Fatal(err) } runner := buildpackrunner.New(&config) deffer runner.CleanUp() stagingInfo, err := runner.Run() if err != nil { exitCode := buildpackapplifecycle.ExitCodeFromError(err) os.Exit(exitCode) } fmt.Printf("Build complete. Staging info at: %s\n", stagingInfo) ``` -------------------------------- ### Get Contents Directory Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/buildpack-runner.md Returns the absolute path to the temporary contents directory that holds the droplet structure. ```APIDOC ## Get Contents Directory ### Description Returns the path to the temporary contents directory containing the droplet structure. ### Signature ```go func (runner *Runner) GetContentsDir() string ``` ### Returns - **string** - Absolute path to contents directory ``` -------------------------------- ### Get Dependencies Directory Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/buildpack-runner.md Returns the absolute path to the dependencies directory where buildpacks place their supplied dependencies. ```APIDOC ## Get Dependencies Directory ### Description Returns the path to the dependencies directory where buildpacks place their supplied dependencies. ### Signature ```go func (runner *Runner) GetDepsDir() string ``` ### Returns - **string** - Absolute path to deps directory ``` -------------------------------- ### Get Credhub Retry Delay from Flags Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/EXPORTS.md Retrieves the retry delay duration from a CredhubFlags struct. Returns a time.Duration. ```go func (chf CredhubFlags) RetryDelay() time.Duration { // ... implementation details ... } ``` -------------------------------- ### Get Credhub Connect Attempts from Flags Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/EXPORTS.md Retrieves the number of connection attempts from a CredhubFlags struct. Returns an integer. ```go func (chf CredhubFlags) ConnectAttempts() int { // ... implementation details ... } ``` -------------------------------- ### WriteStartCommands Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/buildpack-runner.md Writes the result JSON and staging info YAML files with process definitions and buildpack metadata. It requires the buildpack directory, name, detect output, and complete launch data. ```APIDOC ## WriteStartCommands ### Description Writes the result JSON and staging info YAML files with process definitions and buildpack metadata. ### Method *Implicitly a method call on a Runner object* ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * None ### Parameters - **detectedBuildpackDir** (string) - Required - Path to the final buildpack - **detectedBuildpack** (string) - Required - Name of the final buildpack - **detectOutput** (string) - Required - Output from buildpack detect phase (if not skipping detect) - **procMap** (resources.LaunchData) - Required - Complete launch data with all processes ### Response #### Success Response - **string** - Path to result JSON - **string** - Path to staging info YAML - **error** - Error if write fails ### Request Example ```go resultPath, stagingInfoPath, err := runner.WriteStartCommands( "/tmp/buildpacks/ruby_buildpack", "ruby_buildpack", "Ruby 2.7.2", launchData, ) ``` ``` -------------------------------- ### Create New ZipDownloader Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/buildpack-support.md Initializes a new ZipDownloader. Use `skipSSLVerification` set to true to bypass SSL certificate verification, which is not recommended for production environments. ```go // Verify SSL certificates (recommended for production) downloader := buildpackrunner.NewZipDownloader(false) // Skip SSL verification (for testing with self-signed certs) unsafeDownloader := buildpackrunner.NewZipDownloader(true) ``` -------------------------------- ### Buildpack Directory Structure Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/buildpack-support.md Illustrates the expected layout of a buildpack directory, including required and optional scripts within the '/bin' directory. ```text buildpack/ ├── bin/ │ ├── detect (required) │ ├── supply (optional, for multi-buildpack support) │ ├── finalize (optional, replaces compile) │ └── compile (required if no finalize) │ └── release (required) └── [other files] ``` -------------------------------- ### Get Buildpacks Directory Path Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/lifecycle-builder-config.md Returns the absolute path to the local buildpacks directory where local buildpacks are stored. ```go config.BuildpacksDir() ``` -------------------------------- ### Initialize BuildpackRunner Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/buildpack-runner.md Creates a new BuildpackRunner instance with the provided configuration. It's recommended to defer the CleanUp method to ensure temporary directories are removed after the build. ```go config := buildpackapplifecycle.NewLifecycleBuilderConfig([]string{}, false, false) config.Parse(os.Args[1:]) runner := buildpackrunner.New(&config) deferrunner.CleanUp() resultPath, err := runner.Run() if err != nil { log.Fatal(err) } ``` -------------------------------- ### Process Buildpack Launch Data Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/README.md This Go code shows how to process launch data from buildpacks. It merges data from supply buildpacks and the final buildpack, then converts it into a staging result. Error handling is included. ```go runner := buildpackrunner.New(&config) // Merge launch.yml from supply buildpacks launchData, err := runner.ProcessYML(config.SupplyBuildpacks()) if err != nil { log.Fatal(err) } // Process final buildpack and Procfile launchData, err = runner.ProcessFinalBuildpack( detectedBuildpack, detectedBuildpackDir, launchData, ) if err != nil { log.Fatal(err) } // Convert to staging result result := resources.ConvertToResult(launchData) ``` -------------------------------- ### Get Builder Executable Path Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/lifecycle-builder-config.md Retrieves the absolute path to the builder executable. This is useful for invoking the builder directly. ```go func (s LifecycleBuilderConfig) Path() string { return s.ExecutablePath } ``` -------------------------------- ### Get Credhub Connect Attempts Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/credhub.md Retrieves the configured number of Credhub connection attempts from the flags. The default value is 3. ```go func (chf CredhubFlags) ConnectAttempts() int ``` -------------------------------- ### Configure Buildpack Order Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/configuration.md Specifies the ordered list of buildpacks to try, separated by commas. This flag is required but auto-populated. ```bash ./builder -buildpackOrder=ruby_buildpack ``` ```bash ./builder -buildpackOrder=ruby_buildpack,nodejs_buildpack,java_buildpack ``` ```bash ./builder -buildpackOrder=https://github.com/cloudfoundry/ruby-buildpack/releases/download/v1.8.0/ruby-buildpack-v1.8.0.zip ``` ```bash ./builder -buildpackOrder=ruby_buildpack,https://github.com/org/custom-buildpack.zip#v2.0.0 ``` -------------------------------- ### Configure Builder with Command-Line Flags Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/README.md Use these flags to configure the builder's behavior, including input/output paths, buildpack order, and detection settings. Ensure paths are correctly specified. ```bash ./builder \ -buildDir=/path/to/app \ -buildpackOrder=buildpack1,buildpack2 \ -outputDroplet=/path/to/droplet.tgz \ -outputMetadata=/path/to/result.json \ -skipDetect=false \ -credhubConnectAttempts=3 \ -credhubRetryDelay=1s ``` -------------------------------- ### Get Build Artifacts Cache Directory Path Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/lifecycle-builder-config.md Returns the absolute path to the directory where previous build artifacts cache is extracted. ```go config.BuildArtifactsCacheDir() ``` -------------------------------- ### Builder Workflow Entry Points Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/README.md Illustrates the entry points for the builder workflow in the buildpackapplifecycle package. This involves creating a new runner instance and executing the build process. ```Go package main import ( "code.cloudfoundry.org/buildpackapplifecycle/buildpackrunner" ) func main() { // ... setup config ... runner := buildpackrunner.New(config) runner.Run() } ``` -------------------------------- ### Get Credhub Retry Delay Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/credhub.md Retrieves the configured delay duration between Credhub connection retry attempts. The default value is 1 second. ```go func (chf CredhubFlags) RetryDelay() time.Duration ``` -------------------------------- ### Process Struct Definition (resources package) Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/types.md An extended process definition from launch.yml, including platform-specific metadata like sidecars and memory limits. ```go type Process struct { Type string `yaml:"type" json:"type" Command string `yaml:"command" json:"command" Platforms struct { Cloudfoundry struct { SidecarFor []string `yaml:"sidecar_for" json:"sidecar_for" } `yaml:"cloudfoundry" json:"cloudfoundry" } `yaml:"platforms" json:"platforms" Limits struct { Memory int `yaml:"memory" json:"memory" } `yaml:"limits" json:"limits" } ``` -------------------------------- ### Get Zero-Padded Deps Index Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/lifecycle-builder-config.md Returns a zero-padded string index for use in the deps directory structure. The padding width is calculated to accommodate all buildpacks. ```go // If there are 10 buildpacks total idx := config.DepsIndex(0) // Returns: "00" idx := config.DepsIndex(9) // Returns: "09" ``` -------------------------------- ### ProcessYML Configuration Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/buildpack-runner.md Reads and merges launch.yml files from multiple buildpacks based on the provided list of selected buildpacks. ```APIDOC ## ProcessYML Configuration ### Description Reads and merges launch.yml files from multiple buildpacks. ### Signature ```go func (runner *Runner) ProcessYML(selectedBuildpacks []string) (resources.LaunchData, error) ``` ### Parameters #### Path Parameters - **selectedBuildpacks** ([]string) - Required - Buildpack names to process ### Returns - **resources.LaunchData** - Merged launch data - **error** - Error if parsing fails ``` -------------------------------- ### Execute Build Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/00_START_HERE.md Use this function to execute the build process with a runner. ```go Run() ``` -------------------------------- ### Set Build Directory Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/configuration.md Specifies the directory containing the raw application source code to be built. This is a required flag. ```bash ./builder -buildDir=/path/to/app -buildpackOrder=ruby_buildpack ``` -------------------------------- ### MergeLaunchYML Data Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/buildpack-runner.md Reads and merges a single buildpack's launch.yml file with existing process data, identified by its buildpack index. ```APIDOC ## MergeLaunchYML Data ### Description Reads and merges a single buildpack's launch.yml with existing process data. ### Signature ```go func (runner *Runner) MergeLaunchYML(buildpackIndex int, procMap resources.LaunchData) (resources.LaunchData, error) ``` ### Parameters #### Path Parameters - **buildpackIndex** (int) - Required - Zero-based index of the buildpack - **procMap** (resources.LaunchData) - Required - Existing launch data to merge into ### Returns - **resources.LaunchData** - Updated launch data - **error** - Error if read/parse fails ``` -------------------------------- ### Interpolate Credhub References Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/README.md Illustrates the usage of the InterpolateServiceRefs function from the credhub package to interpolate Credhub references within a configuration. This is typically done during the launcher environment setup. ```Go import "code.cloudfoundry.org/buildpackapplifecycle/credhub" // ... err := credhub.InterpolateServiceRefs(config) if err != nil { // handle error } ``` -------------------------------- ### Create New Databaseuri Instance Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/database-uri.md Instantiates a new Databaseuri object. This object is stateless and used to call its methods. ```go dbUri := databaseuri.New() ``` -------------------------------- ### Path Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/lifecycle-builder-config.md Returns the absolute path to the builder executable. ```APIDOC ## Path ### Description Returns the absolute path to the builder executable. ### Signature ```go func (s LifecycleBuilderConfig) Path() string ``` ### Returns - **string** - Path to the lifecycle builder executable ``` -------------------------------- ### Calculate Environment Variables Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/EXPORTS.md Calculates environment variables for the application. Requires an OS interface, directory, number of attempts, and delay duration. ```go func CalcEnv(os osshim.Os, dir string, attempts int, delay time.Duration) error { // ... implementation details ... } ``` -------------------------------- ### Create New StagingResult Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/models.md Initializes a new StagingResult with specified process types and lifecycle metadata. Use this when creating a staging result from scratch. ```go procTypes := buildpackapplifecycle.ProcessTypes{ "web": "bundle exec rails server -p $PORT", } metadata := buildpackapplifecycle.LifecycleMetadata{ DetectedBuildpack: "ruby_buildpack", BuildpackKey: "ruby", } result := buildpackapplifecycle.NewStagingResult(procTypes, metadata) ``` -------------------------------- ### Handle Empty or Missing Credentials Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/database-uri.md This snippet demonstrates how the Credentials method returns an empty list when VCAP_SERVICES is empty or credentials are not found. No error is returned in this scenario. ```Go creds, err := dbUri.Credentials([]byte("{}")) if err != nil { log.Fatal(err) } // creds == []string{} (empty slice) ``` -------------------------------- ### BuildpackConfig Struct Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/models.md Defines configuration options for a buildpack, including an optional entrypoint prefix. ```go type BuildpackConfig struct { EntrypointPrefix string `json:"entrypoint_prefix,omitempty" yaml:"entrypoint_prefix,omitempty"` } ``` -------------------------------- ### Prepare Application Environment Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/environment.md Use CalcEnv to set up standard Cloud Foundry environment variables like HOME, TMPDIR, DEPS_DIR, VCAP_APPLICATION, and DATABASE_URL. It also handles Credhub reference interpolation and cleans up VCAP_PLATFORM_OPTIONS. Requires an OS interface, application directory, and optional Credhub connection parameters. ```go dir := "/var/vcap/app" credhubFlags := credhub_flags.NewCredhubFlags("launcher") if err := credhubFlags.Parse(os.Args[3:]); err != nil { fmt.Fprintf(os.Stderr, "Could not parse credhub flags: %s", err) os.Exit(1) } attempts := credhubFlags.ConnectAttempts() delay := credhubFlags.RetryDelay() if err := env.CalcEnv(&osshim.OsShim{}, dir, attempts, delay); err != nil { fmt.Fprint(os.Stderr, err.Error()) os.Exit(3) } // Environment is now ready for application startup // Available environment variables: // HOME=/var/vcap/app // TMPDIR=/var/vcap/tmp // DEPS_DIR=/var/vcap/deps // VCAP_APPLICATION={"host":"0.0.0.0","instance_id":"...","port":8080,...} // VCAP_SERVICES={interpolated credentials} // DATABASE_URL=postgresql://user:pass@host/db (if applicable) ``` -------------------------------- ### Configure Multi-Buildpack Order Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/README.md Specify the order of buildpacks for multi-buildpack support. The last buildpack in the list performs the finalize/compile and release steps. ```bash -buildpackOrder=buildpack1,buildpack2,buildpack3 ``` -------------------------------- ### Args Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/lifecycle-builder-config.md Returns all configured flags as command-line arguments in the format "-flag=value". ```APIDOC ## Args ### Description Returns all configured flags as command-line arguments. ### Signature ```go func (s LifecycleBuilderConfig) Args() []string ``` ### Returns - **[]string** - Slice of argument strings in "-flag=value" format ### Example ```go args := config.Args() // Might return: ["-buildDir=/tmp/app", "-outputDroplet=/tmp/droplet", ...] ``` ``` -------------------------------- ### Set DATABASE_URL Environment Variable Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/database-uri.md Integrates database URI resolution into an application's startup logic. It checks for VCAP_SERVICES, extracts credentials, normalizes the URI, and sets the DATABASE_URL environment variable if a supported database is found. ```go // Extract and set DATABASE_URL if available if os.Getenv("VCAP_SERVICES") != "" { dbUri := databaseuri.New() if creds, err := dbUri.Credentials([]byte(os.Getenv("VCAP_SERVICES"))); err == nil { databaseUrl := dbUri.Uri(creds) if databaseUrl != "" { err = os.Setenv("DATABASE_URL", databaseUrl) if err != nil { fmt.Fprintf(os.Stderr, "Unable to set DATABASE_URL: %v", err) os.Exit(5) } } } } ``` -------------------------------- ### Process Struct Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/models.md Represents a single process with its type and command. ```go type Process struct { Type string `yaml:"type" json:"type"` Command string `yaml:"command" json:"command"` } ``` -------------------------------- ### NewZipDownloader Constructor Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/buildpack-support.md Creates a new ZipDownloader instance, which is used for downloading and extracting ZIP-based buildpacks. SSL verification can be optionally skipped. ```APIDOC ## NewZipDownloader Constructor ### Description Creates a new ZipDownloader with optional SSL verification bypass. ### Signature ```go func NewZipDownloader(skipSSLVerification bool) *ZipDownloader ``` ### Parameters #### Path Parameters - **skipSSLVerification** (bool) - Required - If true, skips SSL certificate verification ### Returns - ***ZipDownloader** - Initialized downloader ### Example: ```go // Verify SSL certificates (recommended for production) downloader := buildpackrunner.NewZipDownloader(false) // Skip SSL verification (for testing with self-signed certs) unsafeDownloader := buildpackrunner.NewZipDownloader(true) ``` ``` -------------------------------- ### Process Type Definition Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/launch-data.md Defines a single process with its type, command, platform-specific configurations, and resource limits. ```go type Process struct { Type string `yaml:"type" json:"type"` Command string `yaml:"command" json:"command"` Platforms struct { Cloudfoundry struct { SidecarFor []string `yaml:"sidecar_for" json:"sidecar_for"` } `yaml:"cloudfoundry" json:"cloudfoundry"` } `yaml:"platforms" json:"platforms"` Limits struct { Memory int `yaml:"memory" json:"memory"` } `yaml:"limits" json:"limits"` } ``` -------------------------------- ### Download and Extract ZIP Buildpack Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/buildpack-support.md Downloads a ZIP file from a given URL and extracts its contents to a specified destination directory. It handles temporary file creation, download progress, and extraction, returning the downloaded file size and any errors encountered. The download process has a 10-minute timeout. ```go downloader := buildpackrunner.NewZipDownloader(false) u, _ := url.Parse("https://github.com/cloudfoundry/python-buildpack/releases/download/v1.7.0/python-buildpack-v1.7.0.zip") size, err := downloader.DownloadAndExtract(u, "/tmp/buildpacks/python_buildpack") if err != nil { fmt.Printf("Download failed: %v\n", err) os.Exit(1) } fmt.Printf("Downloaded and extracted %d bytes\n", size) ``` -------------------------------- ### WriteStagingInfoYML Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/buildpack-runner.md Writes a YAML file with staging information for DEA compatibility. It takes build result data and a list of buildpack metadata. ```APIDOC ## WriteStagingInfoYML ### Description Writes a YAML file with staging information for DEA compatibility (legacy format). ### Method *Implicitly a method call on a Runner object* ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * None ### Parameters - **resultData** (buildpackapplifecycle.StagingResult) - Required - Build result data - **buildpacks** ([]buildpackapplifecycle.BuildpackMetadata) - Required - List of buildpack metadata ### Response #### Success Response - **string** - Path to staging info file - **error** - Error if write fails ``` -------------------------------- ### Create Builder Config Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/00_START_HERE.md Use this function to create a new configuration for the lifecycle builder. ```go NewLifecycleBuilderConfig() ``` -------------------------------- ### BuildpackMetadata Struct Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/models.md Contains detailed information about a specific buildpack, such as its key, name, version, and configuration. ```go type BuildpackMetadata struct { Key string `json:"key" yaml:"key"` Name string `json:"name" yaml:"name"` Version string `json:"version,omitempty" yaml:"version,omitempty"` Config *BuildpackConfig `json:"config,omitempty" yaml:"config,omitempty"` OutputMetadata map[string]any `json:"output_metadata,omitempty" yaml:"output_metadata,omitempty"` } ``` -------------------------------- ### hasSupply (Unix) Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/buildpack-support.md Checks whether a buildpack has a `/bin/supply` script. This is used for multi-buildpack support. ```APIDOC ## hasSupply (Unix) ### Description Checks whether a buildpack has a `/bin/supply` script. This is used for multi-buildpack support. ### Signature ```go func hasSupply(buildpackPath string) (bool, error) ``` ### Parameters #### Path Parameters - **buildpackPath** (string) - Required - Path to buildpack directory ### Returns - **bool** — true if /bin/supply exists - **error** — Error if check fails ``` -------------------------------- ### BuildDir Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/lifecycle-builder-config.md Returns the absolute path to the application build directory where raw app bits are located. ```APIDOC ## BuildDir ### Description Returns the absolute path to the application build directory. ### Signature ```go func (s LifecycleBuilderConfig) BuildDir() string ``` ### Returns - **string** - Path where raw app bits are located ``` -------------------------------- ### Create New Container Path Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/EXPORTS.md Creates a new container path object. Accepts a string argument, likely a path identifier. ```go func New(_ string) *cpath { // ... implementation details ... } ``` -------------------------------- ### Create Builder Configuration Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/README.md Shows how to create a new instance of LifecycleBuilderConfig, which is used for configuring the builder process. This function is part of the main buildpackapplifecycle package. ```Go import "code.cloudfoundry.org/buildpackapplifecycle" // ... config := buildpackapplifecycle.NewLifecycleBuilderConfig() // ... configure config ... ``` -------------------------------- ### Convert LaunchData to StagingResult Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/launch-data.md Use this function to convert `LaunchData` into a `buildpackapplifecycle.StagingResult`. It separates regular processes from sidecars and populates both the process list and process type map. Processes without `sidecar_for` are added to `ProcessList` and `ProcessTypes`, while those with `sidecar_for` are converted to `Sidecar` entries. ```go launchData := resources.LaunchData{ Processes: []resources.Process{ { Type: "web", Command: "npm start", }, { Type: "logging-agent", Command: "node logging-agent.js", Platforms: struct { Cloudfoundry struct { SidecarFor []string `yaml:"sidecar_for"` } }{ Cloudfoundry: struct { SidecarFor []string `yaml:"sidecar_for"` }{ SidecarFor: []string{"web"}, }, }, Limits: struct { Memory int `yaml:"memory"` }{ Memory: 256, }, }, }, } result := resources.ConvertToResult(launchData) // result.ProcessTypes == map[string]string{"web": "npm start"} // result.ProcessList == []Process{web process} // result.Sidecars == []Sidecar{logging-agent sidecar for web} ``` -------------------------------- ### DeaStagingInfo.GetEntrypointPrefix Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/launch-data.md Returns the entrypoint prefix from the buildpack config, or an empty string if no config is set. ```APIDOC ## DeaStagingInfo.GetEntrypointPrefix ### Description Returns the entrypoint prefix from the buildpack config, or an empty string if no config is set. ### Signature ```go func (stagingInfo DeaStagingInfo) GetEntrypointPrefix() string ``` ### Parameters N/A ### Returns - **string** — Entrypoint prefix or empty string ### Example ```go info := buildpackrunner.DeaStagingInfo{ DetectedBuildpack: "ruby_buildpack", StartCommand: "bundle exec rails server", Config: &buildpackapplifecycle.BuildpackConfig{ EntrypointPrefix: "/bin/sh -c", }, } prefix := info.GetEntrypointPrefix() // Returns: "/bin/sh -c" ``` ``` -------------------------------- ### Set Output Metadata Path Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/configuration.md Specifies the file path where the build result metadata JSON will be written. This is a required flag. ```bash ./builder -outputMetadata=/output/result.json ``` -------------------------------- ### Configure Network Certificate Verification Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/configuration.md Use the -skipCertVerify flag to control SSL certificate verification for remote buildpack downloads. Skipping verification is not recommended for production due to security risks. ```bash # Verify certificates (recommended for production) ./builder -skipCertVerify=false ``` ```bash # Skip verification (use only for testing) ./builder -skipCertVerify=true ``` -------------------------------- ### Parse Platform Options Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/environment.md This snippet shows how to parse the VCAP_PLATFORM_OPTIONS environment variable to retrieve platform configuration, such as the Credhub URI, using the platformoptions module. ```go platformOptions, err := platformoptions.Get(os.Getenv("VCAP_PLATFORM_OPTIONS")) ``` -------------------------------- ### LifecycleBuilderConfig Methods Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/EXPORTS.md Provides access to various configuration details and paths within the LifecycleBuilderConfig. ```APIDOC ## Methods for LifecycleBuilderConfig ### Path() Returns the builder executable path. ### Args() Returns the command-line arguments for the builder. ### Validate() Performs validation on the builder configuration and returns an error if invalid. ### BuildDir() Returns the path to the application source directory. ### BuildpackPath(buildpackName string) Returns the storage path for a specific buildpack. ### LegacyBuildpackPath(buildpackName string) Returns the legacy MD5 path for a specific buildpack. ### BuildpackOrder() Returns the ordered list of buildpacks. ### SupplyBuildpacks() Returns the list of buildpacks used for supplying dependencies (non-final). ### DepsIndex(i int) Returns the zero-padded index for dependencies. ### BuildpacksDir() Returns the path to the local buildpacks directory. ### BuildpacksDownloadDir() Returns the path for downloading remote buildpacks. ### BuildArtifactsCacheDir() Returns the path to the build artifacts cache directory. ### OutputDroplet() Returns the output path for the droplet. ### OutputMetadata() Returns the output path for the metadata. ### OutputBuildArtifactsCache() Returns the output path for the build artifacts cache. ### SkipCertVerify() Returns a boolean indicating if SSL certificate verification is skipped. ### SkipDetect() Returns a boolean indicating if the detect phase is skipped. ### CredhubConnectAttempts() Returns the number of connection attempts for CredHub. ### CredhubRetryDelay() Returns the retry delay duration for CredHub connections. ``` -------------------------------- ### NewLifecycleBuilderConfig Constructor Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/lifecycle-builder-config.md Creates a new builder configuration with default values. Use this to initialize the builder configuration and register flags. ```go config := buildpackapplifecycle.NewLifecycleBuilderConfig( []string{"ruby_buildpack", "nodejs_buildpack"}, false, // perform detect false, // verify SSL certs ) // Parse command-line arguments if err := config.Parse(os.Args[1:]); err != nil { log.Fatal(err) } if err := config.Validate(); err != nil { log.Fatal(err) } ``` -------------------------------- ### PlatformOptions Struct Definition Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/types.md Holds platform-level configuration passed via the VCAP_PLATFORM_OPTIONS environment variable. ```go type PlatformOptions struct { CredhubURI string `json:"credhub-uri" } ``` -------------------------------- ### Check for /bin/supply Script (Unix) Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/buildpack-support.md Verifies if a buildpack directory contains a '/bin/supply' script. This is used for multi-buildpack support. ```go func hasSupply(buildpackPath string) (bool, error) ``` -------------------------------- ### Create Runner Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/00_START_HERE.md Use this function to create a new runner instance for buildpack execution. ```go New() ``` -------------------------------- ### BuildpackOrder Source: https://github.com/cloudfoundry/buildpackapplifecycle/blob/main/_autodocs/api-reference/lifecycle-builder-config.md Returns the ordered list of buildpacks to try, as configured in the buildpackOrder flag. This method provides the sequence in which buildpacks are evaluated during the build process. ```APIDOC ## BuildpackOrder ### Description Returns the ordered list of buildpacks to try, as configured in the buildpackOrder flag. ### Signature ```go func (s LifecycleBuilderConfig) BuildpackOrder() []string ``` ### Returns `[]string` — Buildpack names/URLs in order of preference ### Example ```go order := config.BuildpackOrder() // Might return: ["ruby_buildpack", "nodejs_buildpack"] ``` ```