diff --git a/internal/cmd/commands/targets/tcp.go b/internal/cmd/commands/targets/tcp.go index edf9464ca..32afd87ad 100644 --- a/internal/cmd/commands/targets/tcp.go +++ b/internal/cmd/commands/targets/tcp.go @@ -140,12 +140,12 @@ func (c *TcpCommand) Run(args []string) int { case "null": opts = append(opts, targets.DefaultDefaultPort()) default: - length, err := strconv.ParseUint(c.flagDefaultPort, 10, 32) + port, err := strconv.ParseUint(c.flagDefaultPort, 10, 32) if err != nil { c.UI.Error(fmt.Sprintf("Error parsing %q: %s", c.flagDefaultPort, err)) return 1 } - opts = append(opts, targets.WithDefaultPort(uint32(length))) + opts = append(opts, targets.WithDefaultPort(uint32(port))) } targetClient := targets.NewClient(client) diff --git a/internal/servers/controller/handlers/targets/target_service.go b/internal/servers/controller/handlers/targets/target_service.go index e19bf3443..264a0e41d 100644 --- a/internal/servers/controller/handlers/targets/target_service.go +++ b/internal/servers/controller/handlers/targets/target_service.go @@ -240,6 +240,9 @@ func (s Service) updateInRepo(ctx context.Context, scopeId, id string, mask []st if name := item.GetName(); name != nil { opts = append(opts, target.WithName(name.GetValue())) } + if item.GetDefaultPort().GetValue() != 0 { + opts = append(opts, target.WithDefaultPort(item.GetDefaultPort().GetValue())) + } version := item.GetVersion() u, err := target.NewTcpTarget(scopeId, opts...) if err != nil {