Merge pull request #2175 from thaJeztah/pin_in_scope

parseNetworkOpts, updatePorts: pin variables in scope (scopelint)
This commit is contained in:
Silvin Lubecki 2019-12-04 14:50:00 +01:00 committed by GitHub
commit 6eee39df0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View File

@ -686,6 +686,7 @@ func parseNetworkOpts(copts *containerOptions) (map[string]*networktypes.Endpoin
)
for i, n := range copts.netMode.Value() {
n := n
if container.NetworkMode(n.Target).IsUserDefined() {
hasUserDefined = true
} else {

View File

@ -1004,6 +1004,7 @@ func updatePorts(flags *pflag.FlagSet, portConfig *[]swarm.PortConfig) error {
// Build the current list of portConfig
for _, entry := range *portConfig {
entry := entry
if _, ok := portSet[portConfigToString(&entry)]; !ok {
portSet[portConfigToString(&entry)] = entry
}
@ -1031,6 +1032,7 @@ portLoop:
ports := flags.Lookup(flagPublishAdd).Value.(*opts.PortOpt).Value()
for _, port := range ports {
port := port
if _, ok := portSet[portConfigToString(&port)]; ok {
continue
}