-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pkg/gcp/gcs: Improve GCS path construction/retrieval logic #1738
pkg/gcp/gcs: Improve GCS path construction/retrieval logic #1738
Conversation
- Ensure constructed paths are prefixed with `gs://` - Use flag vars instead of strings for RsyncRecursive - Add isPathNormalized function Use this function as pre-check for any gsutil/GCS functions that manipulate GCS bucket contents. - Use isPathNormalized in RsyncRecursive and PathExists - Clarify when we are constructing a release path or version marker path Signed-off-by: Stephen Augustus <[email protected]>
This allows any caller to pass an arbitrary GCS path elements without having to handle any filepath.Join() logic. Should handle the following cases: - single path element - multiple path elements - path element already contains `gs://` - path element was the result of a filepath.Join() and contains `gs:/` - path element contains a leading `/` Should error if: - there were no path elements - the only path element is an empty string Signed-off-by: Stephen Augustus <[email protected]>
Signed-off-by: Stephen Augustus <[email protected]>
Signed-off-by: Stephen Augustus <[email protected]>
Signed-off-by: Stephen Augustus <[email protected]>
Signed-off-by: Stephen Augustus <[email protected]>
Testing with the `--gcs-suffix` flag has been frustrating. It's possible the original shell library never properly handled this option and it was never noticed because the option isn't exercised in our releases or CI jobs. Here we replace its usage with `--gcs-root`. If specified, it will override BuildType. When unset: - BuildType: "ci" - final path: gs://<bucket>/ci When set: - BuildType: "ci" - GCSRoot: "new-root" - final path: gs://<bucket>/new-root Signed-off-by: Stephen Augustus <[email protected]>
Signed-off-by: Stephen Augustus <[email protected]>
33247d5
to
e5c5306
Compare
`gsutil rsync` doesn't actual require that either of the specified directories be GCS paths, so here we remove that requirement. Signed-off-by: Stephen Augustus <[email protected]>
Signed-off-by: Stephen Augustus <[email protected]>
Signed-off-by: Stephen Augustus <[email protected]>
200a569
to
479164f
Compare
/assign @saschagrunert @hasheddan @cpanato |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: justaugustus, saschagrunert The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind bug cleanup
What this PR does / why we need it:
Continuation of #1711.
pkg/gcp/gcs: Improve path normalization logic
Ensure constructed paths are prefixed with
gs://
Use flag vars instead of strings for RsyncRecursive
Add isPathNormalized function
Use this function as pre-check for any gsutil/GCS functions that
manipulate GCS bucket contents.
Use isPathNormalized in RsyncRecursive and PathExists
Clarify when we are constructing a release path or version marker path
pkg/gcp/gcs: NormalizeGCSPath now handles multiple path elements
This allows any caller to pass an arbitrary GCS path elements without
having to handle any filepath.Join() logic.
Should handle the following cases:
gs://
gs:/
/
Should error if:
pkg: Update usages of gcs.NormalizeGCSPath()
pkg/release: Respect the GCS suffix when pushing version markers
pkg/gcp/gcs: Add a few test cases for GCS paths
pkg/build: Fixup filepath.Join() bug when pushing release artifacts
pkg/build: Deprecate the GCSSuffix option and introduce GCSRoot option
Testing with the
--gcs-suffix
flag has been frustrating.It's possible the original shell library never properly handled this
option and it was never noticed because the option isn't exercised in
our releases or CI jobs.
Here we replace its usage with
--gcs-root
.If specified, it will override BuildType.
When unset:
When set:
pkg/build: Drop references to GCSSuffix
pkg/gcp/gcs: RsyncRecursive doesn't need to run against normalized paths
gsutil rsync
doesn't actual require that either of the specifieddirectories be GCS paths, so here we remove that requirement.
pkg/release: Fix prefix check to determine bucket permissions
dependencies.yaml: Add entry for skopeo
Which issue(s) this PR fixes:
Special notes for your reviewer:
Does this PR introduce a user-facing change?