Skip to content

Commit

Permalink
Fixing provider=existing for local/existing (#1425)
Browse files Browse the repository at this point in the history
* Adding existing and local to checks

* add last check

Co-authored-by: iameskild <[email protected]>
  • Loading branch information
costrouc and iameskild authored Sep 3, 2022
1 parent 2654b47 commit b4965d5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
# additional
pkgs.minikube
pkgs.k9s
pkgs.expect
];
in rec {
defaultApp.x86_64-linux = pythonPackages.buildPythonPackage {
Expand Down
7 changes: 5 additions & 2 deletions qhub/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
def provision_01_terraform_state(stage_outputs, config):
directory = "stages/01-terraform-state"

if config["provider"] == "local":
if config["provider"] in {"existing", "local"}:
stage_outputs[directory] = {}
else:
stage_outputs[directory] = terraform.deploy(
Expand Down Expand Up @@ -195,7 +195,10 @@ def guided_install(
check_cloud_credentials(config)

stage_outputs = {}
if config["provider"] != "local" and config["terraform_state"]["type"] == "remote":
if (
config["provider"] not in {"existing", "local"}
and config["terraform_state"]["type"] == "remote"
):
if skip_remote_state_provision:
print("Skipping remote state provision")
else:
Expand Down
10 changes: 8 additions & 2 deletions qhub/destroy.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ def gather_stage_outputs(config):
terraform_destroy=False,
)

if config["provider"] != "local" and config["terraform_state"]["type"] == "remote":
if (
config["provider"] not in {"existing", "local"}
and config["terraform_state"]["type"] == "remote"
):
stage_outputs["stages/01-terraform-state"] = _terraform_init_output(
directory=os.path.join("stages/01-terraform-state", config["provider"]),
input_vars=input_vars.stage_01_terraform_state(stage_outputs, config),
Expand Down Expand Up @@ -148,7 +151,10 @@ def _terraform_destroy(ignore_errors=False, terraform_apply=False, **kwargs):
ignore_errors=True,
)

if config["provider"] != "local" and config["terraform_state"]["type"] == "remote":
if (
config["provider"] not in {"existing", "local"}
and config["terraform_state"]["type"] == "remote"
):
status["stages/01-terraform-state"] = _terraform_destroy(
# acl and force_destroy do not import properly
# and only get refreshed properly with an apply
Expand Down
5 changes: 4 additions & 1 deletion qhub/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ def render_template(output_directory, config_filename, force=False, dry_run=Fals
"stages/07-kubernetes-services",
"stages/08-qhub-tf-extensions",
]
if config["provider"] != "local" and config["terraform_state"]["type"] == "remote":
if (
config["provider"] not in {"existing", "local"}
and config["terraform_state"]["type"] == "remote"
):
directories.append(f"stages/01-terraform-state/{config['provider']}")

source_dirs = [os.path.join(str(template_directory), _) for _ in directories]
Expand Down

0 comments on commit b4965d5

Please sign in to comment.