...
1# Copyright 2018-2022 Datawire. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License
14
15import os
16
17# Keep this in-sync with cmd/busyambassador/main.go.
18#
19# We don't report or log errors here, we just silently fall back to some static "MISSING(XXX)"
20# strings. This is in-part because the code here is running pretty early, and logging setup hasn't
21# happened yet. Also because any errors will be evident when the version number gets logged and
22# it's this static string.
23Version = "MISSING(FILE)"
24Commit = "MISSING(FILE)"
25try:
26 with open(os.path.join(os.path.dirname(__file__), "..", "ambassador.version")) as version:
27 info = version.read().split("\n")
28 while len(info) < 2:
29 info.append("MISSING(VAL)")
30
31 Version = info[0]
32 Commit = info[1]
33except FileNotFoundError:
34 pass
View as plain text