Skip to content

Error replacing image stamps: Failed to find key #96

@amsokol

Description

@amsokol

Hello,

First thanks author very much for the great tool!

I faced with the bug, I think.

My environment is:
Ubuntu Linux 24.04.1 (arm64)
Bazel 7.3.1
rules_helm 0.5.1
rules_oci 2.0.0

My code is the following:

def helm_package(
        name,
        package,
        values,
        images = {},
        api_version = "v2",
        type = "application",
        app_version = "1.0.0",
        version = "0.1.0",
        description = "A Helm chart",
        templates = [],
        substitutions = []):

    # Normalize the rule name by replacing hyphens and dots with underscores.
    rule_name = name.replace("-", "_").replace(".", "_")

    # Iterate over the images dictionary and push each image to the OCI registry.
    for image in images:
        tag = images[image]
        oci_push(
            name = "%s.push" % image,  # Name of the OCI push target.
            image = "%s" % image,  # Image name.
            remote_tags = [tag],  # Tags to apply to the pushed image.
            repository = "%s/%s/%s" % (REGISTRY_PUSH_URI, package, to_registy_image_name(image)),  # Repository URI.
        )

    # Create a Helm chart file with the specified parameters.
    chart_file(
        name = "%s.chart_file" % rule_name,  # Name of the chart file target.
        api_version = api_version,  # API version of the Helm chart.
        app_version = app_version,  # Application version of the Helm chart.
        chart_name = "%s-chart" % name,  # Name of the Helm chart.
        description = description,  # Description of the Helm chart.
        type = type,  # Type of the Helm chart.
        version = version,  # Version of the Helm chart.
    )

    # Define the Helm chart target.
    helm_chart(
        name = "%s" % rule_name,  # Name of the Helm chart target.
        chart = ":%s.chart_file" % rule_name,  # Reference to the chart file target.
        substitutions = substitutions,  # Substitutions to apply to the Helm chart.
        templates = templates,  # Template files for the Helm chart.
        values = values,  # Values file for the Helm chart.
        images = [
            ":%s.push" % image
            for image in images
        ],
    )

I get the error when I build:

Error replacing image stamps: Failed to find key @@//<oci_push rule created using "for/in"> in content

Thanks in advance for any help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions