Skip to content

Commit

Permalink
🐛 Handle ssh connection errors (#1844)
Browse files Browse the repository at this point in the history
Fixes #1812
Fixes #1814

Signed-off-by: Christian Zunker <[email protected]>
  • Loading branch information
czunker authored Sep 22, 2023
1 parent 928afdc commit 66756d7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions providers/os/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba
case SshConnectionType:
s.lastConnectionID++
conn, err = connection.NewSshConnection(s.lastConnectionID, conf, asset)
if err != nil {
return nil, err
}
fingerprint, err := IdentifyPlatform(conn, asset.Platform, []string{ids.IdDetector_Hostname, ids.IdDetector_CloudDetect, ids.IdDetector_SshHostkey})
if err == nil {
if conn.Asset().Connections[0].Runtime != "vagrant" {
Expand All @@ -311,6 +314,9 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba
case TarConnectionType:
s.lastConnectionID++
conn, err = connection.NewTarConnection(s.lastConnectionID, conf, asset)
if err != nil {
return nil, err
}
fingerprint, err := IdentifyPlatform(conn, asset.Platform, []string{ids.IdDetector_Hostname})
if err == nil {
asset.Name = fingerprint.Name
Expand All @@ -320,6 +326,9 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba
case DockerSnapshotConnectionType:
s.lastConnectionID++
conn, err = connection.NewDockerSnapshotConnection(s.lastConnectionID, conf, asset)
if err != nil {
return nil, err
}
fingerprint, err := IdentifyPlatform(conn, asset.Platform, []string{ids.IdDetector_Hostname})
if err == nil {
asset.Name = fingerprint.Name
Expand Down Expand Up @@ -358,6 +367,9 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba
case FilesystemConnectionType:
s.lastConnectionID++
conn, err = connection.NewFileSystemConnection(s.lastConnectionID, conf, asset)
if err != nil {
return nil, err
}
fingerprint, err := IdentifyPlatform(conn, asset.Platform, []string{ids.IdDetector_Hostname})
if err == nil {
asset.Name = fingerprint.Name
Expand Down

0 comments on commit 66756d7

Please sign in to comment.