packer-cn/packer/artifact_mock.go
Wilken Rivera b9f1b3c8d4
Fix gosimple S1005 linting issue (#8870)
Results before change
```
⇶  golangci-lint run ./... --disable-all --enable=gosimple | grep 1005
fix/fixer_comm_config.go:48:4: S1005: should write `sshHostPortMinRaw := builders["ssh_host_port_min"]` instead of `sshHostPortMinRaw, _ := builders["ssh_host_port_min"]` (gosimple)
fix/fixer_comm_config.go:64:4: S1005: should write `sshHostPortMaxRaw := builders["ssh_host_port_max"]` instead of `sshHostPortMaxRaw, _ := builders["ssh_host_port_max"]` (gosimple)
fix/fixer_comm_config.go:81:4: S1005: should write `sshSkipNatMappingRaw := builders["ssh_skip_nat_mapping"]` instead of `sshSkipNatMappingRaw, _ := builders["ssh_skip_nat_mapping"]` (gosimple)
packer/artifact_mock.go:47:2: S1005: should write `value := a.StateValues[name]` instead of `value, _ := a.StateValues[name]` (gosimple)
packer/artifact_test.go:31:2: S1005: should write `value := a.state[name]` instead of `value, _ := a.state[name]` (gosimple)
```

Results after change
```
```
2020-03-11 10:30:08 +01:00

55 lines
916 B
Go

package packer
// MockArtifact is an implementation of Artifact that can be used for tests.
type MockArtifact struct {
BuilderIdValue string
FilesValue []string
IdValue string
StateValues map[string]interface{}
DestroyCalled bool
StringValue string
}
func (a *MockArtifact) BuilderId() string {
if a.BuilderIdValue == "" {
return "bid"
}
return a.BuilderIdValue
}
func (a *MockArtifact) Files() []string {
if a.FilesValue == nil {
return []string{"a", "b"}
}
return a.FilesValue
}
func (a *MockArtifact) Id() string {
id := a.IdValue
if id == "" {
id = "id"
}
return id
}
func (a *MockArtifact) String() string {
str := a.StringValue
if str == "" {
str = "string"
}
return str
}
func (a *MockArtifact) State(name string) interface{} {
value := a.StateValues[name]
return value
}
func (a *MockArtifact) Destroy() error {
a.DestroyCalled = true
return nil
}