diff --git a/pkg/app/piped/controller/controllermetrics/metrics.go b/pkg/app/piped/controller/controllermetrics/metrics.go index d2f8c0e001..d42cb7feac 100644 --- a/pkg/app/piped/controller/controllermetrics/metrics.go +++ b/pkg/app/piped/controller/controllermetrics/metrics.go @@ -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 ( diff --git a/pkg/app/piped/driftdetector/cloudrun/detector.go b/pkg/app/piped/driftdetector/cloudrun/detector.go index a3fb460a3e..d707570f40 100644 --- a/pkg/app/piped/driftdetector/cloudrun/detector.go +++ b/pkg/app/piped/driftdetector/cloudrun/detector.go @@ -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] } diff --git a/pkg/app/piped/platformprovider/terraform/terraform.go b/pkg/app/piped/platformprovider/terraform/terraform.go index 2b9679f38f..8a497d916b 100644 --- a/pkg/app/piped/platformprovider/terraform/terraform.go +++ b/pkg/app/piped/platformprovider/terraform/terraform.go @@ -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 @@ -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) @@ -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 } @@ -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 diff --git a/pkg/app/server/grpcapi/grpcapi_test.go b/pkg/app/server/grpcapi/grpcapi_test.go index 58def4f62b..19159b3617 100644 --- a/pkg/app/server/grpcapi/grpcapi_test.go +++ b/pkg/app/server/grpcapi/grpcapi_test.go @@ -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) { diff --git a/pkg/model/application_live_state.go b/pkg/model/application_live_state.go index 933797b2d1..077bbea2d3 100644 --- a/pkg/model/application_live_state.go +++ b/pkg/model/application_live_state.go @@ -68,7 +68,6 @@ func (s *ApplicationLiveStateSnapshot) DetermineAppHealthStatus() { case ApplicationKind_CLOUDRUN: s.determineCloudRunAppHealthStatus() } - return } func (s *ApplicationLiveStateSnapshot) determineKubernetesAppHealthStatus() { diff --git a/pkg/model/project.go b/pkg/model/project.go index f21bc48827..d7752bbb3d 100644 --- a/pkg/model/project.go +++ b/pkg/model/project.go @@ -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.