2 # Copyright (c) 2017 GigaSpaces Technologies Ltd. All rights reserved
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # * See the License for the specific language governing permissions and
14 # * limitations under the License.
22 def get_helm_path(url):
23 tarball = _fetch_helm(url)
24 helm_dir = _get_tmp_file_name()
25 _untar_helm_archive(tarball, helm_dir)
26 helm_binary_path = _find_file('helm', helm_dir)
27 return helm_binary_path
30 def get_apps_root_path(git_url):
31 dst_repo_path = _get_tmp_file_name()
32 Repo.clone_from(git_url, dst_repo_path)
33 apps_root = format(dst_repo_path)
37 dst_tar_path = _get_tmp_file_name()
39 file = urllib.URLopener()
40 file.retrieve(url, dst_tar_path)
44 def _untar_helm_archive(tar_path, helm_dir):
45 helm_tar = tarfile.open(tar_path)
46 helm_tar.extractall(helm_dir)
50 def _find_file(filename, base_path):
51 for root, dirs, files in os.walk(base_path):
54 return os.path.abspath(os.path.join(root, name))
56 raise Exception('Cannot find helm binary')
59 def _get_tmp_file_name():
60 return '{}/{}'.format(tempfile._get_default_tempdir(), next(tempfile._get_candidate_names()))