-
Notifications
You must be signed in to change notification settings - Fork 18
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
run vet and lint in CI #136
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package docs | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
@@ -12,39 +11,30 @@ import ( | |
|
||
func TestEnsurePorterRepository(t *testing.T) { | ||
t.Run("has local repo", func(t *testing.T) { | ||
tmp, err := ioutil.TempDir("", "porter-docs-test") | ||
require.NoError(t, err) | ||
defer os.RemoveAll(tmp) | ||
tmp := t.TempDir() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So much cleaner! 💯 |
||
|
||
resolvedPath, err := ensurePorterRepositoryIn(tmp, "") | ||
require.NoError(t, err) | ||
require.Equal(t, tmp, resolvedPath) | ||
}) | ||
|
||
t.Run("missing local repo", func(t *testing.T) { | ||
tmp, err := ioutil.TempDir("", "porter-docs-test") | ||
require.NoError(t, err) | ||
defer os.RemoveAll(tmp) | ||
tmp := t.TempDir() | ||
|
||
resolvedPath, err := ensurePorterRepositoryIn("missing", tmp) | ||
require.NoError(t, err) | ||
require.Equal(t, tmp, resolvedPath) | ||
}) | ||
|
||
t.Run("local repo unset", func(t *testing.T) { | ||
tmp, err := ioutil.TempDir("", "porter-docs-test") | ||
require.NoError(t, err) | ||
defer os.RemoveAll(tmp) | ||
|
||
tmp := t.TempDir() | ||
resolvedPath, err := ensurePorterRepositoryIn("", tmp) | ||
require.NoError(t, err) | ||
require.Equal(t, tmp, resolvedPath) | ||
}) | ||
|
||
t.Run("empty default path clones repo", func(t *testing.T) { | ||
tmp, err := ioutil.TempDir("", "porter-docs-test") | ||
require.NoError(t, err) | ||
defer os.RemoveAll(tmp) | ||
tmp := t.TempDir() | ||
|
||
resolvedPath, err := ensurePorterRepositoryIn("", tmp) | ||
require.NoError(t, err) | ||
|
@@ -55,9 +45,7 @@ func TestEnsurePorterRepository(t *testing.T) { | |
}) | ||
|
||
t.Run("changes in default path are reset", func(t *testing.T) { | ||
tmp, err := ioutil.TempDir("", "porter-docs-test") | ||
require.NoError(t, err) | ||
defer os.RemoveAll(tmp) | ||
tmp := t.TempDir() | ||
|
||
repoPath, err := ensurePorterRepositoryIn("", tmp) | ||
require.NoError(t, err) | ||
|
@@ -67,7 +55,7 @@ func TestEnsurePorterRepository(t *testing.T) { | |
require.NoError(t, os.Remove(readme)) | ||
|
||
// Make sure rerunning resets the change | ||
repoPath, err = ensurePorterRepositoryIn("", tmp) | ||
_, err = ensurePorterRepositoryIn("", tmp) | ||
require.NoError(t, err) | ||
require.FileExists(t, readme) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Default Config | ||
checks = ["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-ST1023", "-ST1005"] | ||
initialisms = ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS"] | ||
http_status_code_whitelist = ["200", "400", "404", "500"] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is always confusing! 😅
I am pretty sure that the json tag does not support squash or inline. Embedded fields are always inlined and do not require a json entry at all.
I'm pretty sure that the json tag just ignores the
,inline
anyway but it may be more clear (so that people aren't tricked into thinking it is doing anything) if we remove that json tag entirely.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are right on the embedded fields are always inlined and do not require a json entry when used with
encoding/json
, the standard library.However, it looks like the
controller-gen
requires it to be specified. I found the same `json:,inline; in their doc as well. https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.htmlThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh I wonder what they are doing that it's used? 🤔
Thanks for checking, I'll try to remember this the next time I'm tempted to remove it!