Skip to content

Commit 6fbe731

Browse files
authored
feat: migrate cicd to gcloud storage from gsutil (#702)
1 parent 3c7854d commit 6fbe731

File tree

3 files changed

+38
-14
lines changed

3 files changed

+38
-14
lines changed

agent_starter_pack/cli/commands/setup_cicd.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ def setup_terraform_backend(
372372
# Ensure bucket exists
373373
try:
374374
result = run_command(
375-
["gsutil", "ls", "-b", f"gs://{bucket_name}"],
375+
["gcloud", "storage", "buckets", "describe", f"gs://{bucket_name}"],
376376
check=False,
377377
capture_output=True,
378378
)
@@ -381,11 +381,28 @@ def setup_terraform_backend(
381381
console.print(f"\n📦 Creating Terraform state bucket: {bucket_name}")
382382
# Create bucket
383383
run_command(
384-
["gsutil", "mb", "-p", project_id, "-l", region, f"gs://{bucket_name}"]
384+
[
385+
"gcloud",
386+
"storage",
387+
"buckets",
388+
"create",
389+
f"gs://{bucket_name}",
390+
f"--project={project_id}",
391+
f"--location={region}",
392+
]
385393
)
386394

387395
# Enable versioning
388-
run_command(["gsutil", "versioning", "set", "on", f"gs://{bucket_name}"])
396+
run_command(
397+
[
398+
"gcloud",
399+
"storage",
400+
"buckets",
401+
"update",
402+
f"gs://{bucket_name}",
403+
"--versioning",
404+
]
405+
)
389406
except subprocess.CalledProcessError as e:
390407
console.print(f"\n❌ Failed to setup state bucket: {e}")
391408
raise

agent_starter_pack/cli/utils/cicd.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ def setup_terraform_state(self, project_dir: Path, env: Environment) -> None:
783783
# Ensure bucket exists and is accessible
784784
try:
785785
result = run_command(
786-
["gsutil", "ls", "-b", f"gs://{bucket_name}"],
786+
["gcloud", "storage", "buckets", "describe", f"gs://{bucket_name}"],
787787
check=False,
788788
capture_output=True,
789789
)
@@ -792,18 +792,25 @@ def setup_terraform_state(self, project_dir: Path, env: Environment) -> None:
792792
print(f"\n📦 Creating Terraform state bucket: {bucket_name}")
793793
run_command(
794794
[
795-
"gsutil",
796-
"mb",
797-
"-p",
798-
self.config.cicd_project_id,
799-
"-l",
800-
self.config.region,
795+
"gcloud",
796+
"storage",
797+
"buckets",
798+
"create",
801799
f"gs://{bucket_name}",
800+
f"--project={self.config.cicd_project_id}",
801+
f"--location={self.config.region}",
802802
]
803803
)
804804

805805
run_command(
806-
["gsutil", "versioning", "set", "on", f"gs://{bucket_name}"]
806+
[
807+
"gcloud",
808+
"storage",
809+
"buckets",
810+
"update",
811+
f"gs://{bucket_name}",
812+
"--versioning",
813+
]
807814
)
808815
except subprocess.CalledProcessError as e:
809816
print(f"\n❌ Failed to setup state bucket: {e}")

tests/cli/commands/test_setup_cicd.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,11 @@ def run_command_side_effect(*args: Any, **kwargs: Any) -> MagicMock:
307307
mock_response.stdout = '{"isEmpty": true}'
308308
mock_response.returncode = 0
309309
print("Mocking repository view command")
310-
# Mock gsutil commands
311-
elif "gsutil" in command:
310+
# Mock gcloud storage commands
311+
elif "gcloud" in command and "storage" in command:
312312
mock_response.stdout = ""
313313
mock_response.returncode = 0
314-
print("Mocking gsutil command")
314+
print("Mocking gcloud storage command")
315315
# Mock git init
316316
elif "git" in command and "init" in command:
317317
mock_response.stdout = ""

0 commit comments

Comments
 (0)