Skip to content
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

Refactor the git clone to make the variable scope smaller #5190

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

Warashi
Copy link
Contributor

@Warashi Warashi commented Sep 5, 2024

What this PR does / why we need it:

Move the authArgs into the singleflight closure, as they are only used within it.

Which issue(s) this PR fixes:

Follows #5171

Does this PR introduce a user-facing change?:

  • How are users affected by this change:
  • Is this breaking change:
  • How to migrate (if breaking change):

Move the authArgs into the singleflight closure, as they are only used within it.

Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Copy link
Member

@ffjlabo ffjlabo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Warashi Warashi enabled auto-merge (squash) September 5, 2024 06:00
Copy link
Member

@khanhtc1202 khanhtc1202 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ナイス👍

@Warashi Warashi merged commit d9db2c6 into master Sep 5, 2024
13 of 15 checks passed
Copy link

codecov bot commented Sep 5, 2024

Codecov Report

Attention: Patch coverage is 14.28571% with 6 lines in your changes missing coverage. Please review.

Project coverage is 22.93%. Comparing base (0f52877) to head (fe5ce6c).
Report is 88 commits behind head on master.

Files with missing lines Patch % Lines
pkg/git/client.go 14.28% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5190      +/-   ##
==========================================
- Coverage   22.95%   22.93%   -0.02%     
==========================================
  Files         419      419              
  Lines       44996    44996              
==========================================
- Hits        10329    10322       -7     
- Misses      33872    33878       +6     
- Partials      795      796       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Warashi Warashi deleted the move-prepare-auth-args-into-closure branch September 5, 2024 06:01
github-actions bot pushed a commit that referenced this pull request Sep 5, 2024
Move the authArgs into the singleflight closure, as they are only used within it.

Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Signed-off-by: pipecd-bot <pipecd.dev@gmail.com>
ffjlabo added a commit that referenced this pull request Sep 5, 2024
* Modified to use Git with PAT (#4571)

* fix to read PAT settings from file

Signed-off-by: sZma5a <sZma5a@geekers.io>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: Your Name <you@example.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* piped

Signed-off-by: sZma5a <sZma5a@geekers.io>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: Your Name <you@example.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* include  PAT information in URL

Signed-off-by: sZma5a <sZma5a@geekers.io>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: Your Name <you@example.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: modification of conditional branching

Co-authored-by: sivchari <shibuuuu5@gmail.com>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: Your Name <you@example.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: corrected error in error message

Co-authored-by: sivchari <shibuuuu5@gmail.com>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: Your Name <you@example.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: integration of mask function

Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: Your Name <you@example.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: make validation test

Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: Your Name <you@example.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: function name

Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: Your Name <you@example.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: rename function for validation PAT

Signed-off-by: Your Name <you@example.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: fix test code as pointed out in the review

Signed-off-by: Your Name <you@example.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* feat: add explan
for git personal access token in document

Signed-off-by: Your Name <you@example.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: change required in documentation

Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: change return value

Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: add test case

Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: fix test

Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: PipedGit struct to use password
authentication instead of personal access token

Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix to read PAT settings from file

Signed-off-by: sZma5a <sZma5a@geekers.io>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: Your Name <you@example.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* piped

Signed-off-by: sZma5a <sZma5a@geekers.io>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: Your Name <you@example.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: integration of mask function

Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: Your Name <you@example.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: make validation test

Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: Your Name <you@example.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: function name

Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: Your Name <you@example.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: rename function for validation PAT

Signed-off-by: Your Name <you@example.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: fix test

Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: PipedGit struct to use password
authentication instead of personal access token

Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* Fix Git authentication configuration

Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* Update password authentication configuration

Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* Fix error variable name

Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* Fix rename password

Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* Refactor includePasswordAuthRemote function

Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* Update password authentication in clone test

Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: delete PasswordAuth

Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: remove unused PasswordAuth field and refactor password authentication in git client

Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* Remove unnecessary print statement in Validate function

Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: fix code for rebase

Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: remove unused GitPasswordAuth configuration

Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* feat: add password decoding for password in includePasswordRemote function

Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: refactor Git password authentication method

Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* fix: update password encoding in TestCloneUsingPassword

Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* Update docs/content/en/docs-dev/user-guide/managing-piped/configuration-reference.md

Co-authored-by: Yoshiki Fujikane <40124947+ffjlabo@users.noreply.github.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* Update pkg/config/piped.go

Co-authored-by: Yoshiki Fujikane <40124947+ffjlabo@users.noreply.github.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* [wip] delete password

Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* [wip] not tested - change token to args from url

Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* Fix commented out test case

Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* Refactor authentication in git client

Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

* feat: add password decoding function and replace Password string

Signed-off-by: sZma5a <masaaki.haribote@gmail.com>

---------

Signed-off-by: sZma5a <sZma5a@geekers.io>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: Your Name <you@example.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Co-authored-by: sZma5a <sZma5a@geekers.io>
Co-authored-by: sivchari <shibuuuu5@gmail.com>
Co-authored-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Co-authored-by: Your Name <you@example.com>
Co-authored-by: Yoshiki Fujikane <40124947+ffjlabo@users.noreply.github.com>
Signed-off-by: pipecd-bot <pipecd.dev@gmail.com>

* Use singleflight to clone/update repository cache (#5171)

Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Signed-off-by: pipecd-bot <pipecd.dev@gmail.com>

* Refactor the git clone (#5190)

Move the authArgs into the singleflight closure, as they are only used within it.

Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Signed-off-by: pipecd-bot <pipecd.dev@gmail.com>

---------

Signed-off-by: sZma5a <sZma5a@geekers.io>
Signed-off-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Signed-off-by: Your Name <you@example.com>
Signed-off-by: sZma5a <masaaki.haribote@gmail.com>
Signed-off-by: swallow <masaaki@haribote-lab.net>
Signed-off-by: pipecd-bot <pipecd.dev@gmail.com>
Signed-off-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
Co-authored-by: sZma5a <35451404+sZma5a@users.noreply.github.com>
Co-authored-by: sZma5a <sZma5a@geekers.io>
Co-authored-by: sivchari <shibuuuu5@gmail.com>
Co-authored-by: 鈴木 優耀 <suzuki_masaaki@cyberagent.co.jp>
Co-authored-by: Your Name <you@example.com>
Co-authored-by: Yoshiki Fujikane <40124947+ffjlabo@users.noreply.github.com>
Co-authored-by: Shinnosuke Sawada-Dazai <shin@warashi.dev>
@github-actions github-actions bot mentioned this pull request Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants