Skip to content

Commit

Permalink
Fix part of lint/go errors (goimports, staticcheck, gosimple) (#4622)
Browse files Browse the repository at this point in the history
* Fix lint/go errors (goimport)

Signed-off-by: karamaru-alpha <[email protected]>

* Fix lint/go errors (staticcheck)

Signed-off-by: karamaru-alpha <[email protected]>

* Fix lint/go errors (gosimple)

Signed-off-by: karamaru-alpha <[email protected]>

* Fix lint/go errors (gosimple)

Signed-off-by: karamaru-alpha <[email protected]>

* Fix return error by function

Signed-off-by: karamaru-alpha <[email protected]>

---------

Signed-off-by: karamaru-alpha <[email protected]>
  • Loading branch information
karamaru-alpha authored Oct 19, 2023
1 parent 4ed62fb commit dcb3da1
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 44 deletions.
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 @@ func (t *Terraform) Init(ctx context.Context, w io.Writer) error {
"init",
}
args = append(args, t.makeCommonCommandArgs()...)
for _, f := range t.options.initFlags {
args = append(args, f)
}
args = append(args, t.options.initFlags...)

cmd := exec.CommandContext(ctx, t.execPath, args...)
cmd.Dir = t.dir
Expand Down Expand Up @@ -278,9 +276,7 @@ func (t *Terraform) Plan(ctx context.Context, w io.Writer) (PlanResult, error) {
"-detailed-exitcode",
}
args = append(args, t.makeCommonCommandArgs()...)
for _, f := range t.options.planFlags {
args = append(args, f)
}
args = append(args, t.options.planFlags...)

var buf bytes.Buffer
stdout := io.MultiWriter(w, &buf)
Expand Down Expand Up @@ -316,9 +312,7 @@ func (t *Terraform) makeCommonCommandArgs() (args []string) {
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...)
return
}

Expand Down Expand Up @@ -398,9 +392,7 @@ func (t *Terraform) Apply(ctx context.Context, w io.Writer) error {
"-input=false",
}
args = append(args, t.makeCommonCommandArgs()...)
for _, f := range t.options.applyFlags {
args = append(args, f)
}
args = append(args, t.options.applyFlags...)

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 @@ func (p *ProjectStaticUser) Auth(username, password string) error {

// RedactSensitiveData redacts sensitive data.
func (p *ProjectSSOConfig) RedactSensitiveData() {
if p.Github != nil {
p.Github.RedactSensitiveData()
}
if p.Google != nil {
if p.Github == nil {
return
}
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
}
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
}
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
}
return nil
return p.Github.Decrypt(decrypter)
}

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

0 comments on commit dcb3da1

Please sign in to comment.