Commit 30f9664b authored by George Engelbrecht's avatar George Engelbrecht Committed by Commit Bot

Add 'stat' to gsutil module.

In support of the signing rework we're going to want to have
the signers keep track of the calculated hash to ensure that
we don't have a TOCTOU type issue. This commit adds the stat
command to the gsutil module so that we can ask gs a files hash.

Change-Id: Ib35d1541292a18fbfc26fab50f594c682ba4109d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1754262Reviewed-by: 's avatarRobbie Iannucci <iannucci@chromium.org>
Commit-Queue: George Engelbrecht <engeg@google.com>
parent 089282a9
......@@ -651,7 +651,7 @@ Arguments:
&mdash; **def [cat](/recipes/recipe_modules/gsutil/api.py#108)(self, url, args=None, \*\*kwargs):**
&mdash; **def [copy](/recipes/recipe_modules/gsutil/api.py#115)(self, source_bucket, source, dest_bucket, dest, args=None, link_name='gsutil.copy', metadata=None, unauthenticated_url=False, \*\*kwargs):**
&mdash; **def [copy](/recipes/recipe_modules/gsutil/api.py#122)(self, source_bucket, source, dest_bucket, dest, args=None, link_name='gsutil.copy', metadata=None, unauthenticated_url=False, \*\*kwargs):**
&mdash; **def [download](/recipes/recipe_modules/gsutil/api.py#94)(self, bucket, source, dest, args=None, \*\*kwargs):**
......@@ -659,11 +659,13 @@ Arguments:
&emsp; **@property**<br>&mdash; **def [gsutil\_py\_path](/recipes/recipe_modules/gsutil/api.py#10)(self):**
&mdash; **def [list](/recipes/recipe_modules/gsutil/api.py#132)(self, url, args=None, \*\*kwargs):**
&mdash; **def [list](/recipes/recipe_modules/gsutil/api.py#139)(self, url, args=None, \*\*kwargs):**
&mdash; **def [remove\_url](/recipes/recipe_modules/gsutil/api.py#146)(self, url, args=None, \*\*kwargs):**
&mdash; **def [remove\_url](/recipes/recipe_modules/gsutil/api.py#153)(self, url, args=None, \*\*kwargs):**
&mdash; **def [signurl](/recipes/recipe_modules/gsutil/api.py#139)(self, private_key_file, bucket, dest, args=None, \*\*kwargs):**
&mdash; **def [signurl](/recipes/recipe_modules/gsutil/api.py#146)(self, private_key_file, bucket, dest, args=None, \*\*kwargs):**
&mdash; **def [stat](/recipes/recipe_modules/gsutil/api.py#115)(self, url, args=None, \*\*kwargs):**
&mdash; **def [upload](/recipes/recipe_modules/gsutil/api.py#78)(self, source, bucket, dest, args=None, link_name='gsutil.upload', metadata=None, unauthenticated_url=False, \*\*kwargs):**
### *recipe_modules* / [infra\_paths](/recipes/recipe_modules/infra_paths)
......
......@@ -112,6 +112,13 @@ class GSUtilApi(recipe_api.RecipeApi):
name = kwargs.pop('name', 'cat')
return self(cmd, name, **kwargs)
def stat(self, url, args=None, **kwargs):
args = args or []
url = self._normalize_url(url)
cmd = ['stat'] + args + [url]
name = kwargs.pop('name', 'stat')
return self(cmd, name, **kwargs)
def copy(self, source_bucket, source, dest_bucket, dest, args=None,
link_name='gsutil.copy', metadata=None, unauthenticated_url=False,
**kwargs):
......
......@@ -189,6 +189,20 @@
"infra_step": true,
"name": "gsutil cat"
},
{
"cmd": [
"python",
"-u",
"RECIPE_MODULE[depot_tools::gsutil]/resources/gsutil_smart_retry.py",
"--",
"RECIPE_REPO[depot_tools]/gsutil.py",
"----",
"stat",
"gs://example/foo"
],
"infra_step": true,
"name": "gsutil stat"
},
{
"name": "$result"
}
......
......@@ -72,6 +72,7 @@ def RunSteps(api):
api.gsutil.cat('gs://%s/foo' % bucket)
api.gsutil.stat('gs://%s/foo' % bucket)
def GenTests(api):
yield api.test('basic')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment