load("@rules_pkg//pkg:pkg.bzl", "pkg_tar")
load("@rules_distroless//distroless:defs.bzl", "passwd")

passwd(
    name = "passwd",
    passwds = [
        dict(
            gecos = ["root"],
            gid = 0,
            home = "/root",
            shell = "/bin/bash",
            uid = 0,
            username = "root",
        ),
        dict(
            gecos = ["nonroot"],
            gid = 1001,
            home = "/home/nonroot",
            shell = "/bin/bash",
            uid = 1001,
            username = "nonroot",
        ),
    ],
)

# Create a tar file containing the created passwd file
pkg_tar(
    name = "passwd_tar",
    srcs = [":passwd"],
    mode = "0o644",
    package_dir = "etc",
    tags = ["manual"],
    visibility = ["//visibility:public"],
)