这是indexloc提供的服务,不要输入任何密码
Skip to content

feat: Support initial empty lockfile #160

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

Conversation

nahueespinosa
Copy link
Contributor

When setting up a new project, an initial template is required for lockfile generation to work without errors.
This patch allows users to create an empty file and run, for example: bazel run @bullseye//:lock.

Related to GoogleContainerTools/distroless#1697.

Signed-off-by: Nahuel Espinosa <nahue.espinosa@gmail.com>
Copy link

google-cla bot commented May 16, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@thesayyn
Copy link
Collaborator

Some CI steps are failing, do you mind checking them?

Signed-off-by: Nahuel Espinosa <nahue.espinosa@gmail.com>
@nahueespinosa
Copy link
Contributor Author

Tests are passing locally now!

Signed-off-by: Nahuel Espinosa <nahue.espinosa@gmail.com>
@thesayyn thesayyn merged commit a69bc19 into GoogleContainerTools:main Jun 11, 2025
9 checks passed
@gfrankliu
Copy link

Thanks for the improvement! If the lock file doesn't exist (initial), why wouldn't the rule start from empty instead of still requiring user to create the initial empty file?

@gfrankliu
Copy link

Maybe something like this?

--- apt/extensions.bzl.orig
+++ apt/extensions.bzl
@@ -26,7 +26,11 @@
                     # buildifier: disable=print
                     print("\nNo lockfile was given, please run `bazel run @%s//:lock` to create the lockfile." % install.name)
             else:
-                lockf = lockfile.from_json(module_ctx, module_ctx.read(install.lock))
+                if module_ctx.file(install.lock.package + "/" + install.lock.name):
+                    lock_content = module_ctx.read(install.lock)
+                else:
+                    lock_content = None
+                lockf = lockfile.from_json(module_ctx, lock_content)
                 reproducible = True
 
             for (package) in lockf.packages():

@gfrankliu
Copy link

Thanks for the improvement! If the lock file doesn't exist (initial), why wouldn't the rule start from empty instead of still requiring user to create the initial empty file?

Submitted PR #169

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.

3 participants