... |
... |
@@ -16,6 +16,8 @@ |
16
|
16
|
import logging
|
17
|
17
|
|
18
|
18
|
from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
|
|
19
|
+from buildgrid._protos.build.bazel.semver import semver_pb2
|
|
20
|
+from buildgrid.settings import HIGH_REAPI_VERSION, LOW_REAPI_VERSION
|
19
|
21
|
|
20
|
22
|
|
21
|
23
|
class CapabilitiesInstance:
|
... |
... |
@@ -29,6 +31,9 @@ class CapabilitiesInstance: |
29
|
31
|
self.__action_cache_instance = action_cache_instance
|
30
|
32
|
self.__execution_instance = execution_instance
|
31
|
33
|
|
|
34
|
+ self.__high_api_version = None
|
|
35
|
+ self.__low_api_version = None
|
|
36
|
+
|
32
|
37
|
# --- Public API ---
|
33
|
38
|
|
34
|
39
|
@property
|
... |
... |
@@ -55,15 +60,20 @@ class CapabilitiesInstance: |
55
|
60
|
self.__execution_instance = execution_instance
|
56
|
61
|
|
57
|
62
|
def get_capabilities(self):
|
|
63
|
+ cache_capabilities = self._get_cache_capabilities()
|
|
64
|
+ execution_capabilities = self._get_capabilities_execution()
|
|
65
|
+
|
|
66
|
+ if self.__high_api_version is None:
|
|
67
|
+ self.__high_api_version = self._split_semantic_version(HIGH_REAPI_VERSION)
|
|
68
|
+ if self.__low_api_version is None:
|
|
69
|
+ self.__low_api_version = self._split_semantic_version(LOW_REAPI_VERSION)
|
|
70
|
+
|
58
|
71
|
server_capabilities = remote_execution_pb2.ServerCapabilities()
|
59
|
|
- server_capabilities.cache_capabilities.CopyFrom(self._get_cache_capabilities())
|
60
|
|
- server_capabilities.execution_capabilities.CopyFrom(self._get_capabilities_execution())
|
61
|
|
- # TODO
|
62
|
|
- # When API is stable, fill out SemVer values
|
63
|
|
- # server_capabilities.deprecated_api_version =
|
64
|
|
- # server_capabilities.low_api_version =
|
65
|
|
- # server_capabilities.low_api_version =
|
66
|
|
- # server_capabilities.hig_api_version =
|
|
72
|
+ server_capabilities.cache_capabilities.CopyFrom(cache_capabilities)
|
|
73
|
+ server_capabilities.execution_capabilities.CopyFrom(execution_capabilities)
|
|
74
|
+ server_capabilities.low_api_version.CopyFrom(self.__low_api_version)
|
|
75
|
+ server_capabilities.high_api_version.CopyFrom(self.__high_api_version)
|
|
76
|
+
|
67
|
77
|
return server_capabilities
|
68
|
78
|
|
69
|
79
|
# --- Private API ---
|
... |
... |
@@ -97,3 +107,13 @@ class CapabilitiesInstance: |
97
|
107
|
capabilities.exec_enabled = False
|
98
|
108
|
|
99
|
109
|
return capabilities
|
|
110
|
+
|
|
111
|
+ def _split_semantic_version(self, version_string):
|
|
112
|
+ major_version, minor_version, patch_version = version_string.split('.')
|
|
113
|
+
|
|
114
|
+ semantic_version = semver_pb2.SemVer()
|
|
115
|
+ semantic_version.major = major_version
|
|
116
|
+ semantic_version.minor = minor_version
|
|
117
|
+ semantic_version.patch = patch_version
|
|
118
|
+
|
|
119
|
+ return semantic_version
|