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

Fix part of lint/go errors (goimports, staticcheck, gosimple) #4622

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/app/piped/controller/controllermetrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
package controllermetrics

import (
"github.com/pipe-cd/pipecd/pkg/model"
"github.com/prometheus/client_golang/prometheus"

"github.com/pipe-cd/pipecd/pkg/model"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/piped/driftdetector/cloudrun/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func makeSyncState(r *provider.DiffResult, commit string) model.ApplicationSyncS
}
}

shortReason := fmt.Sprintf("The service manifest doesn't be synced")
shortReason := "The service manifest doesn't be synced"
if len(commit) >= 7 {
commit = commit[:7]
}
Expand Down
16 changes: 4 additions & 12 deletions pkg/app/piped/platformprovider/terraform/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@
"init",
}
args = append(args, t.makeCommonCommandArgs()...)
for _, f := range t.options.initFlags {
args = append(args, f)
}
args = append(args, t.options.initFlags...)

Check warning on line 123 in pkg/app/piped/platformprovider/terraform/terraform.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/piped/platformprovider/terraform/terraform.go#L123

Added line #L123 was not covered by tests

cmd := exec.CommandContext(ctx, t.execPath, args...)
cmd.Dir = t.dir
Expand Down Expand Up @@ -278,9 +276,7 @@
"-detailed-exitcode",
}
args = append(args, t.makeCommonCommandArgs()...)
for _, f := range t.options.planFlags {
args = append(args, f)
}
args = append(args, t.options.planFlags...)

Check warning on line 279 in pkg/app/piped/platformprovider/terraform/terraform.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/piped/platformprovider/terraform/terraform.go#L279

Added line #L279 was not covered by tests

var buf bytes.Buffer
stdout := io.MultiWriter(w, &buf)
Expand Down Expand Up @@ -316,9 +312,7 @@
for _, f := range t.options.varFiles {
args = append(args, fmt.Sprintf("-var-file=%s", f))
}
for _, f := range t.options.sharedFlags {
args = append(args, f)
}
args = append(args, t.options.sharedFlags...)

Check warning on line 315 in pkg/app/piped/platformprovider/terraform/terraform.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/piped/platformprovider/terraform/terraform.go#L315

Added line #L315 was not covered by tests
return
}

Expand Down Expand Up @@ -398,9 +392,7 @@
"-input=false",
}
args = append(args, t.makeCommonCommandArgs()...)
for _, f := range t.options.applyFlags {
args = append(args, f)
}
args = append(args, t.options.applyFlags...)

Check warning on line 395 in pkg/app/piped/platformprovider/terraform/terraform.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/piped/platformprovider/terraform/terraform.go#L395

Added line #L395 was not covered by tests

cmd := exec.CommandContext(ctx, t.execPath, args...)
cmd.Dir = t.dir
Expand Down
5 changes: 3 additions & 2 deletions pkg/app/server/grpcapi/grpcapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ import (
"fmt"
"testing"

"github.com/pipe-cd/pipecd/pkg/datastore"
"github.com/pipe-cd/pipecd/pkg/filestore"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/pipe-cd/pipecd/pkg/datastore"
"github.com/pipe-cd/pipecd/pkg/filestore"
)

func TestGRPCStoreError(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion pkg/model/application_live_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func (s *ApplicationLiveStateSnapshot) DetermineAppHealthStatus() {
case ApplicationKind_CLOUDRUN:
s.determineCloudRunAppHealthStatus()
}
return
}

func (s *ApplicationLiveStateSnapshot) determineKubernetesAppHealthStatus() {
Expand Down
42 changes: 15 additions & 27 deletions pkg/model/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,51 +209,39 @@

// RedactSensitiveData redacts sensitive data.
func (p *ProjectSSOConfig) RedactSensitiveData() {
if p.Github != nil {
p.Github.RedactSensitiveData()
}
if p.Google != nil {
if p.Github == nil {
return

Check warning on line 213 in pkg/model/project.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/project.go#L213

Added line #L213 was not covered by tests
}
p.Github.RedactSensitiveData()
}

// Update updates ProjectSSOConfig with given data.
func (p *ProjectSSOConfig) Update(sso *ProjectSSOConfig) error {
p.Provider = sso.Provider
if sso.Github != nil {
if p.Github == nil {
p.Github = &ProjectSSOConfig_GitHub{}
}
if err := p.Github.Update(sso.Github); err != nil {
return err
}
if sso.Github == nil {
return nil

Check warning on line 222 in pkg/model/project.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/project.go#L222

Added line #L222 was not covered by tests
}
if sso.Google != nil {

if p.Github == nil {
p.Github = &ProjectSSOConfig_GitHub{}
}
return nil
return p.Github.Update(sso.Github)
}

// Encrypt encrypts sensitive data in ProjectSSOConfig.
func (p *ProjectSSOConfig) Encrypt(encrypter encrypter) error {
if p.Github != nil {
if err := p.Github.Encrypt(encrypter); err != nil {
return err
}
}
if p.Google != nil {
if p.Github == nil {
return nil

Check warning on line 234 in pkg/model/project.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/project.go#L234

Added line #L234 was not covered by tests
}
return nil
return p.Github.Encrypt(encrypter)
}

// Decrypt decrypts encrypted data in ProjectSSOConfig.
func (p *ProjectSSOConfig) Decrypt(decrypter decrypter) error {
if p.Github != nil {
if err := p.Github.Decrypt(decrypter); err != nil {
return err
}
}
if p.Google != nil {
if p.Github == nil {
return nil

Check warning on line 242 in pkg/model/project.go

View check run for this annotation

Codecov / codecov/patch

pkg/model/project.go#L242

Added line #L242 was not covered by tests
}
return nil
return p.Github.Decrypt(decrypter)
}

// GenerateAuthCodeURL generates an auth URL for the specified configuration.
Expand Down
Loading