Giter Club home page Giter Club logo

Comments (6)

thesayyn avatar thesayyn commented on June 29, 2024

Its not a workaround that's how we implemented stamping in rules_oci.

from rules_oci.

gfrankliu avatar gfrankliu commented on June 29, 2024

I'm not talking about stamping, but just passing a variable to oci_push, eg: bazel run --define=repo_url ...

from rules_oci.

gfrankliu avatar gfrankliu commented on June 29, 2024

With container_push, we can have the BUILD file:

container_push(
    name = "image-push",
    format = "OCI",
    image = ":image",
    registry = "$(REGISTRY_REGION)-docker.pkg.dev",
    repository = "$(REGISTRY_PROJECT_ID)/dev-repo/myapp",
    tag = "$(IMAGE_TAG)",
    visibility = ["//visibility:public"],
)

and run

bazel run -define=REGISTRY_REGION=us --define=REGISTRY_PROJECT_ID=my-project-id   --define=IMAGE_TAG=test-tag :image-push

I tried below with oci_push but the variable expansion doesn't work.

oci_push(
    name = "image-push",
    image = ":image",
    repository = "$(REGISTRY_REGION)-docker.pkg.dev/$(REGISTRY_PROJECT_ID)/dev-repo/myapp",
    remote_tags = ["$(IMAGE_TAG)"],
    visibility = ["//visibility:public"],
)

The only workaround seems to be using "expand_template" at this time. It would be great if we can add direct variable expansion support in oci_push, like container_push.

from rules_oci.

thesayyn avatar thesayyn commented on June 29, 2024

it's the same thing essentially, expand_template also supports define variables, so you can expand your --define values.

from rules_oci.

gfrankliu avatar gfrankliu commented on June 29, 2024

Yes, currently since oci_push doesn't support variable expansion, we have to use variable expansion in expand_template to workaround that. Today we use container_push with variables. Is it possible to add variable expansion support in oci_push directly so we don't have to add expand_template for every oci_push during migration?

from rules_oci.

thesayyn avatar thesayyn commented on June 29, 2024

This is by design, is how it works, and not a workaround. Is it unusual? Yes, but it saves us a lot of maintainer time.

we don't have to add expand_template for every oci_push during migration

It's clearly written on the Readme that we are not trying to be 1:1 replacement for rules_docker.

An alternative you can use is that, creating a macro around oci_push that automatically stamps repository and repo_tags so you don't have to use expand template everywhere. It's up to you at that point, how you want to stamp these variables.

from rules_oci.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.