Skip to content

Commit

Permalink
Merge pull request containers#17038 from ygalblum/quadlet-kube-configmap
Browse files Browse the repository at this point in the history
Quadlet: Add support for ConfigMap key in Kube section
  • Loading branch information
openshift-merge-robot authored Jan 11, 2023
2 parents 31dcb48 + 1bd3d32 commit 382c55e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/source/markdown/podman-systemd.unit.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,14 @@ created by using a `$name.network` quadlet file.

This key can be listed multiple times.

#### `ConfigMap=`

Pass the Kubernetes ConfigMap YAML at path to `podman kube play` via the `--configmap` argument.
Unlike the `configmap` argument, the value may contain only one path but
it may be absolute or relative to the location of the unit file.

This key may be used multiple times

### Volume units

Volume files are named with a `.volume` extension and contain a section `[Volume]` describing the
Expand Down
11 changes: 11 additions & 0 deletions pkg/systemd/quadlet/quadlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const (
KeyNetworkIPv6 = "IPv6"
KeyNetworkOptions = "Options"
KeyNetworkSubnet = "Subnet"
KeyConfigMap = "ConfigMap"
)

// Supported keys in "Container" group
Expand Down Expand Up @@ -136,6 +137,7 @@ var supportedKubeKeys = map[string]bool{
KeyRemapUsers: true,
KeyRemapUIDSize: true,
KeyNetwork: true,
KeyConfigMap: true,
}

func replaceExtension(name string, extension string, extraPrefix string, extraSuffix string) string {
Expand Down Expand Up @@ -757,6 +759,15 @@ func ConvertKube(kube *parser.UnitFile, isUser bool) (*parser.UnitFile, error) {

addNetworks(kube, KubeGroup, service, execStart)

configMaps := kube.LookupAllStrv(KubeGroup, KeyConfigMap)
for _, configMap := range configMaps {
configMapPath, err := getAbsolutePath(kube, configMap)
if err != nil {
return nil, err
}
execStart.add("--configmap", configMapPath)
}

execStart.add(yamlPath)

service.AddCmdline(ServiceGroup, "ExecStart", execStart.Args)
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/quadlet/configmap.kube
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## assert-podman-args "--configmap" "/opt/k8s/abs.yml"
## assert-podman-args-regex "--configmap" ".*/podman_test.*/quadlet/rel.yml"

[Kube]
Yaml=deployment.yml
ConfigMap=rel.yml
ConfigMap=/opt/k8s/abs.yml
1 change: 1 addition & 0 deletions test/e2e/quadlet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ var _ = Describe("quadlet system generator", func() {
Entry("Kube - User Remap Auto with IDs", "remap-auto2.kube"),
Entry("Kube - Network", "network.kube"),
Entry("Kube - Quadlet Network", "network.quadlet.kube"),
Entry("Kube - ConfigMap", "configmap.kube"),

Entry("Network - Basic", "basic.network"),
Entry("Network - Label", "label.network"),
Expand Down

0 comments on commit 382c55e

Please sign in to comment.