Conversation
…kahead
only_os is matched against sysinfo's OS.Name, which is os-release's
PRETTY_NAME; os-release's ID lands in OS.Vendor and nothing reads it. So
every lowercase example in the README ('ubuntu', 'opensuse-leap') matches
nothing, and a reader who copies one gets a stage that silently never runs.
The 'everything but ubuntu' example is worse than wrong: Go's regexp is RE2,
which has no lookahead, so '^(?!ubuntu).*' fails to compile and OnlyIfOS
returns the compile error rather than any OS verdict.
Tests pin both. The first pair derives its patterns from the host's own
/etc/os-release and asserts only_os matches PRETTY_NAME and does not match
ID, so pointing OnlyIfOS at OS.Vendor fails them. The second compiles every
only_os, only_os_version and only_arch pattern the README documents, so a
documented lookahead cannot stay documented.
Signed-off-by: mudler-agent <105103991+ci-robbot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
only_osis matched against sysinfo'sOS.Name, and sysinfo puts os-release'sPRETTY_NAMEthere.IDgoes toOS.Vendor, which nothing reads(
zcalusic/sysinfo@v1.1.3/os.go). The README says the opposite, so:only_os: "ubuntu|opensuse-leap",only_os: "ubuntu") matches nothing. A reader who copies one gets a stagethat never runs, and the debug line says "doesn't match os name", naming a
string they did not write a pattern for;
only_os: "^(?!ubuntu).*"is worse than not matching. Go's regexp is RE2,which has no lookahead, so it fails to compile and
OnlyIfOSreturns thecompile error instead of an OS verdict.
Checked on this host (
ID=alpine,PRETTY_NAME="Alpine Linux v3.24"):only_os_versionwas documented correctly:VERSION_IDdoes land inOS.Version.Tests.
pkg/plugins/if_os_fields_test.go:/etc/os-releaseand assertonly_osmatches its
PRETTY_NAMEand does not match itsID, skipping if the hostcannot tell the two apart. Pointing
OnlyIfOSatOS.Vendorfails both;only_os_versionmatchesVERSION_ID;documented lookahead cannot stay documented. Restoring
^(?!ubuntu).*failsit.
Found while migrating kairos-io/kairos's bundled cloudconfigs onto
only_os(kairos-io/kairos#4696), where the docs sent me to the wrong field.