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

Move workflow stuff out of pkg #315

Merged
merged 13 commits into from
Oct 7, 2020

Conversation

mmlb
Copy link
Contributor

@mmlb mmlb commented Oct 1, 2020

Description

Move workflow types and funcs out of pkg/ and into its own package. Also cleaned up some of the API and added some more validation while I'm here.

Why is this needed

Helps address #300

How Has This Been Tested?

go test passes.

How are existing users impacted? What migration steps/scripts do we need?

Low impact. A bc-break is occurring here, but its in internalish code and no user is expected to be using this code. If they are gofmt -w -r 'p.ParseYAML(b) -> p.Parse(b)' . and removing the call to ValidateTemplate is all thats needed.

Checklist:

I have:

  • updated the documentation and/or roadmap (if required)
  • added unit or e2e tests
  • provided instructions on how to upgrade

@mmlb mmlb requested a review from gianarb October 1, 2020 20:58
@mmlb mmlb force-pushed the move-workflow-stuff-out-of-pkg branch 3 times, most recently from a32aa8a to e0d3a62 Compare October 2, 2020 16:16
@codecov
Copy link

codecov bot commented Oct 2, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@1009dc3). Click here to learn what that means.
The diff coverage is 95.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #315   +/-   ##
=========================================
  Coverage          ?   23.79%           
=========================================
  Files             ?       14           
  Lines             ?     1244           
  Branches          ?        0           
=========================================
  Hits              ?      296           
  Misses            ?      928           
  Partials          ?       20           
Impacted Files Coverage Δ
http-server/http_handlers.go 6.68% <ø> (ø)
workflow/template_validator.go 95.00% <95.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1009dc3...80db407. Read the comment docs.

@mmlb mmlb force-pushed the move-workflow-stuff-out-of-pkg branch from e0d3a62 to 6ecf644 Compare October 2, 2020 16:18
@mmlb mmlb mentioned this pull request Oct 2, 2020
@mmlb mmlb requested a review from detiber October 2, 2020 16:34
@gianarb
Copy link
Contributor

gianarb commented Oct 2, 2020

Is it fixing this as well #317 ?

@mmlb mmlb added the breaking-change Denotes a PR that introduces potentially breaking changes that require user action. label Oct 2, 2020
@mmlb
Copy link
Contributor Author

mmlb commented Oct 2, 2020

@gianarb no? I dont see where #317 is valid in non-test code. Every error is returned from TinkDB.CreateTemplate which is checked and returned to callers.

detiber
detiber previously approved these changes Oct 5, 2020
Copy link
Contributor

@detiber detiber left a comment

Choose a reason for hiding this comment

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

These changes look good to me, down with pkg and thank you for internalizing the template validation.

@mmlb mmlb added the ready-to-merge Signal to Mergify to merge the PR. label Oct 5, 2020
@mmlb
Copy link
Contributor Author

mmlb commented Oct 5, 2020

These changes look good to me,

Thanks for the review.

down with pkg

soon it shall be no more.

and thank you for internalizing the template validation.

👍

@mmlb
Copy link
Contributor Author

mmlb commented Oct 5, 2020

I'll leave this up for @gianarb til tomorrow.

gianarb
gianarb previously approved these changes Oct 7, 2020
mmlb added 13 commits October 7, 2020 09:07
pkg is really just another name for utils and thats a bad pattern to have.
We should have small concise packages over large expansive ones.

Signed-off-by: Manuel Mendez <[email protected]>
Every caller of ParseYAML always calls ValidateTemplate right after. Why
would we ever want to allow an invalid Template anyway?

Signed-off-by: Manuel Mendez <[email protected]>
There aren't any other data formats now or in the forseeable future.

Signed-off-by: Manuel Mendez <[email protected]>
The if check should have been:

```go
if err == nil && test.expectedError {
```

otherwise the `err != nil` short-circuits and `test.expectedError` is
never checked.

But there's no real reason to check the value of `err` since we can just
assert that it matches what we expected instead.

Signed-off-by: Manuel Mendez <[email protected]>
This was changed when validation was added when the code was changed
from fmt.Errorf -> errors.New, but errors.Errorf should have been used
instead.

Signed-off-by: Manuel Mendez <[email protected]>
This way we can group them by what they apply to.

Signed-off-by: Manuel Mendez <[email protected]>
No need to have unique strings, and avoids needing another unique long
string for templates if we want to continue with the old pattern.

Signed-off-by: Manuel Mendez <[email protected]>
Makes no sense to add template here too, thats all the objects with name
paramenter...

Signed-off-by: Manuel Mendez <[email protected]>
golangci-lint was printing the following warning:
WARN [runner/nolint] Found unknown linters in //nolint directives: staticcheck sa1019 we will do it later

Signed-off-by: Manuel Mendez <[email protected]>
@mmlb mmlb dismissed stale reviews from gianarb and detiber via 80db407 October 7, 2020 13:08
@mmlb mmlb force-pushed the move-workflow-stuff-out-of-pkg branch from 6ecf644 to 80db407 Compare October 7, 2020 13:08
@mergify mergify bot merged commit 30f4302 into tinkerbell:master Oct 7, 2020
@mmlb mmlb deleted the move-workflow-stuff-out-of-pkg branch October 20, 2020 20:37
@mmlb mmlb removed the ready-to-merge Signal to Mergify to merge the PR. label Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Denotes a PR that introduces potentially breaking changes that require user action.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants