-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add linter; Expose LB API Client (#20)
* export lb api client Signed-off-by: Tyler Auerbeck <[email protected]> * add .golangci.yml Signed-off-by: Tyler Auerbeck <[email protected]> * New lint, New Problems Signed-off-by: Tyler Auerbeck <[email protected]> --------- Signed-off-by: Tyler Auerbeck <[email protected]> Co-authored-by: Tyler Auerbeck <[email protected]>
- Loading branch information
1 parent
390602f
commit f5b2a45
Showing
18 changed files
with
152 additions
and
31 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
linters-settings: | ||
goimports: | ||
local-prefixes: go.infratographer.com/loadbalanceroperator | ||
|
||
linters: | ||
enable: | ||
# default linters | ||
- deadcode | ||
- errcheck | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- staticcheck | ||
- structcheck | ||
- typecheck | ||
- unused | ||
- varcheck | ||
|
||
# additional linters | ||
- bodyclose | ||
- gocritic | ||
- gocyclo | ||
- goerr113 | ||
- gofmt | ||
- goimports | ||
- gomnd | ||
- govet | ||
- misspell | ||
- noctx | ||
- stylecheck | ||
- whitespace | ||
- wsl | ||
|
||
issues: | ||
exclude: | ||
# Default excludes from `golangci-lint run --help` with EXC0002 removed | ||
# EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok | ||
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked | ||
# EXC0002 golint: Annoying issue about not having a comment. The rare codebase has such comments | ||
# - (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form) | ||
# EXC0003 golint: False positive when tests are defined in package 'test' | ||
- func name will be used as test\.Test.* by other packages, and that stutters; consider calling this | ||
# EXC0004 govet: Common false positives | ||
- (possible misuse of unsafe.Pointer|should have signature) | ||
# EXC0005 staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore | ||
- ineffective break statement. Did you mean to break out of the outer loop | ||
# EXC0006 gosec: Too many false-positives on 'unsafe' usage | ||
- Use of unsafe calls should be audited | ||
# EXC0007 gosec: Too many false-positives for parametrized shell calls | ||
- Subprocess launch(ed with variable|ing should be audited) | ||
# EXC0008 gosec: Duplicated errcheck checks | ||
- (G104|G307) | ||
# EXC0009 gosec: Too many issues in popular repos | ||
- (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less) | ||
# EXC0010 gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)' | ||
- Potential file inclusion via variable | ||
exclude-use-default: false |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package dataplaneapi provides a client for interacting with the haproxy dataplane api | ||
package dataplaneapi |
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,3 @@ | ||
// Package manager provides core functionality of the load balancer manager for | ||
// processing messages and managing load balancers | ||
package manager |
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,34 @@ | ||
package manager | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
) | ||
|
||
var ( | ||
// errInvalidLBID is returned when an invalid load balancer ID is provided | ||
errInvalidLBID = errors.New("optional lbID param must be not set or set to a singular loadbalancer ID") | ||
|
||
// errFrontendSectionLabelFailure is returned when a frontend section cannot be created | ||
errFrontendSectionLabelFailure = errors.New("failed to create frontend section with label") | ||
|
||
// errUseBackendFailure is returned when the use_backend attr cannot be applied to a frontend | ||
errUseBackendFailure = errors.New("failed to create frontend attr use_backend") | ||
|
||
// errFrontendBindFailure is returned when the bind attribute cannot be applied to a frontend | ||
errFrontendBindFailure = errors.New("failed to create frontend attr bind") | ||
|
||
// errBackendSectionLabelFailure is returned when a backend section cannot be created | ||
errBackendSectionLabelFailure = errors.New("failed to create section backend with label") | ||
|
||
// errBackendServerFailure is returned when a server cannot be applied to a backend | ||
errBackendServerFailure = errors.New("failed to add backend attr server: ") | ||
) | ||
|
||
func newLabelError(label string, err error, labelErr error) error { | ||
return fmt.Errorf("%w %q: %v", err, label, labelErr) | ||
} | ||
|
||
func newAttrError(err error, attrErr error) error { | ||
return fmt.Errorf("%w: %v", err, attrErr) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package mock provides mock implementations of the lb haproxy manager | ||
package mock |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Package lbapi provides a client for interacting with the load balancer api | ||
package lbapi |
Oops, something went wrong.