Define ShouldRun for GcpTaskRunner and add --force for setup.
Skip the GCP setup task if the config already has fields set. And add
--force for setup args if user wants to re-initialize their config with
new values.
The checked fields are just for remote CF use right now.
Bug: 112615679
Test: acloud setup --gcp_init with config that has required fields defined
acloud setup --gcp_init --force still goes through setup steps.
atest acloud_test
Change-Id: I3fc27d556d828423da253237d570070f25f94bb9
diff --git a/setup/gcp_setup_runner.py b/setup/gcp_setup_runner.py
index 7b9feb5..f50b2c0 100644
--- a/setup/gcp_setup_runner.py
+++ b/setup/gcp_setup_runner.py
@@ -204,6 +204,18 @@
if not cfg.stable_host_image_name:
UpdateConfigFile(self.config_path, "stable_host_image_name", "")
+ def ShouldRun(self):
+ """Check if we actually need to run GCP setup.
+
+ We'll only do the gcp setup if certain fields in the cfg are empty.
+
+ Returns:
+ True if reqired config fields are empty, False otherwise.
+ """
+ return (not self.client_id
+ or not self.client_secret
+ or not self.project)
+
def _Run(self):
"""Run GCP setup task."""
self._SetupGcloudInfo()