Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generate systemd -e/--env option #15584

Merged
merged 1 commit into from Sep 6, 2022

Conversation

sstosh
Copy link
Contributor

@sstosh sstosh commented Sep 1, 2022

-e/--env option sets environment variables to the systemd unit files.

Fixes: #15523

Signed-off-by: Toshiki Sonoda sonoda.toshiki@fujitsu.com

Does this PR introduce a user-facing change?

Now we can use -e/--env option to sets environment variables to the systemd unit files.

docs/source/markdown/podman-generate-systemd.1.md Outdated Show resolved Hide resolved
pkg/domain/entities/generate.go Outdated Show resolved Hide resolved
pkg/systemd/generate/containers.go Outdated Show resolved Hide resolved
pkg/systemd/generate/containers.go Outdated Show resolved Hide resolved
pkg/bindings/generate/types.go Outdated Show resolved Hide resolved
pkg/api/handlers/libpod/generate.go Outdated Show resolved Hide resolved
@sstosh sstosh force-pushed the generate-systemd-env branch 5 times, most recently from b2b277a to cafa12d Compare September 2, 2022 09:18
@sstosh sstosh force-pushed the generate-systemd-env branch 2 times, most recently from a8d8e75 to 3335ccd Compare September 5, 2022 09:06
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
@containers/podman-maintainers PTAL

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add some new unit tests here:

func TestCreateContainerSystemdUnit(t *testing.T) {
to make sure you get exactly what you expect.

cmd/podman/generate/systemd.go Outdated Show resolved Hide resolved
cmd/podman/generate/systemd.go Outdated Show resolved Hide resolved
cmd/podman/generate/systemd.go Outdated Show resolved Hide resolved
docs/source/markdown/podman-generate-systemd.1.md Outdated Show resolved Hide resolved
pkg/bindings/generate/types.go Outdated Show resolved Hide resolved
test/e2e/generate_systemd_test.go Outdated Show resolved Hide resolved
@sstosh sstosh force-pushed the generate-systemd-env branch 2 times, most recently from 5944f6d to 03bb57d Compare September 6, 2022 05:52
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
@Luap99 PTAL

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry one thing I missed yesterday was that you have to escape the arguments if required, see

info.ExtraEnvs = append(info.ExtraEnvs, escapeSystemdArg(containerEnv))

and
Environment=FOO=abc "BAR=my test" USER=%%a

When the env var contains a space or a special character such as % the systemd unit would likely fail right now.

pkg/systemd/generate/containers.go Outdated Show resolved Hide resolved
@sstosh sstosh force-pushed the generate-systemd-env branch 3 times, most recently from fd978ac to a9a411f Compare September 6, 2022 11:17
-e/--env option sets environment variables to the systemd unit files.

Fixes: containers#15523

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
@rhatdan
Copy link
Member

rhatdan commented Sep 6, 2022

@Luap99 PTAL again.

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@Luap99
Copy link
Member

Luap99 commented Sep 6, 2022

/lgtm

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 6, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Luap99, sstosh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. labels Sep 6, 2022
@openshift-merge-robot openshift-merge-robot merged commit 4e06aa3 into containers:main Sep 6, 2022
@sstosh sstosh deleted the generate-systemd-env branch September 7, 2022 00:13
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

generate systemd creates a systemd unit file with proxy environment variables
5 participants