func()

in fast-build-update-tool/internal/tools/ssh_config_manager.go [30:51]


func (s *SSHConfigManager) DeterminePort(operatingSystem config.OperatingSystem) (int32, error) {
	port := int32(s.sshPort)

	// Currently this tool does not support using a custom port for Linux
	if operatingSystem == config.OperatingSystemLinux {
		if port > 0 && port != config.DefaultPortLinux {
			s.logger.Warn("custom SSH ports are not supported for Linux fleets, using the default", "port", config.DefaultPortLinux)
		}
		return config.DefaultPortLinux, nil
	}

	// If the user provided a port, but it is invalid return an error
	if port > 0 && port < config.DefaultPortWindows {
		return 0, fmt.Errorf("ssh port must be greater than or equal to %d for Windows servers", config.DefaultPortWindows)
	}

	if port == 0 {
		return config.DefaultPortWindows, nil
	}

	return port, nil
}