Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

feat: support stamping repository tags for images #423

Merged
merged 4 commits into from
Sep 17, 2019

Conversation

LanceEa
Copy link
Contributor

@LanceEa LanceEa commented Sep 12, 2019

This addresses issue #378

Adds support for using stamp variables for the repository tag so that it will resolve the repository name and tag prior to pushing the container to the repository. It now works similar to the docker_rules push_container rule.

k8s_object(
    name = "image-stamping",
    # K8s deployment template wtih a stamping variable to replace
    template = ":deployment.yaml",
    # Build images with the same container
    images = {
        "index.docker.io/parsec86/{REPOSITORY}:{STABLE_GIT_COMMIT}": "//examples/imagestamping/go:go-container",
    }
)

Note - Stamping only effects the resolved image name that is pushed to the container registry. The container digest will still be used inside your resolved template since the digest is immutable.

Adds support for using stamp variables for the repository tag so that it will resolve the repository name and tag prior to pushing the container to the repository. It now works similiar to the docker_rules `push_container` rule.

```python
k8s_object(
    name = "image-stamping",
    # K8s deployment template wtih a stamping variable to replace
    template = ":deployment.yaml",
    # Build images with the same container
    images = {
        "index.docker.io/parsec86/{REPOSITORY}:{STABLE_GIT_COMMIT}": "//examples/imagestamping/go:go-container",
    }
)
```

>**Note** - Stamping only effects the resolved image name that is pushed to the container registry. The container digest will still be used inside your resolved template since the digest is immutable.
@k8s-ci-robot
Copy link

Hi @LanceEa. Thanks for your PR.

I'm waiting for a bazelbuild member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@LanceEa
Copy link
Contributor Author

LanceEa commented Sep 12, 2019

@nlopezgi - This should address #387 that @codesuki was describing.

I'm new to Bazel so let me know if there is anything I missed. Also, I wasn't sure on the examples folder if I should use gcr registry or not. So, for the time being I just use my personal repo for the example. Let me know how to best proceed and I can make that change.

Thanks,
Lance

@nlopezgi
Copy link
Contributor

/ok-to-test

Copy link
Contributor

@nlopezgi nlopezgi left a comment

Choose a reason for hiding this comment

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

thanks for sending this PR!
Change looks really good overall, a few nits, kicked off tests but should be good to submit once addressed.

@nlopezgi
Copy link
Contributor

Note: I'm not sure how this is related to #378
The issues I found related to this are: #387 and possibly #351. Please confirm

@LanceEa
Copy link
Contributor Author

LanceEa commented Sep 14, 2019

Note: I'm not sure how this is related to #378
The issues I found related to this are: #387 and possibly #351. Please confirm

Sorry about that. Yes, I meant #387. I'm not sure on #351. I think that one is a more general purpose stamping of the template file via the substitution.

@LanceEa
Copy link
Contributor Author

LanceEa commented Sep 14, 2019

Cleaned up the PR based on your feedback. Let me know if you need me to squash the commits or update the commit messages at all.

Thanks,
Lance

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: LanceEa, nlopezgi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants