Skip to content

Commit 66c5a80

Browse files
Steve Ramageclaude
andcommitted
feat: flag deprecated IPMasquerade= boolean values
A second user of the deprecation layer, found by scanning systemd.network(5): the boolean forms of IPMasquerade= "are now deprecated. Please use one of the values above" (ipv4/ipv6/both/no). The validator already enumerated the eleven boolean aliases as accepted values; mark them deprecated so they get the weak warning (truthy -> use "ipv4", falsy -> use "no"). Demonstrates the layer is generic across grammars, not AF-specific. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 17f263b commit 66c5a80

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/main/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/optionvalues/ai/ConfigParseIpMasqueradeOptionValue.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ class ConfigParseIpMasqueradeOptionValue : SimpleGrammarOptionValues(
2222
"1", "yes", "y", "true", "t", "on",
2323
// Deprecated boolean false values (map to no)
2424
"0", "n", "false", "f", "off"
25+
).deprecating(
26+
// systemd.network(5): the boolean forms "are now deprecated. Please use one of the
27+
// values above" (ipv4/ipv6/both/no). Still accepted; the truthy forms map to ipv4.
28+
buildMap {
29+
for (t in listOf("1", "yes", "y", "true", "t", "on")) {
30+
put(t, "Boolean values for IPMasquerade= are deprecated; use \"ipv4\" (or \"ipv6\"/\"both\") instead.")
31+
}
32+
for (f in listOf("0", "n", "false", "f", "off")) {
33+
put(f, "Boolean values for IPMasquerade= are deprecated; use \"no\" instead.")
34+
}
35+
}
2536
),
2637
EOF()
2738
)

src/test/kotlin/net/sjrx/intellij/plugins/systemdunitfiles/semanticdata/optionvalues/grammar/DeprecationsTest.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar
22

33
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.ai.ConfigParseAddressFamiliesOptionValue
4+
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.ai.ConfigParseIpMasqueradeOptionValue
45
import org.junit.Assert.assertEquals
56
import org.junit.Assert.assertTrue
67
import org.junit.Test
@@ -31,4 +32,15 @@ class DeprecationsTest {
3132
// No full parse -> nothing (the InvalidValue inspection handles the error instead).
3233
assertTrue(grammar.deprecatedTokens("AF_DECnet AF_BOGUS").isEmpty())
3334
}
35+
36+
@Test
37+
fun testIpMasqueradeBooleanValuesAreDeprecated() {
38+
// A second, unrelated user of the same layer: the legacy boolean forms of IPMasquerade= are
39+
// accepted but deprecated in favour of ipv4/ipv6/both/no.
40+
val ipMasquerade = ConfigParseIpMasqueradeOptionValue().combinator
41+
assertTrue(ipMasquerade.deprecatedTokens("true").single().message.contains("ipv4"))
42+
assertTrue(ipMasquerade.deprecatedTokens("off").single().message.contains("no"))
43+
assertTrue(ipMasquerade.deprecatedTokens("ipv4").isEmpty())
44+
assertTrue(ipMasquerade.deprecatedTokens("both").isEmpty())
45+
}
3446
}

0 commit comments

Comments
 (0)