diff options
author | Jordan Christiansen <xordspar0@gmail.com> | 2022-02-23 09:59:49 -0600 |
---|---|---|
committer | Jordan Christiansen <xordspar0@gmail.com> | 2022-02-24 08:59:11 -0600 |
commit | a7fc8a146075805c0c4941652bcaf377943f4d1c (patch) | |
tree | 850d3ff831ef49184a0ebfadae42ba35ebb56c5f | |
parent | a234e4e19662e172472877ce69523f4afea5c12e (diff) | |
download | podman-a7fc8a146075805c0c4941652bcaf377943f4d1c.tar.gz podman-a7fc8a146075805c0c4941652bcaf377943f4d1c.tar.bz2 podman-a7fc8a146075805c0c4941652bcaf377943f4d1c.zip |
Improve the error message for usused configMaps
If you run `podman play kube` on a yaml file that only contains
configMaps, podman will fail with the error:
Error: YAML document does not contain any supported kube kind
This is not strictly true; configMaps are a supported kube kind. The
problem is that configMaps aren't a standalone entity. They have to be
used in a container somewhere, otherwise they don't do anything.
This change adds a new message in the case when there only configMaps
resources. It would be helpful if podman reported which configMaps are
unused on every invocation of kube play. However, even if that feedback
were added, this new error messages still helpfully explains the reason
that podman is not creating any resources.
[NO NEW TESTS NEEDED]
Signed-off-by: Jordan Christiansen <xordspar0@gmail.com>
-rw-r--r-- | docs/source/markdown/podman-play-kube.1.md | 13 | ||||
-rw-r--r-- | pkg/domain/infra/abi/play.go | 3 |
2 files changed, 9 insertions, 7 deletions
diff --git a/docs/source/markdown/podman-play-kube.1.md b/docs/source/markdown/podman-play-kube.1.md index f85ea9046..389affc3a 100644 --- a/docs/source/markdown/podman-play-kube.1.md +++ b/docs/source/markdown/podman-play-kube.1.md @@ -72,9 +72,11 @@ disable builds. `Kubernetes ConfigMap` -Kubernetes ConfigMap can be referred as a source of environment variables in Pods or Deployments. +Kubernetes ConfigMap can be referred as a source of environment variables or volumes in Pods or Deployments. +ConfigMaps aren't a standalone object in Podman; instead, when a container uses a ConfigMap, Podman will create environment variables or volumes as needed. + +For example, the following YAML document defines a ConfigMap and then uses it in a Pod: -For example ConfigMap defined in following YAML: ``` apiVersion: v1 kind: ConfigMap @@ -82,14 +84,11 @@ metadata: name: foo data: FOO: bar -``` - -can be referred in a Pod in following way: -``` +--- apiVersion: v1 kind: Pod metadata: -... + name: foobar spec: containers: - command: diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go index 1cd80a6d2..8cbf5da9a 100644 --- a/pkg/domain/infra/abi/play.go +++ b/pkg/domain/infra/abi/play.go @@ -128,6 +128,9 @@ func (ic *ContainerEngine) PlayKube(ctx context.Context, path string, options en } if validKinds == 0 { + if len(configMaps) > 0 { + return nil, fmt.Errorf("ConfigMaps in podman are not a standalone object and must be used in a container") + } return nil, fmt.Errorf("YAML document does not contain any supported kube kind") } |