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

quadlet: Handle booleans that have defaults better #16893

Conversation

alexlarsson
Copy link
Contributor

The ReadOnly and the RunInit keys affect options that have a variable default (configurable in containers.conf). This means we need to handle them a bit differently in quadlet to allow overriding the default. For example, we can't assume ReadOnly=false doesn't need to add any argument because no argument may mean read-only is enabled if the default is changed.

We now don't add any argument (leaving the default) if the key is not specified, or we always add an argument (--foo or --foo=false) if the key is specified (overriding whatever the default is).

None

We add a regular LookupBoolean that can fail lookups, which is used by
the WithDefault version. We want to use this directly later in some places.

It is fina to change API here because this has not been in a release yet.

Signed-off-by: Alexander Larsson <[email protected]>
The ReadOnly and the RunInit keys affect options that have a variable
default (configurable in containers.conf). This means we need to
handle them a bit differently in quadlet to allow overriding the
default. For example, we can't assume ReadOnly=false doesn't need to
add any argument because no argument may mean readonly=true if the default
is changed.

We now don't add any argument (leaving the default) if the key is not specified,
or we always add an argument (--foo or --foo=false) if the key is specified (overriding whatever the default is).

Signed-off-by: Alexander Larsson <[email protected]>
@alexlarsson
Copy link
Contributor Author

Weird CI error:

         not ok 223 [12-imagesMore] POST images/localhost:5000/myrepo/push?tag=mytag [-d {}] : .error
         #  expected: ~ .*x509: certificate signed by unknown authority
         #    actual: null

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

Re: API. It's an internal API of Podman, so we are free to break :)

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 20, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexlarsson, vrothberg

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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 20, 2022
}

// By default we handle startup notification with conmon, but allow passing it to the container with Notify=yes
notify := container.LookupBoolean(ContainerGroup, KeyNotify, false)
notify := container.LookupBooleanWithDefault(ContainerGroup, KeyNotify, false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since 'LookupBooleanreturnfalsewhen the key is not found. Is there any advantage of usingLookupBooleanWithDefaultwithfalse` as default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not technically, but it imho makes the code intention clearer.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK

@alexlarsson
Copy link
Contributor Author

Some CI network hickup it seems.

@ygalblum
Copy link
Contributor

LGTM

@rhatdan
Copy link
Member

rhatdan commented Dec 20, 2022

/lgtm
/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 20, 2022
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 20, 2022
@rhatdan
Copy link
Member

rhatdan commented Dec 21, 2022

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 21, 2022
@openshift-merge-robot openshift-merge-robot merged commit 90ba443 into containers:main Dec 21, 2022
@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 17, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 17, 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-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants