Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Fix golangci issues on master branch #78

Merged
merged 5 commits into from
Aug 13, 2020
Merged

Fix golangci issues on master branch #78

merged 5 commits into from
Aug 13, 2020

Conversation

edwardstudy
Copy link
Member

@edwardstudy edwardstudy commented Aug 11, 2020

A chore.

Added TODO about errchecking on BindFlag.

@edwardstudy edwardstudy requested review from manno and viovanov and removed request for manno August 11, 2020 03:35
@@ -205,7 +205,10 @@ func (f *Config) CreateValidationWebhookServerConfig(ctx context.Context, webhoo
}
}
ctxlog.Debugf(ctx, "Creating validation webhook config '%s'", config.Name)
f.client.Delete(ctx, config)
err := f.client.Delete(ctx, config)
if err != nil && !apierrors.IsNotFound(err) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if err != nil && !apierrors.IsNotFound(err) {
if err := f.client.Delete(ctx, config); err != nil && !apierrors.IsNotFound(err) {

@@ -251,7 +254,10 @@ func (f *Config) CreateMutationWebhookServerConfig(ctx context.Context, webhooks
}

ctxlog.Debugf(ctx, "Creating mutating webhook config '%s'", config.Name)
f.client.Delete(ctx, &config)
err := f.client.Delete(ctx, &config)
if err != nil && !apierrors.IsNotFound(err) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if err != nil && !apierrors.IsNotFound(err) {
if err := f.client.Delete(ctx, &config); err != nil && !apierrors.IsNotFound(err) {

@@ -27,7 +27,10 @@ func newLogger(level string, options ...zap.Option) *zap.Logger {
}

l := zap.DebugLevel
l.Set(level)
err := l.Set(level)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if err != nil {
if err := l.Set(level); err != nil {

@@ -112,7 +112,11 @@ func (ev Event) debugJSON(ctx context.Context, objectInfo interface{}) {

// treat JSON data as a string map and extract message
var result map[string]string
json.Unmarshal([]byte(jsonData), &result)
err := json.Unmarshal([]byte(jsonData), &result)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if err != nil {
if err := json.Unmarshal([]byte(jsonData), &result); err != nil {

pkg/cmd/argtoenv.go Outdated Show resolved Hide resolved
pkg/crd/crd.go Outdated
@@ -68,7 +68,7 @@ func ApplyCRD(ctx context.Context, client extv1client.ApiextensionsV1beta1Interf
}

// WaitForCRDReady blocks until the CRD is ready.
func WaitForCRDReady(ctx context.Context, client extv1client.ApiextensionsV1beta1Interface, crdName string) error {
func WaitForCRDReady(ctx context.Context, client extv1client.ApiextensionsV1beta1Interface, crdName string) error { // nolint:interfacer
Copy link
Member

Choose a reason for hiding this comment

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

Does anyone intend to use the output of interfacer? Maybe we drop that linter

Copy link
Member Author

@edwardstudy edwardstudy Aug 12, 2020

Choose a reason for hiding this comment

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

@manno I had same feeling.
BTW, interface is out of maintain: https://github.com/mvdan/interfacer

Deprecated: A tool that suggests interfaces is prone to bad suggestions, so its usefulness in real code is limited.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, added a commit to drop it

@edwardstudy edwardstudy requested review from manno and mudler August 12, 2020 03:10
@@ -112,7 +112,10 @@ func (ev Event) debugJSON(ctx context.Context, objectInfo interface{}) {

// treat JSON data as a string map and extract message
var result map[string]string
json.Unmarshal([]byte(jsonData), &result)
if err := json.Unmarshal([]byte(jsonData), &result); err != nil {
return
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it would be helpful to print the error to debug if it fails?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe it was silent for a reason, but then a few lines done it does print a debug msg. So why not here, too.

@manno manno requested a review from mudler August 13, 2020 13:33
@manno manno merged commit bc38d82 into master Aug 13, 2020
@manno manno deleted the ed/fix-lint branch August 13, 2020 13:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants