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

Create secret with bearer-token #3617

Merged
merged 1 commit into from
Mar 16, 2023
Merged

Conversation

Santosh1176
Copy link
Contributor

@Santosh1176 Santosh1176 commented Feb 21, 2023

This is for creating a secret with a git bearer-token.
The tests are failing due to some new lines being added to the golden file. I've tested the generated manifest and it's in line with the one in the ./testdata dir.

I need further guidance on whether the data for bearerToken needs to be captured as .data.bearerToken or .stringData.bearerToken? The current implementation is for .stringData

This PR attempts to close #3536

@Santosh1176 Santosh1176 marked this pull request as draft February 21, 2023 09:17
@Santosh1176 Santosh1176 changed the title WIP create secret with bearer-token Create secret with bearer-token Feb 26, 2023
cmd/flux/testdata/create_secret/git/git-bearer-token.yaml Outdated Show resolved Hide resolved
cmd/flux/testdata/create_secret/git/git-bearer-token.yaml Outdated Show resolved Hide resolved
cmd/flux/create_secret_git.go Outdated Show resolved Hide resolved
cmd/flux/create_secret_git.go Outdated Show resolved Hide resolved
cmd/flux/create_secret_git.go Outdated Show resolved Hide resolved
cmd/flux/create_secret_git_test.go Outdated Show resolved Hide resolved
pkg/manifestgen/sourcesecret/options.go Outdated Show resolved Hide resolved
cmd/flux/create_secret_git.go Outdated Show resolved Hide resolved
pkg/manifestgen/sourcesecret/sourcesecret.go Outdated Show resolved Hide resolved
@Santosh1176
Copy link
Contributor Author

@aryan9600 Thank you for the review. I've addressed them as advised, requesting a review.

@darkowlzz
Copy link
Contributor

The tests are failing due to some new lines being added to the golden file. I've tested the generated manifest and it's in line with the one in the ./testdata dir.

@Santosh1176 I tried your tests and found that the newline is expected. Our test tooling supports an -update flag that can be used to update such golden files automatically. For updating the golden files related to just that particular test, I ran

$ make test TEST_PKG_PATH="./cmd/flux" TEST_ARGS="-run TestCreateGitSecret -update"

The golden file got updated and I got the following diff:

diff --git a/cmd/flux/testdata/create_secret/git/git-bearer-token.yaml b/cmd/flux/testdata/create_secret/git/git-bearer-token.yaml
index 52a37a25..7dcfde2d 100644
--- a/cmd/flux/testdata/create_secret/git/git-bearer-token.yaml
+++ b/cmd/flux/testdata/create_secret/git/git-bearer-token.yaml
@@ -6,3 +6,4 @@ metadata:
   namespace: my-namespace
 stringData:
   bearerToken: ghp_baR2qnFF0O41WlucePL3udt2N9vVZS4R0hAS
+

And after that, running the test without the -update flag makes it pass.

I need further guidance on whether the data for bearerToken needs to be captured as .data.bearerToken or .stringData.bearerToken? The current implementation is for .stringData

The other secret related tests also use stringData, so it should be fine to use stringData for this.

@Santosh1176
Copy link
Contributor Author

running the test without the -update flag makes it pass.

@darkowlzz Thank you for clarifying this for me, really helps.

I'll look into the error part.
Thank you.

@Santosh1176 Santosh1176 force-pushed the patch-3536 branch 2 times, most recently from eaa6146 to 34adb42 Compare March 12, 2023 19:39
@Santosh1176 Santosh1176 requested review from darkowlzz and aryan9600 and removed request for aryan9600 and darkowlzz March 12, 2023 19:41
cmd/flux/create_secret_git.go Outdated Show resolved Hide resolved
cmd/flux/create_secret_git_test.go Show resolved Hide resolved
cmd/flux/create_secret_git.go Outdated Show resolved Hide resolved
@darkowlzz
Copy link
Contributor

darkowlzz commented Mar 13, 2023

After addressing the above review comments, please rebase on the latest main branch, squash all the commits into one and mark this PR as ready. It looks almost ready to me.

@darkowlzz darkowlzz added the area/git Git related issues and pull requests label Mar 13, 2023
@Santosh1176 Santosh1176 marked this pull request as ready for review March 13, 2023 13:50
@Santosh1176 Santosh1176 requested review from darkowlzz and removed request for aryan9600 March 13, 2023 13:51
Copy link
Contributor

@darkowlzz darkowlzz left a comment

Choose a reason for hiding this comment

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

Overall, it looks good to me. Thanks for implementing it.
It'd be better to have one more reviewer go through it before we merge it.

cmd/flux/create_secret_git.go Outdated Show resolved Hide resolved
cmd/flux/create_secret_git.go Outdated Show resolved Hide resolved
@Santosh1176 Santosh1176 requested review from darkowlzz and hiddeco and removed request for darkowlzz and hiddeco March 14, 2023 15:56
Signed-off-by: Santosh Kaluskar <[email protected]>
Copy link
Contributor

@darkowlzz darkowlzz left a comment

Choose a reason for hiding this comment

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

LGTM!

@Santosh1176
Copy link
Contributor Author

Thank you for your guidance.

@darkowlzz darkowlzz merged commit 5fdc8c3 into fluxcd:main Mar 16, 2023
@Santosh1176 Santosh1176 deleted the patch-3536 branch March 16, 2023 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/git Git related issues and pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add create secret git with bearer token
4 participants