Adapt to ytt 0.28.0
Ytt 0.28.0 introduced a breaking change. The --output-directory
option was removed. This was done because this option implicitly
emptied the directory, which could be dangerous. While this option
still exist under a different name, the --output-files option is
now recommended.
The installer now uses the --output-files option, but to ensure a
clean installation, it checks, whether the directory already exists
and if it does, asks the user, whether it can empty it. If it is
not allowed to do so, the installation will abort.
Change-Id: I574c3b054e9293c0534d609c062946cd39890793
This commit is contained in:
parent
3b4005a047
commit
89ee46a081
|
@ -14,7 +14,9 @@
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
import stat
|
import stat
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
@ -146,7 +148,7 @@ def _run_ytt(config, output_dir):
|
||||||
command += ["-f", template]
|
command += ["-f", template]
|
||||||
|
|
||||||
command += [
|
command += [
|
||||||
"--output-directory",
|
"--output-files",
|
||||||
output_dir,
|
output_dir,
|
||||||
"--ignore-unknown-comments",
|
"--ignore-unknown-comments",
|
||||||
"-f",
|
"-f",
|
||||||
|
@ -230,6 +232,23 @@ def install(config_manager, output_dir, dryrun, update_repo):
|
||||||
|
|
||||||
if not os.path.exists(output_dir):
|
if not os.path.exists(output_dir):
|
||||||
os.mkdir(output_dir)
|
os.mkdir(output_dir)
|
||||||
|
elif os.listdir(output_dir):
|
||||||
|
while True:
|
||||||
|
response = input(
|
||||||
|
(
|
||||||
|
"Output directory already exists. This may lead to file conflicts "
|
||||||
|
"and unwanted configuration applied to the cluster. Do you want "
|
||||||
|
"to empty the directory? [y/n] "
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if response == "y":
|
||||||
|
shutil.rmtree(output_dir)
|
||||||
|
os.mkdir(output_dir)
|
||||||
|
break
|
||||||
|
if response == "n":
|
||||||
|
print("Aborting installation. Please provide empty directory.")
|
||||||
|
sys.exit(1)
|
||||||
|
print("Unknown input.")
|
||||||
|
|
||||||
_run_ytt(config, output_dir)
|
_run_ytt(config, output_dir)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue