Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable Env Vars and Post Installation Commands from project.toml #84

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tiff-ritz
Copy link

@tiff-ritz tiff-ritz commented Dec 27, 2024

These changes collectively enhance the buildpack's flexibility and usability, allowing for more sophisticated configuration and automation during the build process.This pull request introduces several significant changes to the buildpack configuration and package installation process. The main changes include adding support for configuring environment variables and commands for installed packages, updating dependencies, and enhancing the test coverage.

New keys were added to the project.toml file to allow the ability to configure package environment variables and post installation commands.

env - a dict {} of key/pairs defining environment variables to be exported to the environment after package installation
commands - a list of string commands to be executed after package installation. These will be executed in the order they are listed.

During the build process, the buildpack will read the project.toml file and apply the specified environment variables. The {install_dir} placeholder will be replaced with the actual paths so the variables are available at both build and launch phases using [layer environment variables][cnb-environment].

The buildpack includes a set of default environment variables for each package, known as PACKAGE_ENV_VARS. These default environment variables are applied during the build process. However, you can override these default values by specifying environment variables in the project.toml file.

If a package is listed in the project.toml file with environment variables under the env key, those variables will take precedence over the default PACKAGE_ENV_VARS.

[_]
schema-version = "0.2"

[com.heroku.buildpacks.deb-packages]
install = [
    # string version of a dependency to install
    system-cron,
    # inline-table version of a dependency to install
    { name = "git", env = { "GIT_EXEC_PATH" = "{install_dir}/usr/lib/git-core", "GIT_TEMPLATE_DIR" = "{install_dir}/usr/share/git-core/templates" }, commands = ["echo 'Git installed successfully'", "git --version"]},
    { name = "babeld" },
    { name = "ghostscript", skip_dependencies = true, force = true, env = { "GS_LIB" = "{install_dir}/var/lib/ghostscript" }, commands = ["echo Ghostscript installed successfully", "gs --version"]},
]

Added unit tests to:

buildpack_config.rs
requested_package.rs
environment.rs
install_packages.rs

Integration Tests added:

test_get_integration_test_builder()
test_get_integration_test_arch()
test_panic_unsupported_test_configuration()
test_set_install_config()

@tiff-ritz tiff-ritz requested a review from a team as a code owner December 27, 2024 18:57
@tiff-ritz tiff-ritz changed the title Added a FromStr implementation to debian::MultiarchName Configurable Env Vars from project.toml Dec 27, 2024
@tiff-ritz tiff-ritz force-pushed the main branch 2 times, most recently from b95a6ce to 2e9918a Compare December 30, 2024 16:40
@tiff-ritz tiff-ritz changed the title Configurable Env Vars from project.toml Configurable Env Vars and Post Installation Commands from project.toml Dec 31, 2024
@tiff-ritz tiff-ritz marked this pull request as draft December 31, 2024 21:01
@edmorley edmorley removed the request for review from a team January 1, 2025 12:33
# This is the 1st commit message:

added code to set GIT_EXEC_PATH while installing packages.  Added a FromStr implementation to debian::MultiarchName in order to implement a unit test
document adding GIT_EXEC_PATH in the readme table of environment variables

# This is the commit message #2:

add setting of GS_LIB
Added a FromStr implementation to debian::MultiarchName
Implment functionality to load the environment variables associate with packages from the project.toml file
use PACKAGE_ENV_VARS constand to map default env vars to be defined if the package is in the project.toml file - these can be overwritten by the values in the project.toml file
define the package_env_vars before the env vars in the project.toml file
update README to reflect the PACKAGE_ENV_VARS

testing the buildpack, added a variable for skipped_packages.  Will incorporate that into install_packages

move the env logic into configure_layer_environment.  Iterate through the skipped_packages to make sure all the env vars are set and the post install command are run

flushed out a test in order to accomindate the new parameters passed to configure_layer_environment

finished the test for skipped packages

update the unit test to use a fixture to create the env correctly

use  a fixture for the test project.toml file; update the README
@tiff-ritz tiff-ritz marked this pull request as ready for review January 10, 2025 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants