27
27
from tests .providers .google .cloud .utils .gcp_authenticator import GCP_CLOUD_BUILD_KEY , GcpAuthenticator
28
28
from tests .utils .logging_command_executor import LoggingCommandExecutor
29
29
30
- GCE_INSTANCE = os .environ .get ("GCE_INSTANCE" , "testinstance" )
31
30
GCP_PROJECT_ID = os .environ .get ("GCP_PROJECT_ID" , "example-project" )
32
31
GCP_ARCHIVE_URL = os .environ .get ("GCP_CLOUD_BUILD_ARCHIVE_URL" , "gs://example-bucket/source-code.tar.gz" )
33
32
GCP_ARCHIVE_URL_PARTS = urlparse (GCP_ARCHIVE_URL )
@@ -71,7 +70,7 @@ def create_repository_and_bucket(self):
71
70
self .execute_cmd (["gcloud" , "source" , "repos" , "create" , GCP_REPOSITORY_NAME ])
72
71
self .execute_cmd (["git" , "init" ], cwd = tmp_dir )
73
72
self .execute_cmd (["git" , "config" , "user.email" , "bot@example.com" ], cwd = tmp_dir )
74
- self .execute_cmd (["git" , "config" , "user.name" , "system-test" ])
73
+ self .execute_cmd (["git" , "config" , "user.name" , "system-test" ], cwd = tmp_dir )
75
74
self .execute_cmd (
76
75
["git" , "config" , "credential.https://source.developers.google.com.helper" , "gcloud.sh" ],
77
76
cwd = tmp_dir ,
@@ -82,7 +81,7 @@ def create_repository_and_bucket(self):
82
81
GCP_PROJECT_ID , GCP_REPOSITORY_NAME
83
82
)
84
83
self .execute_cmd (["git" , "remote" , "add" , "origin" , repo_url ], cwd = tmp_dir )
85
- self .execute_cmd (["git" , "push" , "origin" , "master" ], cwd = tmp_dir )
84
+ self .execute_cmd (["git" , "push" , "--force" , " origin" , "master" ], cwd = tmp_dir )
86
85
87
86
def delete_repo (self ):
88
87
"""Delete repository in Google Cloud Source Repository service"""
@@ -92,15 +91,15 @@ def delete_repo(self):
92
91
def delete_bucket (self ):
93
92
"""Delete bucket in Google Cloud Storage service"""
94
93
95
- self .execute_cmd (["gsutil" , "rb " , "gs://{}" .format (GCP_BUCKET_NAME )])
94
+ self .execute_cmd (["gsutil" , "rm" , "-r " , "gs://{}" .format (GCP_BUCKET_NAME )])
96
95
97
96
def delete_docker_images (self ):
98
97
"""Delete images in Google Cloud Container Registry"""
99
98
100
99
repo_image_name = "gcr.io/{}/{}" .format (GCP_PROJECT_ID , GCP_REPOSITORY_NAME )
101
- self .execute_cmd (["gcloud" , "container" , "images" , "delete" , repo_image_name ])
100
+ self .execute_cmd (["gcloud" , "container" , "images" , "delete" , "--quiet" , repo_image_name ])
102
101
bucket_image_name = "gcr.io/{}/{}" .format (GCP_PROJECT_ID , GCP_BUCKET_NAME )
103
- self .execute_cmd (["gcloud" , "container" , "images" , "delete" , bucket_image_name ])
102
+ self .execute_cmd (["gcloud" , "container" , "images" , "delete" , "--quiet" , bucket_image_name ])
104
103
105
104
106
105
if __name__ == "__main__" :
0 commit comments