Skip to content

Commit

Permalink
Drop redundant guard cases
Browse files Browse the repository at this point in the history
The upper index bound for a slice is cap(args) we can safely retun appended slices

```
~>  go test -count=1 ./plugin/... -v
=== RUN   TestPluginServerRandom
--- PASS: TestPluginServerRandom (0.00s)
=== RUN   TestSet
--- PASS: TestSet (0.00s)
=== RUN   TestSetProtobufArgParsing
=== RUN   TestSetProtobufArgParsing/no_--protobuf_argument_provided
=== RUN   TestSetProtobufArgParsing/providing_--protobuf_as_first_argument
=== RUN   TestSetProtobufArgParsing/providing_--protobuf_as_last_argument
=== RUN   TestSetProtobufArgParsing/providing_--protobuf_as_middle_argument
--- PASS: TestSetProtobufArgParsing (0.00s)
    --- PASS: TestSetProtobufArgParsing/no_--protobuf_argument_provided (0.00s)
    --- PASS: TestSetProtobufArgParsing/providing_--protobuf_as_first_argument (0.00s)
    --- PASS: TestSetProtobufArgParsing/providing_--protobuf_as_last_argument (0.00s)
    --- PASS: TestSetProtobufArgParsing/providing_--protobuf_as_middle_argument (0.00s)
PASS
ok      github.com/hashicorp/packer-plugin-sdk/plugin   0.244s

```
  • Loading branch information
nywilken authored and lbajolet-hashicorp committed Dec 17, 2024
1 parent 460c0fc commit 66e2128
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions plugin/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,6 @@ func (i *Set) parseProtobufFlag(args ...string) []string {
}

i.useProto = true

if protobufPos == 0 {
return args[1:]
}

if protobufPos == len(args)-1 {
return args[:len(args)-1]
}

return append(args[:protobufPos], args[protobufPos+1:]...)
}

Expand Down

0 comments on commit 66e2128

Please sign in to comment.