Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions agent_starter_pack/cli/commands/setup_cicd.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def setup_terraform_backend(
# Ensure bucket exists
try:
result = run_command(
["gsutil", "ls", "-b", f"gs://{bucket_name}"],
["gcloud", "storage", "buckets", "describe", f"gs://{bucket_name}"],
check=False,
capture_output=True,
)
Expand All @@ -381,11 +381,28 @@ def setup_terraform_backend(
console.print(f"\n📦 Creating Terraform state bucket: {bucket_name}")
# Create bucket
run_command(
["gsutil", "mb", "-p", project_id, "-l", region, f"gs://{bucket_name}"]
[
"gcloud",
"storage",
"buckets",
"create",
f"gs://{bucket_name}",
f"--project={project_id}",
f"--location={region}",
]
)

# Enable versioning
run_command(["gsutil", "versioning", "set", "on", f"gs://{bucket_name}"])
run_command(
[
"gcloud",
"storage",
"buckets",
"update",
f"gs://{bucket_name}",
"--versioning",
]
)
except subprocess.CalledProcessError as e:
console.print(f"\n❌ Failed to setup state bucket: {e}")
raise
Expand Down
23 changes: 15 additions & 8 deletions agent_starter_pack/cli/utils/cicd.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ def setup_terraform_state(self, project_dir: Path, env: Environment) -> None:
# Ensure bucket exists and is accessible
try:
result = run_command(
["gsutil", "ls", "-b", f"gs://{bucket_name}"],
["gcloud", "storage", "buckets", "describe", f"gs://{bucket_name}"],
check=False,
capture_output=True,
)
Expand All @@ -792,18 +792,25 @@ def setup_terraform_state(self, project_dir: Path, env: Environment) -> None:
print(f"\n📦 Creating Terraform state bucket: {bucket_name}")
run_command(
[
"gsutil",
"mb",
"-p",
self.config.cicd_project_id,
"-l",
self.config.region,
"gcloud",
"storage",
"buckets",
"create",
f"gs://{bucket_name}",
f"--project={self.config.cicd_project_id}",
f"--location={self.config.region}",
]
)

run_command(
["gsutil", "versioning", "set", "on", f"gs://{bucket_name}"]
[
"gcloud",
"storage",
"buckets",
"update",
f"gs://{bucket_name}",
"--versioning",
]
)
except subprocess.CalledProcessError as e:
print(f"\n❌ Failed to setup state bucket: {e}")
Expand Down
6 changes: 3 additions & 3 deletions tests/cli/commands/test_setup_cicd.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,11 @@ def run_command_side_effect(*args: Any, **kwargs: Any) -> MagicMock:
mock_response.stdout = '{"isEmpty": true}'
mock_response.returncode = 0
print("Mocking repository view command")
# Mock gsutil commands
elif "gsutil" in command:
# Mock gcloud storage commands
elif "gcloud" in command and "storage" in command:
mock_response.stdout = ""
mock_response.returncode = 0
print("Mocking gsutil command")
print("Mocking gcloud storage command")
# Mock git init
elif "git" in command and "init" in command:
mock_response.stdout = ""
Expand Down