Commit graph

3196 commits

Author SHA1 Message Date
OpenShift Merge Robot 1916fe22a9
Merge pull request #14272 from Luap99/completion2
shell completion: use more constants in the code
2022-05-19 18:45:03 -04:00
Paul Holzinger 9c9fc96d27
shell completion: use more constants instead of duplicating strings
It is better to just reuse the existing constants instead of duplicating
the strings.

[NO NEW TESTS NEEDED]

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-05-19 14:04:23 +02:00
Paul Holzinger 337f8b9d98
shell completion: podman save --format use all valid values
docker-archive was missing from the completions. To prevent duplication
use the same format list as podman save.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-05-19 14:04:22 +02:00
Paul Holzinger 74f70315b3
shell completion: update podman inspect --type options
Add all option that are supported by the podman inspect --type flag to
the completions. Also use the same constants instead of duplicating the
strings. In order to do this I had to move the definitions into the
common package to prevent an import cycle.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-05-19 14:04:22 +02:00
Paul Holzinger 318e95fd2a
shell completion: fix podman event --filter values
The completion suggested incorrect values for `podman events --filter
type=` . It should only list types not the event status. Also make sure
to use the constants instead of duplicating the strings.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-05-19 14:04:10 +02:00
Valentin Rothberg b22143267b linter: enable unconvert linter
Detects unneccessary type conversions and helps in keeping the code base
cleaner.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-05-19 13:59:15 +02:00
Jason T. Greene de4f76e7ea Fix strange buildtag edit
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-05-13 12:11:51 -05:00
Jason T. Greene 7804f4d291 Add support for machine events on Windows
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-05-12 14:41:26 -05:00
Daniel J Walsh 81fc9f1dea
Merge pull request #14159 from vrothberg/service-container
play kube: service container
2022-05-12 13:35:56 -04:00
OpenShift Merge Robot 45e9f1ff09
Merge pull request #14216 from Luap99/format-completion
shell completion --format: work with pointer functions
2022-05-12 15:32:58 +02:00
Paul Holzinger 9df3906553
shell completion --format: work with pointer functions
The completion logic currently suggest also the functions that are
defined for this type. However this did not work correctly when it was
defined as pointer to that type on not the actual type.

This commit fixes that problem. To test you can compare the difference
between `podman stats --format {{.[TAB]` with and without this commit.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-05-12 13:15:56 +02:00
Valentin Rothberg 840c120c21 play kube: service container
Add the notion of a "service container" to play kube.  A service
container is started before the pods in play kube and is (reverse)
linked to them.  The service container is stopped/removed *after*
all pods it is associated with are stopped/removed.

In other words, a service container tracks the entire life cycle
of a service started via `podman play kube`.  This is required to
enable `play kube` in a systemd unit file.

The service container is only used when the `--service-container`
flag is set on the CLI.  This flag has been marked as hidden as it
is not meant to be used outside the context of `play kube`.  It is
further not supported on the remote client.

The wiring with systemd will be done in a later commit.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-05-12 10:51:13 +02:00
OpenShift Merge Robot c379014ee4
Merge pull request #14170 from ashley-cui/machtests
Add more machine tests
2022-05-11 03:03:31 -04:00
Ashley Cui c7c00ce551 Add more machine tests
Add more machine tests for flags in init, inspect, and list.

Signed-off-by: Ashley Cui <acui@redhat.com>
2022-05-10 14:56:13 -04:00
Giuseppe Scrivano 0774a4ce13
kube: add support for --userns=
add support to override the user namespace to use for the pod.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-05-10 16:51:01 +02:00
Aditya R c38e7e5f61
build: disable --output for podman-remote clients
Disable `build --output` for remote clients and update docs.

[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]

Signed-off-by: Aditya R <arajan@redhat.com>
2022-05-05 16:16:41 +05:30
Daniel J Walsh ed159f864d
Vendor in containers/buildah@v1.26.1
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-05-05 04:41:06 -04:00
OpenShift Merge Robot bdaac4b2b6
Merge pull request #14037 from rhatdan/remoteuri
Report correct RemoteURI
2022-05-04 14:52:19 -04:00
OpenShift Merge Robot ad93318370
Merge pull request #14066 from ashley-cui/sysres
podman system reset removed machines incorrectly
2022-05-04 13:20:09 -04:00
Daniel J Walsh 5fa6f686db
Report correct RemoteURI
Rather than assuming a filesystem path, the API service URI is recorded
in the libpod runtime configuration and then reported as requested.

Note: All schemes other than "unix" are hard-coded to report URI exists.

Fixes #12023

Signed-off-by: Jhon Honce <jhonce@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-05-04 12:11:32 -04:00
OpenShift Merge Robot b1e9ea38e5
Merge pull request #14060 from nicrowe00/13781
play kube default log driver
2022-05-04 11:44:06 -04:00
Ashley Cui 80744c6441 podman system reset removed machines incorrectly
podman system reset did not clean up machines fully, leaving some config
files, and breaking machines. Now it removes all machines files fully.

Signed-off-by: Ashley Cui <acui@redhat.com>
2022-05-04 10:31:42 -04:00
Paul Holzinger a5800c78fd
machine events: only open sockets when needed
We should only open the socket when needed and not always at init time.

[NO NEW TESTS NEEDED]

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-05-04 15:08:25 +02:00
OpenShift Merge Robot 1975975cf4
Merge pull request #14099 from jwhonce/wip/machine_inspect
Implement --format for machine inspect
2022-05-04 08:33:22 -04:00
Niall Crowe ccd576504e play kube default log driver
The default log driver is not used when using play kube
without --log-driver. The LogDriver function needs to
be called in order to use the default log driver.

fixes #13781
Signed-off-by: Niall Crowe <nicrowe@redhat.com>
2022-05-04 12:52:27 +01:00
Jhon Honce 88015cf0d8 Implement --format for machine inspect
* Fix issue of nil pointer derefence

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2022-05-03 16:15:59 -07:00
Jhon Honce 8da5f3f733 Add podman machine events
Signed-off-by: Jhon Honce <jhonce@redhat.com>
2022-05-03 13:49:01 -07:00
Valentin Rothberg 4eff0c8cf2 pod: add exit policies
Add the notion of an "exit policy" to a pod.  This policy controls the
behaviour when the last container of pod exits.  Initially, there are
two policies:

 - "continue" : the pod continues running. This is the default policy
                when creating a pod.

 - "stop" : stop the pod when the last container exits. This is the
            default behaviour for `play kube`.

In order to implement the deferred stop of a pod, add a worker queue to
the libpod runtime.  The queue will pick up work items and in this case
helps resolve dead locks that would otherwise occur if we attempted to
stop a pod during container cleanup.

Note that the default restart policy of `play kube` is "Always".  Hence,
in order to really solve #13464, the YAML files must set a custom
restart policy; the tests use "OnFailure".

Fixes: #13464
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-05-02 13:29:59 +02:00
OpenShift Merge Robot 80315b9c86
Merge pull request #14026 from n1hility/simulate-dualstack
Use simulated dual-stack binds when using WSL
2022-04-30 06:38:19 -04:00
Jason T. Greene 772ead2531 Use simulated dual-stack binds when using WSL
Resolves a WSL problem where traffic from only one stack is relayed

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-04-29 17:03:45 -05:00
Paul Holzinger 69c479b16e
enable errcheck linter
The errcheck linter makes sure that errors are always check and not
ignored by accident. It spotted a lot of unchecked errors, mostly in the
tests but also some real problem in the code.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-29 14:06:38 +02:00
OpenShift Merge Robot 765c8818e4
Merge pull request #14033 from baude/inspectredo
Refactor machine inspect
2022-04-28 16:21:33 -04:00
Brent Baude 2902d32c49 Refactor machine inspect
I was asked to refactor machine inspect output to represent more common
and basic information.  machine inspect now has information that would
be appropriate for different machines.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-04-28 13:32:21 -05:00
Paul Holzinger 6b7fd318bd
image search --format: add completion for go template
podman image search accepts a go template, we can use the same shell
completion logic which is used everywhere else in the code.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-28 18:33:23 +02:00
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