-
Notifications
You must be signed in to change notification settings - Fork 36
Refactor Build for Go #753
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
Draft
raykroeker
wants to merge
1
commit into
main
Choose a base branch
from
raykroeker/006-cni-productization-buildfiles
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
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 hidden or 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 hidden or 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,4 +1,6 @@ | ||
| **/.idea | ||
| *.iml | ||
| **/*.swp | ||
| *-test.json | ||
| *-cover.out | ||
| target/ |
This file contains hidden or 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,39 @@ | ||
|
|
||
| # go-build all packages into target binaries | ||
| go-build: \ | ||
| (go-build-pkg "linkerd2-cni-plugin" "cni-plugin") \ | ||
| (go-build-pkg "linkerd2-proxy-init" "proxy-init") | ||
|
|
||
| # go-fmt-check the root directory for all fmt errors printing the result; | ||
| # and exiting non-zero if formatting issues exist. | ||
| go-fmt-check: | ||
| out=$(gofmt -e -d .) ; [ -z "$out" ] || (echo "$out" ; exit 1) | ||
|
|
||
| # go-lint all packages | ||
| go-lint *flags: \ | ||
| (go-lint-pkg "cni-plugin" flags) \ | ||
| (go-lint-pkg "pkg" flags) \ | ||
| (go-lint-pkg "proxy-init" flags) | ||
|
|
||
| # go-test all packages w/ gotestsum and write results to ${pkg}-test.json | ||
| # | ||
| # cni-plugin is not tested here as it only include integration tests | ||
| go-test: \ | ||
| (go-test-pkg "pkg") \ | ||
| (go-test-pkg "proxy-init") | ||
|
|
||
| # go-build runs go build against a specific package outputting to a specific | ||
| # target binary (no optional flags) | ||
| go-build-pkg out pkg: | ||
| go build -o target/{{ out }} ./{{ pkg }} | ||
|
|
||
| # go-lint-pkg runs go lint against a specific package with optional flags | ||
| go-lint-pkg pkg *flags: | ||
| golangci-lint run ./{{ pkg }}/... {{ flags }} | ||
|
|
||
| # go-test runs gotestsum against a specific package with optional flags writing | ||
| # the output/result to ${pkg}-test.json and coverage detail to ${pkg}-cover.out | ||
| go-test-pkg pkg *flags: | ||
| gotestsum --jsonfile {{ pkg }}-test.json -- \ | ||
| -coverprofile {{ pkg }}-cover.out \ | ||
| -race -v -mod=readonly -v ./{{ pkg }}/... {{ flags }} |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -274,7 +274,7 @@ func (fc FirewallConfiguration) addRulesForIgnoredSubnets(chainName string, comm | |
| func makeMultiportDestinations(portsToIgnore []string) [][]string { | ||
| destinationSlices := make([][]string, 0) | ||
| destinationPortCount := 0 | ||
| if portsToIgnore == nil || len(portsToIgnore) < 1 { | ||
| if len(portsToIgnore) < 1 { | ||
| return destinationSlices | ||
| } | ||
| destinations := make([]string, 0) | ||
|
|
@@ -422,9 +422,9 @@ func (fc FirewallConfiguration) makeRedirectChainToPortBasedOnDestinationPort(ch | |
| "--comment", formatComment(comment)) | ||
| } | ||
|
|
||
| func (fc FirewallConfiguration) makeJumpFromChainToAnotherForAllProtocols(chainName string, targetChain string, comment string, delete bool) *exec.Cmd { | ||
| func (fc FirewallConfiguration) makeJumpFromChainToAnotherForAllProtocols(chainName string, targetChain string, comment string, deleteChain bool) *exec.Cmd { | ||
| action := "-A" | ||
| if delete { | ||
| if deleteChain { | ||
|
Author
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.
|
||
| action = "-D" | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -48,7 +48,10 @@ func TestParsePortRange(t *testing.T) { | |
| for _, tt := range tests { | ||
| t.Run(tt.input, func(t *testing.T) { | ||
| check, _ := ParsePortRange(tt.input) | ||
| reflect.DeepEqual(tt.expected, check) | ||
| if !reflect.DeepEqual(tt.expected, check) { | ||
| t.Fatalf("expected port range does not match check '%v'<>'%v'", | ||
| tt.expected, check) | ||
| } | ||
|
Author
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. Adding lint checks to |
||
| }) | ||
| } | ||
| } | ||
|
|
||
Oops, something went wrong.
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.
portsToIgnore == nilis a lint triger.