---
# System prepended metadata

title: kctrl - Update image with ver instead of sha in package-repository.yml
tags: [kctrl]

---

# kctrl - Update image with ver instead of sha in package-repository.yml

###### tags: `kctrl`

## Problem Statement

Update image with ver instead of sha in package-repository.yml. When users do kctrl pkg repo get -r REPO or kctrl pkg repo list, sha value is not human readable and it becomes difficult to figure out the repository version.

## Observation and findings

```
$ ./kctrl pkg repo list -A
Target cluster 'https://192.168.64.108:8443' (nodes: minikube)

Repositories in all namespaces

Namespace   Name   Source                                                                             Status
kctrl-test  demo   (imgpkg) rohitagg2020/demo-repo:1.0.0                                       Reconcile succeeded
^           demo2  (imgpkg) rohitagg2020/demo-repo:sha256-8a55a777f43f6755fbe782f7b45...       Reconcile succeeded
^           demo3  (imgpkg) rohitagg2020/demo-repo:sha256-8a55a777f43f6755fbe782f7b45...       Reconcile succeeded
```

## Possible Approach

1. Instead of creating the url with `sha`, we will create it with version ``
2. Enhance imgpkg bundle to support multiple tags while doing `imgpkg push` [#355](https://github.com/vmware-tanzu/carvel-imgpkg/issues/355). Since it is a good first issue, I will check with `Joao` and see if we can pick and implement it real quick.
3. Run imgpkg push twice on the same bundle, once with `user-provided` tag and other time with `bundle-<TIMESTAMP>` tag.

## Adding a flag

There are two possibilities:
1. There is already a version tag provided which can be used. A flag can be used to enable/disable the use of this `version` as tag.

    e.g. `kctrl pkg release -v 1.0.0 --use-version-as-tag=true/false`

    **Cons**:

    As version flag is optional, how will be the behavior if it is not provided.

    `kctrl pkg release --use-version-as-tag=true`

    In this, version is set to `0.0.0+build.1664733377`.
    
2. Add another flag: `--additional-imgpkg-tag` 

    e.g. `kctrl pkg release -v 1.0.0 --additional-imgpkg-tag=v1.0.0`

    **Pros**
    Decoupled from package version.

    **Cons**
    1. Two tags are introduced, one for package version and another for imgpkg tag.
    2. Export section only supports imgpkg bundle only today. Do we see some other mechanism? If yes, should we make it more generic e.g. `--additional-tag` ?

## Discussion and finalized approach

Since the user wants to override the tag, we will add a new flag `tag` which when specified will override the default `bundle-<TIMESTAMP>` format.