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

Bump golangci-lint to v1.46.2 #595

Merged
merged 2 commits into from
May 18, 2022
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 4 additions & 5 deletions cloud/cpi_cmd_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,10 @@ type CPICmdRunner interface {
}

type cpiCmdRunner struct {
cmdRunner boshsys.CmdRunner
cpi CPI
logger boshlog.Logger
apiVersion int
logTag string
cmdRunner boshsys.CmdRunner
cpi CPI
logger boshlog.Logger
logTag string
}

func NewCPICmdRunner(
Expand Down
8 changes: 3 additions & 5 deletions cmd/clean_up.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewCleanUpCmd(ui boshui.UI, director boshdir.Director) CleanUpCmd {

func (c CleanUpCmd) Run(opts CleanUpOpts) error {

if opts.DryRun == false {
if !opts.DryRun {
err := c.ui.AskForConfirmation()
if err != nil {
return err
Expand Down Expand Up @@ -77,17 +77,15 @@ func (c CleanUpCmd) PrintCleanUpTable(resp boshdir.CleanUp) {
orphanedVmRows(resp.OrphanedVMs),
}

for i, _ := range titles {
for i := range titles {
table := boshtbl.Table{
Title: titles[i],
Header: headers[i],
SortBy: []boshtbl.ColumnSort{
{Column: 0, Asc: true},
},
}
for _, r := range rows[i] {
table.Rows = append(table.Rows, r)
}
table.Rows = append(table.Rows, rows[i]...)
c.ui.PrintTable(table)
}
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/config/fs_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ var _ = Describe("FSConfig", func() {
})

It("returns creds with username/password if environment is found and basic creds are set", func() {
updatedConfig, err := config.AliasEnvironment("url", "alias", "") //nolint:ineffassign
updatedConfig, err := config.AliasEnvironment("url", "alias", "") //nolint:ineffassign,staticcheck
Expect(err).ToNot(HaveOccurred())

updatedConfig = config.SetCredentials("url", Creds{Client: "user", ClientSecret: "pass"})
Expand All @@ -410,7 +410,7 @@ var _ = Describe("FSConfig", func() {
})

It("returns creds with token if environment is found and token is set", func() {
updatedConfig, err := config.AliasEnvironment("url", "alias", "") //nolint:ineffassign
updatedConfig, err := config.AliasEnvironment("url", "alias", "") //nolint:ineffassign,staticcheck
Expect(err).ToNot(HaveOccurred())

updatedConfig = config.SetCredentials("url", Creds{AccessToken: "access", AccessTokenType: "access-type", RefreshToken: "token"})
Expand All @@ -433,7 +433,7 @@ var _ = Describe("FSConfig", func() {
})

It("returns creds for alias if environment is found and token is set", func() {
updatedConfig, err := config.AliasEnvironment("url", "alias", "") //nolint:ineffassign
updatedConfig, err := config.AliasEnvironment("url", "alias", "") //nolint:ineffassign,staticcheck
Expect(err).ToNot(HaveOccurred())

updatedConfig = config.SetCredentials("alias", Creds{AccessToken: "access", AccessTokenType: "access-type", RefreshToken: "token"})
Expand All @@ -456,7 +456,7 @@ var _ = Describe("FSConfig", func() {
})

It("does not update existing config when creds are set", func() {
updatedConfig, err := config.AliasEnvironment("url", "alias", "") //nolint:ineffassign
updatedConfig, err := config.AliasEnvironment("url", "alias", "") //nolint:ineffassign,staticcheck
Expect(err).ToNot(HaveOccurred())

updatedConfig = config.SetCredentials("url", Creds{Client: "user"})
Expand Down
2 changes: 1 addition & 1 deletion cmd/deployment_manifest_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (y deploymentManifestParser) getManifest(path string, vars boshtpl.Variable
return bosherr.WrapError(err, "Validating deployment manifest")
}

if skipReleaseJobsValidation == false {
if !skipReleaseJobsValidation {
err = y.deploymentValidator.ValidateReleaseJobs(deploymentManifest, y.releaseManager)
if err != nil {
return bosherr.WrapError(err, "Validating deployment jobs refer to jobs in release")
Expand Down
3 changes: 1 addition & 2 deletions cmd/env_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ type envFactory struct {
vmManagerFactory bivm.ManagerFactory
stemcellManagerFactory bistemcell.ManagerFactory

instanceManagerFactory biinstance.ManagerFactory
deploymentManagerFactory bidepl.ManagerFactory
instanceManagerFactory biinstance.ManagerFactory

agentClientFactory bihttpagent.AgentClientFactory
blobstoreFactory biblobstore.Factory
Expand Down
6 changes: 3 additions & 3 deletions cmd/opts/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type BoshOpts struct {
UnaliasEnv UnaliasEnvOpts `command:"unalias-env" description:"Remove an aliased environment"`

// Authentication
LogIn LogInOpts `command:"log-in" alias:"l" alias:"login" description:"Log in"`
LogIn LogInOpts `command:"log-in" alias:"l" alias:"login" description:"Log in"` //nolint:staticcheck
LogOut LogOutOpts `command:"log-out" alias:"logout" description:"Log out"`

// Tasks
Expand Down Expand Up @@ -83,7 +83,7 @@ type BoshOpts struct {

// Deployments
Deployment DeploymentOpts `command:"deployment" alias:"dep" description:"Show deployment information"`
Deployments DeploymentsOpts `command:"deployments" alias:"ds" alias:"deps" description:"List deployments"`
Deployments DeploymentsOpts `command:"deployments" alias:"ds" alias:"deps" description:"List deployments"` //nolint:staticcheck
DeleteDeployment DeleteDeploymentOpts `command:"delete-deployment" alias:"deld" description:"Delete deployment"`

Deploy DeployOpts `command:"deploy" alias:"d" description:"Update deployment"`
Expand Down Expand Up @@ -136,7 +136,7 @@ type BoshOpts struct {
UpdateResurrection UpdateResurrectionOpts `command:"update-resurrection" description:"Enable/disable resurrection"`
Ignore IgnoreOpts `command:"ignore" description:"Ignore an instance"`
Unignore UnignoreOpts `command:"unignore" description:"Unignore an instance"`
CloudCheck CloudCheckOpts `command:"cloud-check" alias:"cck" alias:"cloudcheck" description:"Cloud consistency check and interactive repair"`
CloudCheck CloudCheckOpts `command:"cloud-check" alias:"cck" alias:"cloudcheck" description:"Cloud consistency check and interactive repair"` //nolint:staticcheck
OrphanedVMs OrphanedVMsOpts `command:"orphaned-vms" description:"List all the orphaned VMs in all deployments"`

// Instance management
Expand Down
2 changes: 1 addition & 1 deletion cmd/opts/opts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

var (
dupSpaces = regexp.MustCompile("\\s{2,}")
dupSpaces = regexp.MustCompile(`\s{2,}`)
)

func getStructTagForName(field string, opts interface{}) string {
Expand Down
6 changes: 3 additions & 3 deletions cmd/opts/var_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ func (f VarFlags) AsVariables() boshtpl.Variables {

staticVars := boshtpl.StaticVariables{}

for i, _ := range f.VarsEnvs {
for i := range f.VarsEnvs {
for k, v := range f.VarsEnvs[i].Vars {
staticVars[k] = v
}
}

for i, _ := range f.VarsFiles {
for i := range f.VarsFiles {
for k, v := range f.VarsFiles[i].Vars {
staticVars[k] = v
}
}

for i, _ := range f.VarFiles {
for i := range f.VarFiles {
for k, v := range f.VarFiles[i].Vars {
staticVars[k] = v
}
Expand Down
7 changes: 0 additions & 7 deletions cmd/run_errand.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,3 @@ func (c RunErrandCmd) summarize(errandName string, results []boshdir.ErrandResul

return errandErr
}

func (c RunErrandCmd) printOutput(title, output string) {
if len(output) > 0 {
c.ui.PrintLinef("%s", title)
c.ui.PrintLinef("%s", output)
}
}
3 changes: 1 addition & 2 deletions cmd/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ var _ = Describe("SessionImpl", func() {
auth := req.Header.Get("Authorization")
Expect(auth).To(BeEmpty(), "Authorization header must empty")
},
ghttp.RespondWith(http.StatusOK, fmt.Sprintf(
`{"user_authentication":{"type":"basic","options":{}}}`)),
ghttp.RespondWith(http.StatusOK, `{"user_authentication":{"type":"basic","options":{}}}`),
),
ghttp.CombineHandlers(
ghttp.VerifyRequest("GET", "/locks"),
Expand Down
2 changes: 1 addition & 1 deletion crypto/fakes/fake_digest_calculator.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (c *FakeDigestCalculator) CalculateString(data string) string {
}

var availableData []string
for key, _ := range c.CalculateStringInputs {
for key := range c.CalculateStringInputs {
availableData = append(availableData, key)
}

Expand Down
6 changes: 3 additions & 3 deletions deployment/instance/state/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (b *builder) Build(jobName string, instanceID int, deploymentManifest bidep
return nil, bosherr.WrapErrorf(err, "Compiling job package dependencies for instance '%s/%d'", jobName, instanceID)
}

compiledDeploymentPackageRefs := make([]PackageRef, len(compiledPackageRefs), len(compiledPackageRefs))
compiledDeploymentPackageRefs := make([]PackageRef, len(compiledPackageRefs))

for i, compiledPackageRef := range compiledPackageRefs {
compiledDeploymentPackageRefs[i] = PackageRef{
Expand All @@ -107,7 +107,7 @@ func (b *builder) Build(jobName string, instanceID int, deploymentManifest bidep
}

// convert array to array
renderedJobRefs := make([]JobRef, len(releaseJobs), len(releaseJobs))
renderedJobRefs := make([]JobRef, len(releaseJobs))

for i, releaseJob := range releaseJobs {
renderedJobRefs[i] = JobRef{
Expand Down Expand Up @@ -168,7 +168,7 @@ func (b *builder) BuildInitialState(jobName string, instanceID int, deploymentMa

// FIXME: why do i exist here and in installation/state/builder.go??
func (b *builder) resolveJobs(jobRefs []bideplmanifest.ReleaseJobRef) ([]bireljob.Job, error) {
releaseJobs := make([]bireljob.Job, len(jobRefs), len(jobRefs))
releaseJobs := make([]bireljob.Job, len(jobRefs))
for i, jobRef := range jobRefs {
release, err := b.releaseJobResolver.Resolve(jobRef.Name, jobRef.Release)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion deployment/instance/state/remote_package_compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (c *remotePackageCompiler) Compile(pkg birelpkg.Compilable) (bistatepkg.Com
if !pkg.IsCompiled() {
// Resolve dependencies from map of previously compiled packages.
// Only install the package's immediate dependencies.
packageDependencies := make([]biagentclient.BlobRef, len(pkg.Deps()), len(pkg.Deps()))
packageDependencies := make([]biagentclient.BlobRef, len(pkg.Deps()))

for i, pkgDep := range pkg.Deps() {
compiledPackageRecord, found, err := c.packageRepo.Find(pkgDep)
Expand Down
2 changes: 1 addition & 1 deletion deployment/instance/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (s *state) CompiledPackages() []PackageRef { return s.compiledPackages }
func (s *state) RenderedJobListArchive() BlobRef { return s.renderedJobListArchive }

func (s *state) ToApplySpec() bias.ApplySpec {
jobTemplateList := make([]bias.Blob, len(s.renderedJobs), len(s.renderedJobs))
jobTemplateList := make([]bias.Blob, len(s.renderedJobs))
for i, renderedJob := range s.renderedJobs {
jobTemplateList[i] = bias.Blob{
Name: renderedJob.Name,
Expand Down
14 changes: 7 additions & 7 deletions deployment/manifest/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (p *parser) parseDeploymentManifest(depManifest manifest, path string) (Man
}

func (p *parser) parseJobManifests(rawJobs []job) ([]Job, error) {
jobs := make([]Job, len(rawJobs), len(rawJobs))
jobs := make([]Job, len(rawJobs))
for i, rawJob := range rawJobs {
job := Job{
Name: rawJob.Name,
Expand All @@ -218,7 +218,7 @@ func (p *parser) parseJobManifests(rawJobs []job) ([]Job, error) {
}

if templates != nil {
releaseJobRefs := make([]ReleaseJobRef, len(templates), len(templates))
releaseJobRefs := make([]ReleaseJobRef, len(templates))
for i, rawJobRef := range templates {
ref := ReleaseJobRef{
Name: rawJobRef.Name,
Expand All @@ -240,15 +240,15 @@ func (p *parser) parseJobManifests(rawJobs []job) ([]Job, error) {
}

if rawJob.Networks != nil {
jobNetworks := make([]JobNetwork, len(rawJob.Networks), len(rawJob.Networks))
jobNetworks := make([]JobNetwork, len(rawJob.Networks))
for i, rawJobNetwork := range rawJob.Networks {
jobNetwork := JobNetwork{
Name: rawJobNetwork.Name,
StaticIPs: rawJobNetwork.StaticIPs,
}

if rawJobNetwork.Defaults != nil {
networkDefaults := make([]NetworkDefault, len(rawJobNetwork.Defaults), len(rawJobNetwork.Defaults))
networkDefaults := make([]NetworkDefault, len(rawJobNetwork.Defaults))
for i, rawDefaults := range rawJobNetwork.Defaults {
networkDefaults[i] = NetworkDefault(rawDefaults)
}
Expand All @@ -275,7 +275,7 @@ func (p *parser) parseJobManifests(rawJobs []job) ([]Job, error) {
}

func (p *parser) parseNetworkManifests(rawNetworks []network) ([]Network, error) {
networks := make([]Network, len(rawNetworks), len(rawNetworks))
networks := make([]Network, len(rawNetworks))
for i, rawNetwork := range rawNetworks {
network := Network{
Name: rawNetwork.Name,
Expand Down Expand Up @@ -310,7 +310,7 @@ func (p *parser) parseNetworkManifests(rawNetworks []network) ([]Network, error)
}

func (p *parser) parseResourcePoolManifests(rawResourcePools []resourcePool, path string) ([]ResourcePool, error) {
resourcePools := make([]ResourcePool, len(rawResourcePools), len(rawResourcePools))
resourcePools := make([]ResourcePool, len(rawResourcePools))
for i, rawResourcePool := range rawResourcePools {
resourcePool := ResourcePool{
Name: rawResourcePool.Name,
Expand Down Expand Up @@ -342,7 +342,7 @@ func (p *parser) parseResourcePoolManifests(rawResourcePools []resourcePool, pat
}

func (p *parser) parseDiskPoolManifests(rawDiskPools []diskPool) ([]DiskPool, error) {
diskPools := make([]DiskPool, len(rawDiskPools), len(rawDiskPools))
diskPools := make([]DiskPool, len(rawDiskPools))
for i, rawDiskPool := range rawDiskPools {
diskPool := DiskPool{
Name: rawDiskPool.Name,
Expand Down
5 changes: 3 additions & 2 deletions deployment/manifest/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (v *validator) Validate(deploymentManifest Manifest, releaseSetManifest bir
networksErrors := v.validateNetworks(deploymentManifest.Networks)
errs = append(errs, networksErrors...)

protocolRegex := regexp.MustCompile("^(file|http|https)://")
for idx, resourcePool := range deploymentManifest.ResourcePools {
if v.isBlank(resourcePool.Name) {
errs = append(errs, bosherr.Errorf("resource_pools[%d].name must be provided", idx))
Expand All @@ -51,8 +52,8 @@ func (v *validator) Validate(deploymentManifest Manifest, releaseSetManifest bir
errs = append(errs, bosherr.Errorf("resource_pools[%d].stemcell.url must be provided", idx))
}

matched, err := regexp.MatchString("^(file|http|https)://", resourcePool.Stemcell.URL)
if err != nil || !matched {
matched := protocolRegex.MatchString(resourcePool.Stemcell.URL)
if !matched {
errs = append(errs, bosherr.Errorf("resource_pools[%d].stemcell.url must be a valid URL (file:// or http(s)://)", idx))
}

Expand Down
22 changes: 10 additions & 12 deletions deployment/vm/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"code.cloudfoundry.org/clock"
biagentclient "github.com/cloudfoundry/bosh-agent/agentclient"
bihttpagent "github.com/cloudfoundry/bosh-agent/agentclient/http"
bicloud "github.com/cloudfoundry/bosh-cli/cloud"
biconfig "github.com/cloudfoundry/bosh-cli/config"
bideplmanifest "github.com/cloudfoundry/bosh-cli/deployment/manifest"
Expand All @@ -24,17 +23,16 @@ type Manager interface {
}

type manager struct {
vmRepo biconfig.VMRepo
stemcellRepo biconfig.StemcellRepo
diskDeployer DiskDeployer
agentClient biagentclient.AgentClient
agentClientFactory bihttpagent.AgentClientFactory
cloud bicloud.Cloud
uuidGenerator boshuuid.Generator
fs boshsys.FileSystem
logger boshlog.Logger
logTag string
timeService Clock
vmRepo biconfig.VMRepo
stemcellRepo biconfig.StemcellRepo
diskDeployer DiskDeployer
agentClient biagentclient.AgentClient
cloud bicloud.Cloud
uuidGenerator boshuuid.Generator
fs boshsys.FileSystem
logger boshlog.Logger
logTag string
timeService Clock
}

func NewManager(
Expand Down
4 changes: 1 addition & 3 deletions director/cloud_configs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ var _ = Describe("Director", func() {
})

Describe("DiffCloudConfig", func() {
var expectedDiffResponse ConfigDiff

expectedDiffResponse = ConfigDiff{
expectedDiffResponse := ConfigDiff{
Diff: [][]interface{}{
[]interface{}{"azs:", nil},
[]interface{}{"- name: az2", "removed"},
Expand Down
4 changes: 1 addition & 3 deletions director/cpi_configs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ var _ = Describe("Director", func() {
})

Describe("DiffCPIConfig", func() {
var expectedDiffResponse ConfigDiff

expectedDiffResponse = ConfigDiff{
expectedDiffResponse := ConfigDiff{
Diff: [][]interface{}{
[]interface{}{"cpis:", nil},
[]interface{}{" name: smurf", "removed"},
Expand Down
Loading