Commit Graph

17 Commits

Author SHA1 Message Date
Paul Holzinger d240865a45 lint: update golangci-lint to v1.56.2
Adds a couple of new linters with many new warnings:
- perfsprint (fixed in code, excluded for tests)
- revive (fix the problems, disabled the dot import check as we use it
  for ginkgo)
- inamedparam (disabled because it is opinionated)
- testifylint (great linter but we have like 1000+ issues that I have no
  time fixing now)

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-05 18:10:32 +01:00
Gordon Messmer 9c69ae85ec Support the execution of SSH commands with optional input.
Because the SSH exec functions do not currently support execution with
input, some users (such as the podman-image-scp) must operate in two
phases, first copying a file to the remote host, and then executing a
command with shell redirection and removing the temporary file.

This API extension allows those users to simplify their code and
avoid the use of temporary files.

Signed-off-by: Gordon Messmer <gordon.messmer@gmail.com>
2024-02-07 09:05:31 -08:00
Paul Holzinger 330f41d7a2 pkg/config: add new connections.conf file
podman systemd conenction and farm currently both write containers.conf
to store their settings. Each write removes comments from the user
config file and thus makes it not great to use.

The new approach is to have a seperate file connections.conf (json
format) to store both conenctions and farms for podman. We continue to
read containers.conf for the connections and farms as well and podman
can read both. This means we have a read only store in containers.conf
(manually added by users), they cannot be removed by the podman cli.

This is a breaking chnage and will require many chnages in podman to
migrate to the new APIs added in this commit.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-01-29 17:05:03 +01:00
Oleksandr Redko 63869c6bf3 chore: replace 'interface{}' with 'any' for consistency
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-08 21:26:34 +02:00
Oleksandr Redko 4dbd58b735 Refactor: replace raw loops with funcs from slices and maps
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-05 00:11:15 +02:00
Oleksandr Redko 3cc2a76ae9 Fix typos across repo; extend codespell config
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-03 23:38:47 +02:00
Valentin Rothberg de32d5a9f7 linters: enable dupword
Mostly monkey work to fix comments but there was also an error message.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-09-01 11:51:25 +02:00
Valentin Rothberg f3860c8fcc linters: enable wastedassign
Useful micro optimizations.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-09-01 11:27:18 +02:00
Valentin Rothberg 14bddff8d5 linters: enable mirror
Useful micro optimizations.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-09-01 11:20:53 +02:00
Urvashi Mohnani a489f0261c Update system connection to add to farm
A new --farm flag is being added to podman system connection
add so that when a new connection is added it can be added to a new
or existing farm. Update the code here to be able to do that.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-08-03 09:53:55 -04:00
Daniel J Walsh bb2e6fbeb9 Default to port 22 when dialing
[NO NEW TESTS NEEDED]

Fixes: https://github.com/containers/podman/issues/19162

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-07-21 13:00:00 -04:00
Doug Rabson 9854a2b4d3 pkg/ssh: simplify ssh.Validate
This removes logic which forces the socket path (if present) to start
with "/run" and uses (*URL).String to reconstruct the URI after applying
port and user policy. Fixes #1551.

Signed-off-by: Doug Rabson <dfr@rabson.org>
2023-07-12 11:42:37 +01:00
Daniel J Walsh 488fb367e7 create known_hosts file path when missing
Fixes: https://github.com/containers/podman/issues/16340

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-11-04 08:30:42 -04:00
Valentin Rothberg e17483b871 bump to golangci-lint v1.50.0
Used `go fmt` rules to migrate away from deprecated functions, for
instance `gofmt -w -s -r 'ioutil.TempDir(a, b) -> os.MkdirTemp(a, b)'`

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-10-17 15:03:07 +02:00
Charlie Doern 2b86bc5d8a podman machine and podman-remote need some softer handling when it comes to key verification
this ensures that podman machine will still work (until we want to make this mandatory). I made the call back function more verbose so we know what is happening from now on.

Signed-off-by: Charlie Doern <cdoern@redhat.com>
2022-09-26 15:36:00 -04:00
Daniel J Walsh a5698c8b06 Fix stutters
Podman adds an Error: to every error message. So starting an error
message with "error" ends up being reported to the user as

Error: error ...

This patch removes the stutter.

Also ioutil.ReadFile errors report the Path, so wrapping the err message
with the path causes a stutter.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-08-27 08:05:03 -04:00
Charlie Doern 64be63d976 ssh package
initial implementation of the ssh package including:

- nativeConnectionCreate() / golangConnectionCreate()
- n/a / golangConnectionDial()
- nativeConnectionScp() / golangConnectionScp()
- nativeConnectionExec() / golangConnectionExeC()

the way this works, is there are publicly accessible functions Create, Exec, Dial and Scp. podman will have a new global flag --ssh` that will allow users to choose native or golang based ssh functions. The functionality in containers/common (here) also checks if you have the necessary binaries installed

closes #1091

Signed-off-by: Charlie Doern <cdoern@redhat.com>
2022-08-08 09:22:46 -04:00