Commit graph

3162 commits

Author SHA1 Message Date
Paul Holzinger 0d9f190280
shell completion --format: use structs by reference
For the AutocompleteFormat function we expect the correct template
struct which is used in the golang template. The function can handle
both struct and pointer to a struct. Using the reference is more
efficient since it doe snot have to copy the whole struct.

Also change some structs to use he actual type from the template instead
of some nested one to make sure it has to correct fields.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-28 18:12:17 +02:00
Paul Holzinger cac2b7800b
image --format: fix add completion for go template
It used the wrong struct so not all fields were listed in the
completion.
Fixes podman images --format and podman image history --format

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-28 16:53:12 +02:00
Paul Holzinger cb9a45630f
shell completion --format: use anonymous struct field once
We should not include the anonymous twice in the suggestions.

one example is `podman network ls --format {{.` it will also show
`{{.Network` but since Network is the actual struct all fields are
already shown so there is no need for it to be suggested.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-28 15:11:25 +02:00
Paul Holzinger 8be9781586
network inspect --format: add completion for go template
Make sure to autocomplete the go template for network inspect.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-28 15:11:25 +02:00
Paul Holzinger f93ba587c6
shell completion --format: work with nil structs
AutocompleteFormat() takes the format struct as argument. Often the structs
are deeply nested and contain other structs. Up until now if there was a
pointer to a struct the logic was not able to get the field names from
that, simply because the pointer was nil. However it is possible to
create a new initialized type with reflect.New(). This allows us to
complete all struct fields/functions even when there nil pointers.
Therefore we can drop the extra initialization which was done by some
callers.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-28 15:11:21 +02:00
Valentin Rothberg ea1fcd7bc7 podman search: truncate by default
Truncate by default to avoid long descriptions from rendering the output
unreadable.

[NO NEW TESTS NEEDED]

Fixes: #14044
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-04-28 09:40:46 +02:00
OpenShift Merge Robot 7321f5e462
Merge pull request #14034 from rhatdan/history
Add CreatedSince & CreatedAt format fields to podman image history
2022-04-27 17:08:44 -04:00
OpenShift Merge Robot 60d6cc8e1e
Merge pull request #13953 from ashley-cui/mach
Allow changing of CPUs, Memory, and Disk Size
2022-04-27 16:02:57 -04:00
Daniel J Walsh 22b421dd7e
Add CreatedSince & CreatedAt format fields to podman image history
Fixes: https://github.com/containers/podman/issues/14012

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-04-27 15:15:03 -04:00
Ashley Cui e7390f30b9 Allow changing of CPUs, Memory, and Disk Size
Allow podman machine set to change CPUs, Memory and Disk size of a QEMU machine after its been created.
Disk size can only be increased.

If one setting fails to be changed, the other settings will still be applied.

Signed-off-by: Ashley Cui <acui@redhat.com>
2022-04-27 13:56:14 -04:00
OpenShift Merge Robot bbe419ef9f
Merge pull request #14023 from rhatdan/kube
Truncate annotations when generating kubernetes yaml files
2022-04-27 09:42:31 -04:00
Daniel J Walsh 7259a6315c
Truncate annotations when generating kubernetes yaml files
Kubernetes only allows 63 characters in an annotation.  Make sure
that we only add 63 or less charaters when generating kube. Warn
if containers or pods have longer length and truncate.

Discussion: https://github.com/containers/podman/discussions/13901

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-04-27 04:39:05 -04:00
Paul Holzinger 51fbf3da9e
enable gocritic linter
The linter ensures a common code style.
- use switch/case instead of else if
- use if instead of switch/case for single case statement
- add space between comment and text
- detect the use of defer with os.Exit()
- use short form var += "..." instead of var = var + "..."
- detect problems with append()
```
newSlice := append(orgSlice, val)
```
  This could lead to nasty bugs because the orgSlice will be changed in
  place if it has enough capacity too hold the new elements. Thus we
  newSlice might not be a copy.

Of course most of the changes are just cosmetic and do not cause any
logic errors but I think it is a good idea to enforce a common style.
This should help maintainability.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-26 18:12:22 +02:00
Brent Baude 7c914355d0 [CI:DOCS]Remove unnecesarry files
Removing two files that are not needed.  One is likely an accidental
check-in and the other is a empty file.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-04-26 08:22:14 -05:00
OpenShift Merge Robot e7c30d855f
Merge pull request #13996 from cdoern/machine
machine starting status
2022-04-26 09:08:31 -04:00
OpenShift Merge Robot ace6672bf1
Merge pull request #13908 from n1hility/win-mounts
Implement Windows volume/mount support
2022-04-26 08:38:33 -04:00
Jason T. Greene b0d36f6351 Implements Windows volume/mount support
Based on WSL2 9p support: remaps windows paths to /mnt/<drive> locations for
both podman and Docker API clients.

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-04-25 13:52:27 -05:00
cdoern d441a711e5 machine starting status
podman machine was using the file modification time to get the running status
add three new config entries Starting (bool) Created (time) LastUp (time) to actually
keep track of when these events happened. This means we can use the config file
to actually store this data and not mess up the created/last-up time.

This fixes the issues where the machine would report running 15 seconds before it was up.
Also fixes the issue of modifying the file manually and saying the machine is "up"

[NO NEW TESTS NEEDED]

resolves #13711

Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
2022-04-25 14:14:45 -04:00
Brent Baude 833456e079 Add podman machine test suite
This PR introduces a test suite for podman machine.  It can currently be
run on developers' local machines and is not part of the official CI
testing; however, the expectation is that any work on machine should
come with an accompanying test.

At present, the test must be run on Linux.  It is untested on Darwin.
There is no Makefile target for the test.  It can be run like `ginkgo -v
pkg/machine/test/.`.  It should be run as a unprivileged user.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-04-25 13:05:35 -05:00
OpenShift Merge Robot 6984a0f357
Merge pull request #13999 from Luap99/go1.18-deprecated
[CI:DOCS] fix staticcheck linter warning for deprecated function
2022-04-25 13:52:15 -04:00
OpenShift Merge Robot 09ef4f2e22
Merge pull request #13978 from Luap99/unparam
enable unparam linter
2022-04-25 13:43:57 -04:00
OpenShift Merge Robot a775e77cba
Merge pull request #13995 from ashley-cui/revrootful
Rootfull -> Rootful
2022-04-25 13:37:59 -04:00
Paul Holzinger 62f4ae98fb
fix staticcheck linter warning for deprecated function
go1.18 deprecates `strings.Title()`. However for our use case this is
still fine. The recommended replacement is adding about 400kb binary
size so lets keep using this for now.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-25 18:55:28 +02:00
Ashley Cui 1260bf631f Revert "Switch all rootful to rootfull"
This reverts commit cc3790f332.

We can't change rootful to rootfull because `rootful` is written into the machine config. Changing this will break json unmarshalling, which will break existing machines.

[NO NEW TESTS NEEDED]

Signed-off-by: Ashley Cui <acui@redhat.com>
2022-04-25 09:14:04 -04:00
Paul Holzinger c7b16645af
enable unparam linter
The unparam linter is useful to detect unused function parameters and
return values.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-25 13:23:20 +02:00
Daniel J Walsh 13079abe3f
Add support for passing --volumepath
Fixes: https://github.com/containers/podman/issues/13860

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-04-23 08:03:36 -04:00
OpenShift Merge Robot 2df9bdc009
Merge pull request #13973 from Luap99/linter-revive
replace golint with revive linter
2022-04-23 06:32:41 -04:00
Paul Holzinger 5b4af0584d
replace golint with revive linter
golint, scopelint and interfacer are deprecated. golint is replaced by
revive. This linter is better because it will also check for our error
style: `error strings should not be capitalized or end with punctuation or a newline`

scopelint is replaced by exportloopref (already endabled)
interfacer has no replacement but I do not think this linter is
important.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-22 15:12:33 +02:00
OpenShift Merge Robot 1bafde2d22
Merge pull request #13881 from rhatdan/userns
Add support for --userns=nomap
2022-04-22 08:40:34 -04:00
OpenShift Merge Robot 22500d797a
Merge pull request #13972 from Luap99/staticcheck
enable staticcheck linter
2022-04-22 08:26:31 -04:00
OpenShift Merge Robot 0d6af14387
Merge pull request #13964 from rhatdan/rootfull
Switch all rootful to rootfull
2022-04-22 06:56:33 -04:00
Paul Holzinger 2a8e435671
enable staticcheck linter
Fix many problems reported by the staticcheck linter, including many
real bugs!

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-22 12:51:29 +02:00
Paul Holzinger 56d6ee0808
move golang.org/x/crypto/ssh/terminal to golang.org/x/term
golang.org/x/crypto/ssh/terminal is deprecated. The package was moved to
golang.org/x/term. golang.org/x/crypto/ssh/terminal was already just
calling golang.org/x/term itslef so there are no functional changes.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-22 12:40:52 +02:00
OpenShift Merge Robot 26a51b2900
Merge pull request #13943 from cdoern/clone
podman container clone -f
2022-04-22 06:24:52 -04:00
Daniel J Walsh cc3790f332
Switch all rootful to rootfull
We are inconsistent on the name, we should stick with rootfull.

[NO NEW TESTS NEEDED] Existing tests should handle this and no tests for
machines exists yet.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-04-21 17:05:16 -04:00
Daniel J Walsh 80c0fceb24
Add support for --userns=nomap
From a security point of view, it would be nice to be able to map a
rootless usernamespace that does not use your own UID within the
container.

This would add protection against a hostile process escapping the
container and reading content in your homedir.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-04-21 15:29:04 -04:00
cdoern 5375401960 podman container clone -f
add the option -f to force remove the parent container if --destory is specified

resolves #13917

Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
2022-04-21 15:00:32 -04:00
OpenShift Merge Robot cb09c26c65
Merge pull request #13505 from rst0git/checkpoint-image-1
Add support for checkpoint image
2022-04-21 11:58:56 -04:00
Paul Holzinger 13c6fd067c
system service: remove unnecessary pointer to listner
Since the listener is already an interface there is no reason to use a
extra pointer for it.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-21 13:32:20 +02:00
Radostin Stoyanov 756ecd5400
Add support for checkpoint image
This is an enhancement proposal for the checkpoint / restore feature of
Podman that enables container migration across multiple systems with
standard image distribution infrastructure.

A new option `--create-image <image>` has been added to the
`podman container checkpoint` command. This option tells Podman to
create a container image.  This is a standard image with a single layer,
tar archive, that that contains all checkpoint files. This is similar to
the current approach with checkpoint `--export`/`--import`.

This image can be pushed to a container registry and pulled on a
different system.  It can also be exported locally with `podman image
save` and inspected with `podman inspect`. Inspecting the image would
display additional information about the host and the versions of
Podman, criu, crun/runc, kernel, etc.

`podman container restore` has also been extended to support image
name or ID as input.

Suggested-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Radostin Stoyanov <radostin@redhat.com>
2022-04-20 18:55:39 +01:00
Daniel J Walsh a2077e5eae
Add missing events to podman-events man page
[NO NEW TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-04-19 16:30:26 -04:00
Brent Baude 99bcd65959 Add --quiet to machine ls
The podman machine ls command would benefit from a --quiet flag which
would only print the machine names without the extra information.  It
also implies --noheader as well.  This can be helpful for scripting with
the podman cli.

Signed-off-by: Brent Baude <bbaude@redhat.com>

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-04-16 08:54:56 -05:00
OpenShift Merge Robot 25eeaec219
Merge pull request #13849 from baude/defaultvolumess
Mount $HOME:$HOME by default in podman machine init
2022-04-15 06:10:17 -04:00
OpenShift Merge Robot f2ab79cc02
Merge pull request #13868 from cdoern/cloneSwap
Fix Memory Swappiness passing in Container Clone
2022-04-15 05:54:05 -04:00
OpenShift Merge Robot 6076e1a9a5
Merge pull request #13616 from giuseppe/passwd-entry
run, create: add --passwd-entry
2022-04-14 15:35:20 -04:00
Brent Baude 900739d134 Add container.conf default volume to init
containers.conf now has a default volumes field for podman machine.
this pr inserts those values as the default volumes in init.

Signed-off-by: Brent Baude <bbaude@redhat.com>

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-04-14 13:06:05 -05:00
cdoern f38b03d375 Fix Memory Swappiness passing in Container Clone
`DefineCreateFlags` was excluding clone from using the memory-swappiness flag leading the value to be zero
when our deafult is -1. Rearrange the if/else to give clone these memory related options

resolves #13856

Signed-off-by: cdoern <cdoern@redhat.com>
2022-04-14 10:40:29 -04:00
OpenShift Merge Robot 001f619eab
Merge pull request #13872 from vrothberg/revert-size
Revert "images --size"
2022-04-14 07:18:52 -04:00
Giuseppe Scrivano 3f2939c2ef
run, create: add --passwd-entry
It allows to customize the entry that is written to the `/etc/passwd`
file when --passwd is used.

Closes: https://github.com/containers/podman/issues/13185

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-04-14 11:22:13 +02:00
Valentin Rothberg 97f93dc78e Revert "images --size"
This reverts commit e133a06d2f.

@nalind found a proper fix in c/storage [1] to address the performance
issue.  So we really don't need the flag anymore.  Note the flag has
never made it into any release.

[1] d76b3606fc

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-04-14 10:58:36 +02:00