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

pack builder create should accept builder env config #1926

Merged
merged 11 commits into from
Oct 31, 2023

Conversation

WYGIN
Copy link
Contributor

@WYGIN WYGIN commented Oct 4, 2023

Summary

This PR adds new [[build.env]] table to the builder.toml file. If a platform environment variable with the given key/name exists, it will be overridden at build time. Otherwise, a new build-time environment variable with the given name will be created. that will be translated to files in /cnb/build-config/env by pack during pack builder create.
end-users can change the /cnb/build-config/env directory by defining CNB_BUILD_CONFIG_DIR env variable when building image

Output

when below table is added to builder.toml file

[[build.env]]
name = "CNB_USER_ID"
value = "9999"

Before

After

jammy: Pulling from cnbs/sample-stack-run
Digest: sha256:64ef0713b6b7499d3be43c78cdbbe2e1663d423219cdaf57135641cefd1dd291
Status: Image is up to date for cnbs/sample-stack-run:jammy
0.17.1: Pulling from buildpacksio/lifecycle
Digest: sha256:d2198a1940e80d6261d4cc4512c0303d56436836e59a71b90d28d03a5b9ba373
Status: Image is up to date for buildpacksio/lifecycle:0.17.1
===> ANALYZING
[analyzer] Timer: Analyzer started at 2023-10-08T12:33:42Z
[analyzer] Restoring data for SBOM from previous image
[analyzer] Timer: Analyzer ran for 1.74305ms and ended at 2023-10-08T12:33:42Z
===> DETECTING
[detector] Timer: Detector started at 2023-10-08T12:33:43Z
[detector] samples/hello-world     0.0.1
[detector] samples/hello-moon      0.0.1
[detector] samples/hello-processes 0.0.1
[detector] Timer: Detector ran for 5.280129ms and ended at 2023-10-08T12:33:43Z
===> RESTORING
[restorer] Timer: Restorer started at 2023-10-08T12:33:44Z
[restorer] Restoring metadata for "samples/hello-processes:sys-info" from app image
[restorer] Timer: Restorer ran for 896.35µs and ended at 2023-10-08T12:33:44Z
===> BUILDING
[builder] Timer: Builder started at 2023-10-08T12:33:46Z
[builder] ---> Hello World buildpack
[builder]      platform_dir files:
[builder]        /platform:
[builder]        total 0
[builder]        drwxr-xr-x 1 root root 17 Jan  1  1980 .
[builder]        drwxr-xr-x 1 root root 17 Oct  8 12:33 ..
[builder]        drwxr-xr-x 1 root root  6 Jan  1  1980 env
[builder]        
[builder]        /platform/env:
[builder]        total 0
[builder]        drwxr-xr-x 1 root root  6 Jan  1  1980 .
[builder]        drwxr-xr-x 1 root root 17 Jan  1  1980 ..
[builder]      env_dir: /platform/env
[builder]      env vars:
[builder]        declare -x CNB_BP_PLAN_PATH="/tmp/samples_hello-world-3609087222/samples_hello-world/plan.toml"
[builder]        declare -x CNB_BUILDPACK_DIR="/cnb/buildpacks/samples_hello-world/0.0.1"
[builder]        declare -x CNB_LAYERS_DIR="/layers/samples_hello-world"
[builder]        declare -x CNB_PLATFORM_DIR="/platform"
[builder]        declare -x CNB_STACK_ID="io.buildpacks.samples.stacks.jammy"
[builder]        declare -x CNB_TARGET_ARCH="amd64"
[builder]        declare -x CNB_TARGET_ARCH_VARIANT=""
[builder]        declare -x CNB_TARGET_DISTRO_NAME=""
[builder]        declare -x CNB_TARGET_DISTRO_VERSION=""
[builder]        declare -x CNB_TARGET_OS="linux"

[builder]        declare -x CNB_USER_ID="9999"

[builder]        declare -x HOME="/home/cnb"
[builder]        declare -x HOSTNAME="b08b51a7f373"
[builder]        declare -x OLDPWD
[builder]        declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
[builder]        declare -x PWD="/workspace"
[builder]        declare -x SHLVL="1"
[builder]      layers_dir: /layers/samples_hello-world
[builder]      plan_path: /tmp/samples_hello-world-3609087222/samples_hello-world/plan.toml
[builder]      plan contents:
[builder]        [[entries]]
[builder]          name = "some-world"
[builder]        
[builder]        [[entries]]
[builder]          name = "some-world"
[builder]          [entries.metadata]
[builder]            world = "Earth-616"
[builder] 
[builder] ---> Done
[builder] ---> Hello Moon buildpack
[builder]      env_dir: /platform/env
[builder]      env vars:
[builder]        declare -x CNB_BP_PLAN_PATH="/tmp/samples_hello-moon-3528507633/samples_hello-moon/plan.toml"
[builder]        declare -x CNB_BUILDPACK_DIR="/cnb/buildpacks/samples_hello-moon/0.0.1"
[builder]        declare -x CNB_LAYERS_DIR="/layers/samples_hello-moon"
[builder]        declare -x CNB_PLATFORM_DIR="/platform"
[builder]        declare -x CNB_STACK_ID="io.buildpacks.samples.stacks.jammy"
[builder]        declare -x CNB_TARGET_ARCH="amd64"
[builder]        declare -x CNB_TARGET_ARCH_VARIANT=""
[builder]        declare -x CNB_TARGET_DISTRO_NAME=""
[builder]        declare -x CNB_TARGET_DISTRO_VERSION=""
[builder]        declare -x CNB_TARGET_OS="linux"

[builder]        declare -x CNB_USER_ID="9999"

[builder]        declare -x HOME="/home/cnb"
[builder]        declare -x HOSTNAME="b08b51a7f373"
[builder]        declare -x OLDPWD
[builder]        declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
[builder]        declare -x PWD="/workspace"
[builder]        declare -x SHLVL="1"
[builder]      layers_dir: /layers/samples_hello-moon
[builder]      plan_path: /tmp/samples_hello-moon-3528507633/samples_hello-moon/plan.toml
[builder]      plan contents:
[builder] 
[builder] ---> Done
[builder] ---> Hello processes buildpack
[builder] ---> Adding sys-info process
[builder] ---> Done
[builder] Timer: Builder ran for 20.015147ms and ended at 2023-10-08T12:33:46Z
===> EXPORTING
[exporter] Timer: Exporter started at 2023-10-08T12:33:47Z
[exporter] Reusing layer 'samples/hello-processes:sys-info'
[exporter] Reusing layer 'buildpacksio/lifecycle:launch.sbom'
[exporter] Reusing 1/1 app layer(s)
[exporter] Reusing layer 'buildpacksio/lifecycle:launcher'
[exporter] Reusing layer 'buildpacksio/lifecycle:config'
[exporter] Reusing layer 'buildpacksio/lifecycle:process-types'
[exporter] Adding label 'io.buildpacks.lifecycle.metadata'
[exporter] Adding label 'io.buildpacks.build.metadata'
[exporter] Adding label 'io.buildpacks.project.metadata'
[exporter] no default process type
[exporter] Timer: Saving my-app... started at 2023-10-08T12:33:47Z
[exporter] *** Images (1660049a6cae):
[exporter]       my-app
[exporter] Timer: Saving my-app... ran for 9.972529ms and ended at 2023-10-08T12:33:47Z
[exporter] Timer: Exporter ran for 25.353927ms and ended at 2023-10-08T12:33:47Z
[exporter] Timer: Cache started at 2023-10-08T12:33:47Z
[exporter] Timer: Cache ran for 279.06µs and ended at 2023-10-08T12:33:47Z
Successfully built image my-app

Documentation

Related

Resolves #1632

Signed-off-by: WYGIN <wygininc@gmail.com>
@github-actions github-actions bot added this to the 0.32.0 milestone Oct 4, 2023
@github-actions github-actions bot added the type/enhancement Issue that requests a new feature or improvement. label Oct 4, 2023
@WYGIN WYGIN changed the title WIP added code to generate env files in buildConfigEnv dir pack builder create should accept builder env config Oct 4, 2023
Signed-off-by: WYGIN <wygininc@gmail.com>
Signed-off-by: WYGIN <wygininc@gmail.com>
Signed-off-by: WYGIN <wygininc@gmail.com>
Signed-off-by: WYGIN <wygininc@gmail.com>
@WYGIN
Copy link
Contributor Author

WYGIN commented Oct 8, 2023

@natalieparellano @jjbustamante i am getting following response when i use CNB_USER_ID value from 1000 to 9999 from the guide here & i added

[[build.env]]
name = "CNB_USER_ID"
value = "9999"

to the builder.toml

jammy: Pulling from cnbs/sample-stack-run
Digest: sha256:64ef0713b6b7499d3be43c78cdbbe2e1663d423219cdaf57135641cefd1dd291
Status: Image is up to date for cnbs/sample-stack-run:jammy
0.17.1: Pulling from buildpacksio/lifecycle
Digest: sha256:d2198a1940e80d6261d4cc4512c0303d56436836e59a71b90d28d03a5b9ba373
Status: Image is up to date for buildpacksio/lifecycle:0.17.1
===> ANALYZING
[analyzer] Timer: Analyzer started at 2023-10-08T12:33:42Z
[analyzer] Restoring data for SBOM from previous image
[analyzer] Timer: Analyzer ran for 1.74305ms and ended at 2023-10-08T12:33:42Z
===> DETECTING
[detector] Timer: Detector started at 2023-10-08T12:33:43Z
[detector] samples/hello-world     0.0.1
[detector] samples/hello-moon      0.0.1
[detector] samples/hello-processes 0.0.1
[detector] Timer: Detector ran for 5.280129ms and ended at 2023-10-08T12:33:43Z
===> RESTORING
[restorer] Timer: Restorer started at 2023-10-08T12:33:44Z
[restorer] Restoring metadata for "samples/hello-processes:sys-info" from app image
[restorer] Timer: Restorer ran for 896.35µs and ended at 2023-10-08T12:33:44Z
===> BUILDING
[builder] Timer: Builder started at 2023-10-08T12:33:46Z
[builder] ---> Hello World buildpack
[builder]      platform_dir files:
[builder]        /platform:
[builder]        total 0
[builder]        drwxr-xr-x 1 root root 17 Jan  1  1980 .
[builder]        drwxr-xr-x 1 root root 17 Oct  8 12:33 ..
[builder]        drwxr-xr-x 1 root root  6 Jan  1  1980 env
[builder]        
[builder]        /platform/env:
[builder]        total 0
[builder]        drwxr-xr-x 1 root root  6 Jan  1  1980 .
[builder]        drwxr-xr-x 1 root root 17 Jan  1  1980 ..
[builder]      env_dir: /platform/env
[builder]      env vars:
[builder]        declare -x CNB_BP_PLAN_PATH="/tmp/samples_hello-world-3609087222/samples_hello-world/plan.toml"
[builder]        declare -x CNB_BUILDPACK_DIR="/cnb/buildpacks/samples_hello-world/0.0.1"
[builder]        declare -x CNB_LAYERS_DIR="/layers/samples_hello-world"
[builder]        declare -x CNB_PLATFORM_DIR="/platform"
[builder]        declare -x CNB_STACK_ID="io.buildpacks.samples.stacks.jammy"
[builder]        declare -x CNB_TARGET_ARCH="amd64"
[builder]        declare -x CNB_TARGET_ARCH_VARIANT=""
[builder]        declare -x CNB_TARGET_DISTRO_NAME=""
[builder]        declare -x CNB_TARGET_DISTRO_VERSION=""
[builder]        declare -x CNB_TARGET_OS="linux"

[builder]        declare -x CNB_USER_ID="9999"

[builder]        declare -x HOME="/home/cnb"
[builder]        declare -x HOSTNAME="b08b51a7f373"
[builder]        declare -x OLDPWD
[builder]        declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
[builder]        declare -x PWD="/workspace"
[builder]        declare -x SHLVL="1"
[builder]      layers_dir: /layers/samples_hello-world
[builder]      plan_path: /tmp/samples_hello-world-3609087222/samples_hello-world/plan.toml
[builder]      plan contents:
[builder]        [[entries]]
[builder]          name = "some-world"
[builder]        
[builder]        [[entries]]
[builder]          name = "some-world"
[builder]          [entries.metadata]
[builder]            world = "Earth-616"
[builder] 
[builder] ---> Done
[builder] ---> Hello Moon buildpack
[builder]      env_dir: /platform/env
[builder]      env vars:
[builder]        declare -x CNB_BP_PLAN_PATH="/tmp/samples_hello-moon-3528507633/samples_hello-moon/plan.toml"
[builder]        declare -x CNB_BUILDPACK_DIR="/cnb/buildpacks/samples_hello-moon/0.0.1"
[builder]        declare -x CNB_LAYERS_DIR="/layers/samples_hello-moon"
[builder]        declare -x CNB_PLATFORM_DIR="/platform"
[builder]        declare -x CNB_STACK_ID="io.buildpacks.samples.stacks.jammy"
[builder]        declare -x CNB_TARGET_ARCH="amd64"
[builder]        declare -x CNB_TARGET_ARCH_VARIANT=""
[builder]        declare -x CNB_TARGET_DISTRO_NAME=""
[builder]        declare -x CNB_TARGET_DISTRO_VERSION=""
[builder]        declare -x CNB_TARGET_OS="linux"

[builder]        declare -x CNB_USER_ID="9999"

[builder]        declare -x HOME="/home/cnb"
[builder]        declare -x HOSTNAME="b08b51a7f373"
[builder]        declare -x OLDPWD
[builder]        declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
[builder]        declare -x PWD="/workspace"
[builder]        declare -x SHLVL="1"
[builder]      layers_dir: /layers/samples_hello-moon
[builder]      plan_path: /tmp/samples_hello-moon-3528507633/samples_hello-moon/plan.toml
[builder]      plan contents:
[builder] 
[builder] ---> Done
[builder] ---> Hello processes buildpack
[builder] ---> Adding sys-info process
[builder] ---> Done
[builder] Timer: Builder ran for 20.015147ms and ended at 2023-10-08T12:33:46Z
===> EXPORTING
[exporter] Timer: Exporter started at 2023-10-08T12:33:47Z
[exporter] Reusing layer 'samples/hello-processes:sys-info'
[exporter] Reusing layer 'buildpacksio/lifecycle:launch.sbom'
[exporter] Reusing 1/1 app layer(s)
[exporter] Reusing layer 'buildpacksio/lifecycle:launcher'
[exporter] Reusing layer 'buildpacksio/lifecycle:config'
[exporter] Reusing layer 'buildpacksio/lifecycle:process-types'
[exporter] Adding label 'io.buildpacks.lifecycle.metadata'
[exporter] Adding label 'io.buildpacks.build.metadata'
[exporter] Adding label 'io.buildpacks.project.metadata'
[exporter] no default process type
[exporter] Timer: Saving my-app... started at 2023-10-08T12:33:47Z
[exporter] *** Images (1660049a6cae):
[exporter]       my-app
[exporter] Timer: Saving my-app... ran for 9.972529ms and ended at 2023-10-08T12:33:47Z
[exporter] Timer: Exporter ran for 25.353927ms and ended at 2023-10-08T12:33:47Z
[exporter] Timer: Cache started at 2023-10-08T12:33:47Z
[exporter] Timer: Cache ran for 279.06µs and ended at 2023-10-08T12:33:47Z
Successfully built image my-app

however i am getting following result when i run docker run --rm --entrypoint sys-info -it my-app

       env vars:
       declare -x CNB_GROUP_ID="1000"
       declare -x CNB_USER_ID="1000"
       declare -x HOME="/home/cnb"
       declare -x HOSTNAME="ef8750c6846c"
       declare -x OLDPWD
       declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
       declare -x PWD="/workspace"
       declare -x SHLVL="1"
       declare -x TERM="xterm"

how can i check the envs of the image ?
also i am getting layer path and layer inside image but in tests here the layer doesn't exists and failing with error Expected nil: opening layer file '/tmp/fake-image1553049604/build-config-env.tar': open /tmp/fake-image1553049604/build-config-env.tar: no such file or directory and the [[build.env]] layer is not getting shaForFile
when i debug i am getting 8 layers in the image including the [[build.env]] (image.Layer()) one but it does has layerMap with only 7 layers but layers are 8 is this due to new Functions like SetBuildConfigEnv and other implementations are not implemented in imgutil ?

@WYGIN
Copy link
Contributor Author

WYGIN commented Oct 8, 2023

should i open a new issue in imgutil and a pr to resolve it if it is related to it

@WYGIN WYGIN marked this pull request as ready for review October 9, 2023 14:36
@WYGIN WYGIN requested review from a team as code owners October 9, 2023 14:36
@jjbustamante
Copy link
Member

jjbustamante commented Oct 10, 2023

Hi @WYGIN, there are several questions here. Let me try to go through them.

how can i check the envs of the image ?

If you are saving the image in your docker daemon, you can use docker inspect to check the configuration file and you can see the metadata.

For example, having jq installed, something like this could do the work for you. Also, if you publish your image to a registry you can use a tool like crane to check the config file, crane config.

docker inspect <your-iamge> jq '.[] | .Config | .Env '

Compiling your branch and running the sample builder you mentioned, I can see:

The config file for the image builder has the following environment variables

> docker inspect my-builder-env:jammy | jq '.[] | .Config | .Env '
[
  "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "CNB_USER_ID=1000",
  "CNB_GROUP_ID=1000",
  "CNB_STACK_ID=io.buildpacks.samples.stacks.jammy"
]

Inspecting the image layers with dive tool:

Screenshot 2023-10-10 at 6 26 14 PM

I can see a file CNB_USER_ID was added into /cnb/build-config/env with content 9999

@jjbustamante
Copy link
Member

jjbustamante commented Oct 11, 2023

also i am getting layer path and layer inside image but in tests here the layer doesn't exists and failing with error Expected nil: opening layer file '/tmp/fake-image1553049604/build-config-env.tar': open /tmp/fake-image1553049604/build-config-env.tar: no such file or directory and the [[build.env]] layer is not getting shaForFile when i debug i am getting 8 layers in the image including the [[build.env]] (image.Layer()) one but it does has layerMap with only 7 layers but layers are 8 is this due to new Functions like SetBuildConfigEnv and other implementations are not implemented in imgutil ?

I think I found your problem.

  • You are right, the Image interface implementation used in our unit tests came from imgutil. Your build-config-env.tar file is empty and the sha is the same for others empty tar added into the image. after your code is executed, we also have this code:
if len(b.env) > 0 {
  logger.Debugf("Provided Environment Variables\n  %s", style.Map(b.env, "  ", "\n"))
}

envTar, err := b.envLayer(tmpDir, b.env)
if err != nil {
   return err
}

Which I think is overriding the path in the layerMap because the env.tar is also empty. I think a quick way to fix it is moving the process to add the layer into the if validation that checks that you actually have build config envs.

Something like this:

if len(b.buildConfigEnv) > 0 {
	logger.Debugf("Provided Build Config Environment Variables\n  %s", style.Map(b.env, "  ", "\n"))

	buildConfigEnvTar, err := b.buildConfigEnvLayer(tmpDir, b.buildConfigEnv)
	if err != nil {
		return errors.Wrap(err, "retrieving build-config-env layer")
	}

	if err := b.image.AddLayer(buildConfigEnvTar); err != nil {
		return errors.Wrap(err, "adding build-config-env layer")
	}
}

Which I think it better, I don't know why we add the empty env layer into the image anyway

Signed-off-by: WYGIN <wygininc@gmail.com>
@WYGIN
Copy link
Contributor Author

WYGIN commented Oct 12, 2023

when i run the following command pack build my-app --builder my-builder:jammy --path samples/apps/java-maven/ --env "HI=hi"
note: here i declared --env "HI=hi" flag to pass env with value from guide here & the code implementation here
i am getting the following envs declared in lifecycle phases

declare -x CNB_BP_PLAN_PATH="/tmp/samples_hello-moon-3054511201/samples_hello-moon/plan.toml"
[builder]        declare -x CNB_BUILDPACK_DIR="/cnb/buildpacks/samples_hello-moon/0.0.1"
[builder]        declare -x CNB_DUP_ID="9999"
[builder]        declare -x CNB_LAYERS_DIR="/layers/samples_hello-moon"
[builder]        declare -x CNB_PLATFORM_DIR="/platform"
[builder]        declare -x CNB_STACK_ID="io.buildpacks.samples.stacks.jammy"
[builder]        declare -x CNB_TARGET_ARCH="amd64"
[builder]        declare -x CNB_TARGET_ARCH_VARIANT=""
[builder]        declare -x CNB_TARGET_DISTRO_NAME=""
[builder]        declare -x CNB_TARGET_DISTRO_VERSION=""
[builder]        declare -x CNB_TARGET_OS="linux"
[builder]        declare -x HI="hi"
[builder]        declare -x HOME="/home/cnb"
[builder]        declare -x HOSTNAME="000fe4967dab"
[builder]        declare -x OLDPWD
[builder]        declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
[builder]        declare -x PWD="/workspace"
[builder]        declare -x SHLVL="1"

this is the output when i run 'env' in container's docker run --rm -it my-app bash -c 'env'

HOSTNAME=a29123dbe762
PWD=/workspace
_=/usr/bin/env
CNB_GROUP_ID=1000
HOME=/home/cnb
TERM=xterm
SHLVL=0
CNB_USER_ID=1000
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
OLDPWD=/workspace

and AFAIK docker/podman will read config-file/metadata of the container before it starts the container & it looks like it also reads envs too from the metadata & there are only few envs are getting declared in metadata & even flag --env "HI=hi" is not getting added to the metadata, for me it looks like an issue that is not related to my ticket/issue & i would like to confirm it once before i rise an issue on it :)
thanks a lot @jjbustamante @natalieparellano for your support & i think apart from that issue, i think the pr is ready for review and i would like to know the changes required :)

Copy link
Member

@natalieparellano natalieparellano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WYGIN this is awesome! My apologies for the delay in getting back to you about this. The PR looks great! Thank you for testing everything so thoroughly 🙌🏼 🙏🏼

I left a couple of comments, but this is really close!

builder/config_reader.go Outdated Show resolved Hide resolved
internal/builder/builder_test.go Show resolved Hide resolved
@@ -1257,3 +1305,11 @@ func (e errModuleTar) Info() dist.ModuleInfo {
func (e errModuleTar) Path() string {
return ""
}

func cnbBuildConfigDir() string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC this allows the pack user to specify the location of the build config directory within the builder by setting an environment variable in pack's environment. We might want to add some text to pack builder create --help so that this option is discoverable. Or maybe we could add it as a field in builder.toml ...or just leave it non-configurable. WDYT @WYGIN @jjbustamante?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not sure about adding pack builder create --help, IMO the pack builder create --help is about giving better context to user about the list of commands available for the end-user to use, and i think CNB_BUILD_CONFIG_DIR in cli help might not required
so i added it to the docs where builder.toml fields and tables are specified

internal/builder/builder.go Show resolved Hide resolved
internal/commands/builder_create.go Outdated Show resolved Hide resolved
@WYGIN WYGIN marked this pull request as draft October 24, 2023 16:19
Signed-off-by: WYGIN <wygininc@gmail.com>
Signed-off-by: WYGIN <wygininc@gmail.com>
@WYGIN
Copy link
Contributor Author

WYGIN commented Oct 26, 2023

@natalieparellano @jjbustamante i have noticed the following differences in between operator-defined variables and environment-variable-modification-rules

where operator-defined variables

The /env/ directory follows the Environment Variable Modification Rules outlined in the Buildpack Interface Specification, except for the modification behavior when no period-delimited suffix is provided; when no suffix is provided, the behavior is default.

and environment-variable-modification-rules

Suffix Modification Behavior
none Override
.append Append
.default Default
.delim Delimiter
.override Override
.prepend Prepend

when the [[build.env]]'s suffix field is omited we get zero value of string which is empty string and when suffix = "" again it is a zero value of string
So i think it is not possible to differentiate empty string and an omited suffix field AFAIK, so now what should be the default behavior when suffix is omited or has empty string

Signed-off-by: WYGIN <wygininc@gmail.com>
@natalieparellano
Copy link
Member

what should be the default behavior when suffix is omited or has empty string

Ah, that is okay - the lifecycle will handle that. We just need to create the files in the correct format.

@natalieparellano
Copy link
Member

I think this is ready for your review @jjbustamante

Copy link
Member

@jjbustamante jjbustamante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WYGIN

Thank you very much for this PR! and all your amazing work ❤️

@WYGIN
Copy link
Contributor Author

WYGIN commented Oct 27, 2023

how can i contribute to this issue, i have never co-authored before & now i need make contribution based on changes made by husni-faiz, it would be helpful if you point me to some resource or by giving some suggestion on how to make changes made pr, if i clone husni-faiz repo i need to commit changes to his repo and he need to create a commit for my changes to reflect at buildpack, is there any simple way this @natalieparellano @jjbustamante

@natalieparellano
Copy link
Member

how can i contribute to buildpacks/rfcs#294

I'll let @jjbustamante speak further to this as he's leading this track of work, but I think a first step would be to go through this RFC. The RFC mentions:

The problem for adding support for multi-arch buildpacks can be divided into three parts:

  1. Support buildpack authors to migrate their existing buildpacks to support multi-arch.
  2. Support buildpack authors to create new buildpacks and builders that handle multi-arch from the beginning.
  3. Support application developers to create application images using multi-arch buildpacks and builders.

I believe @husni-faiz has been working on some (though perhaps not all) of the issues that relate to phase 1 (Husni could you advise if there any issues unclaimed or that you'd like help with?).

We haven't started work on phase 2, mostly because the requirements are still evolving, but it might not hurt to get some idea of what issues we might need to create for phase 2 (how the work will be broken down). I am sure that any of us who've been involved with this effort would be happy to provide guidance when it comes to the implementation.

Signed-off-by: Juan Bustamante <jbustamante@vmware.com>
@jkutner jkutner merged commit 7944bf1 into buildpacks:main Oct 31, 2023
15 checks passed
@jjbustamante
Copy link
Member

jjbustamante commented Oct 31, 2023

Hi @WYGIN

how can i contribute to buildpacks/rfcs#294

As @natalieparellano mentioned, @husni-faiz is being working on this. He is struggling adding test coverage to his imgutil and pack PR. I have the following approach to contribute to Husni pull requests using my pack personal fork

  1. On my local pack fork I added Husni remote
    git remote add husni-faiz git://github.com/husni-faiz/pack.git
  2. I changed the URL to used ssh authentication (to avoid a time out error when fetching)
    git remote set-url husni-faiz git@github.com:husni-faiz/pack.git
  3. I fetched Husni branch on my local
    git fetch -v husni-faiz test-manifest
  4. I created a local branch from Husni's branch to do some changes
    git checkout -b jjbustamante/suggestions-1 husni-faiz/test-manifest
  5. Push your local branch and the you will be able to create a PR changing the destination to be Husni fork
    Screenshot 2023-10-31 at 9 31 03 AM

I think in this way you can help Husni, we will really appreciate it! ❤️ , our main goal is to improve test coverage in both PR (imgutil and pack)

@WYGIN
Copy link
Contributor Author

WYGIN commented Oct 31, 2023

@jjbustamante i have been deep diving into gccr, podman's image, buildah, storage and other repos and also docker cli, now i got a clear picture of the pr but i have few confusions on --all flag implementation in podman, it's been a little overwhelming, but mostly by the next day i will try to get clarified by myself, and when it comes to pr of @husni-faiz it looks pretty ok for me on pack's pr, but i think there is still a lot of work left in imgutil IMO and i am trying to understand whether pack manifest push or pack manifest create with --publish flag is used along with --all flag then should the local images too needed to be uploaded to the registry if they are not found in registry with the given name/digest, also thinking about using gccr puller to only download manifest instead of downloading entire image and then getting manifest from the downloaded image
this is my only doubt i have for now , once i get clarified; i will start making changes accordingly and will push changes, hoping will complete pack manifest and imgutil within the next 7 days by testing everything perfectly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Issue that requests a new feature or improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC #0109] pack builder create should accept builder env config
4 participants