Skip to content

Fixed regex for matching size, localhost. Error logging in defer call #3679

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

Closed
wants to merge 3 commits into from

Conversation

saisrivathsa
Copy link

@saisrivathsa saisrivathsa commented Mar 31, 2021

  • The regexes used are not valid regular expressions and the test cases pass with the changed regex.
  • Error handling while using defer and go commands

@saisrivathsa saisrivathsa changed the title Fixed regex for matching size and localhost Fixed regex for matching size, localhost. Error logging in defer call Mar 31, 2021
@csweichel
Copy link
Contributor

csweichel commented Apr 6, 2021

/werft run

👍 started the job as gitpod-build-main-fork.1

Copy link
Contributor

@corneliusludmann corneliusludmann left a comment

Choose a reason for hiding this comment

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

Hi @saisrivathsa,

Thanks for your contribution! Looks good!

Could you do me a favor and consider the following two things:

First: Would you mind squashing/renaming your commits to something more meaningful? I would suggest something like this:

  • One commit for the defer close functions with a commit message like Improve error handling in defer function calls
  • One commit for the regex changes: Fix regex strings in gitpod-cli and ws-daemon

Second: Would you mind adding the change of my comment to the size.go file?

Thanks!

@@ -31,7 +31,7 @@ const (
)

var (
sizeRegexp = regexp.MustCompile("(\\d+)(k|m|g|t)?")
sizeRegexp = regexp.MustCompile(`(\d+)(k|m|g|t)?`)
Copy link
Contributor

Choose a reason for hiding this comment

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

While we are at it, I would also suggest the following change:

Suggested change
sizeRegexp = regexp.MustCompile(`(\d+)(k|m|g|t)?`)
sizeRegexp = regexp.MustCompile(`^(\d+)(k|m|g|t)?$`)

That would also fix this one:

// This test should fail but doesn't because match somehow matches the regexp
// {"-42m", 0, quota.ErrInvalidSize},

Would be great if you could then make those changes to the tests as well:

diff --git a/components/ws-daemon/pkg/quota/size_test.go b/components/ws-daemon/pkg/quota/size_test.go
index cc21ae25..68b3b822 100644
--- a/components/ws-daemon/pkg/quota/size_test.go
+++ b/components/ws-daemon/pkg/quota/size_test.go
@@ -23,8 +23,8 @@ func TestParseSize(t *testing.T) {
                {"42m", 42 * quota.Megabyte, nil},
                {"42g", 42 * quota.Gigabyte, nil},
                {"42t", 42 * quota.Terabyte, nil},
-               // This test should fail but doesn't because match somehow matches the regexp
-               // {"-42m", 0, quota.ErrInvalidSize},
+               {"-42m", 0, quota.ErrInvalidSize},
+               {"x42mx", 0, quota.ErrInvalidSize},
                {"abc", 0, quota.ErrInvalidSize},
                {"99999999999999999999999999999999999999999999999999999999999999999999999999999999", 0, quota.ErrInvalidSize},
        }

What do you think?

@gtsiolis
Copy link
Contributor

gtsiolis commented Nov 25, 2021

@saisrivathsa let us know if you up for picking up this and addressing the comments in #3679 (review). You also need to sign a Contributor License Agreement (CLA) before merging this. Cc @meysholdt

@gtsiolis gtsiolis added the do-not-merge/cla-pending CLA has not been signed label Nov 25, 2021
@meysholdt
Copy link
Member

Hi @saisrivathsa! I've reached out to you via email about the CLA.

@gtsiolis gtsiolis added team: IDE team: workspace Issue belongs to the Workspace team labels Dec 13, 2021
@meysholdt
Copy link
Member

hi @saisrivathsa ! Thank you for your contribution. Before we can merge it, we'll need to sign a CLA. I've sent you an email about the next steps.

@kylos101 kylos101 removed the team: workspace Issue belongs to the Workspace team label Feb 2, 2022
@iQQBot iQQBot removed the team: IDE label Feb 11, 2022
@meysholdt
Copy link
Member

hi @saisrivathsa, we've updated our CLA process. Maybe it's easier for you now. Can you please sign our CLA via this DocuSign form? If there are any questions, you can reach me via moritz@gitpod.io.

@reviewpad reviewpad bot mentioned this pull request Apr 4, 2023
9 tasks
@gtsiolis
Copy link
Contributor

Closing this for now. 📕

Looping below corresponding teams below if any of the changes here make sense to pick up in separate PRs.
Cc @lucasvaltl + @kylos101 as @gitpod-io/engineering-workspace is code owner for changes here.
Cc @laushinka + @loujaybee as @gitpod-io/engineering-ide is code owner for changes here.

@gtsiolis gtsiolis closed this May 23, 2023
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.

8 participants