Change kolla_version LABEL to git sha-1

Downstream users are often building their own
custom images from their own forked git.
Reasoning can be various - added fixes not merged yet,
some customizations and etc.

Because of this, it's very usefull to have information
about git commit in images, and this is exactly what
that patch does.

If images are built from pip source, kolla_version
LABEL contains kolla version.

Change-Id: If81989603185528dae86df52e8f8d0f94cdca85d
This commit is contained in:
Michal Arbet 2021-11-22 10:57:43 +01:00
parent 7afbcf1cc1
commit ad7b9054ca
3 changed files with 12 additions and 1 deletions

View File

@ -818,7 +818,8 @@ class KollaWorker(object):
return ret
def create_dockerfiles(self):
kolla_version = version.version_info.cached_version_string()
kolla_version = version.git_info if len(version.git_info) != 0 else \
version.version_info.cached_version_string()
supported_distro_name = common_config.DISTRO_PRETTY_NAME.get(
self.base)
for path in self.docker_build_paths:

View File

@ -10,6 +10,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import pbr.git
import pbr.version
kolla_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
version_info = pbr.version.VersionInfo('kolla')
git_info = pbr.git.get_git_short_sha(git_dir=os.path.join(kolla_path, ".git"))

View File

@ -0,0 +1,5 @@
---
upgrade:
- |
Change ``kolla_version`` label to git sha-1 if images
are built with kolla from git.