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

fix: Trim newline of the content read from Secrets or Configmaps #1146

Merged
merged 2 commits into from
Mar 30, 2021

Conversation

whynowy
Copy link
Member

@whynowy whynowy commented Mar 30, 2021

Signed-off-by: Derek Wang [email protected]

Secrets edited by tools like vim always have an invisible \n in the end, and it is often neglected by the user, however this makes differences for some of the applications. We trim that \n to avoid issues.

Also upgraded go-git package to the latest.

Fixes: #338

Might fix: #1068 as well.
Checklist:

Copy link
Contributor

@alexec alexec left a comment

Choose a reason for hiding this comment

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

are we saying go 16 is broken?

Signed-off-by: Derek Wang <[email protected]>
@whynowy
Copy link
Member Author

whynowy commented Mar 30, 2021

are we saying go 16 is broken?

are we saying go 16 is broken?

I take back what I said, it's NOT an issue of ioutil.ReadFile() or os.ReadFile(), this is actually an issue of vim.

We always use vim to create a credential file on the local, and then use kubectl create secret xxx --from-file=xxx to create k8s secrets. However, vi or vim always put newlines (\n) at the end of every line - especially including the last line. This newline is not a visible new line, but it does have an \n there.

For example:

vi test1.txt with a string hello and :wq, you will see the file size is 6 instead of 5, the extra 1 is invisible \n, though you don't see a new line with cat test1.txt.

If you do the same thing with another file text2.txt, but do :set binary, :set noeol before :wq, the file size will be 5 indeed.

https://unix.stackexchange.com/questions/31807/what-does-the-noeol-indicator-at-the-bottom-of-a-vim-edit-session-mean

Here we still trim the ending \n in our code to avoid issues.

@whynowy whynowy changed the title fix: Remove extra new line of ioutil.ReadFile() fix: Trim newline of the content read from Secrets or Confirmaps Mar 30, 2021
@whynowy whynowy changed the title fix: Trim newline of the content read from Secrets or Confirmaps fix: Trim newline of the content read from Secrets or Configmaps Mar 30, 2021
@whynowy whynowy merged commit 9340b98 into argoproj:master Mar 30, 2021
@whynowy whynowy deleted the fix branch March 30, 2021 21:28
whynowy added a commit that referenced this pull request Mar 30, 2021
* fix: fix: Trim newline of the content read from Secrets or Configmaps

Signed-off-by: Derek Wang <[email protected]>
juliev0 pushed a commit to juliev0/argo-events that referenced this pull request Mar 29, 2022
…oproj#1146)

* fix: fix: Trim newline of the content read from Secrets or Configmaps

Signed-off-by: Derek Wang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem with setting SQS queue Trigger source git doesn't work when private repo via HTTPS URL.
2 participants