Skip to content

Commit

Permalink
docs: warn about using experimental features
Browse files Browse the repository at this point in the history
  • Loading branch information
favonia committed Sep 25, 2024
1 parent 57f6568 commit 9450ade
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 8 deletions.
4 changes: 4 additions & 0 deletions internal/config/env_notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ func ReadAndAppendShoutrrrURL(ppfmt pp.PP, key string, field *notifier.Notifier)
return true
}

ppfmt.Hintf(pp.HintExperimentalShoutrrr,
"You are using the experimental shoutrrr support added in 1.12.0. Please report bugs at %s",
pp.IssueReportingURL)

s, ok := notifier.NewShoutrrr(ppfmt, vals)
if !ok {
return false
Expand Down
15 changes: 11 additions & 4 deletions internal/config/env_notifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ func TestReadAndAppendShoutrrrURL(t *testing.T) {
t.Helper()
require.Nil(t, n)
},
true, nil,
true,
nil,
},
"empty": {
true, "", nil,
func(t *testing.T, n not) {
t.Helper()
require.Nil(t, n)
},
true, nil,
true,
nil,
},
"generic": {
true, "generic+https://example.com/api/v1/postStuff",
Expand All @@ -55,7 +57,9 @@ func TestReadAndAppendShoutrrrURL(t *testing.T) {
require.Equal(t, []string{"Generic"}, s.ServiceDescriptions)
},
true,
nil,
func(m *mocks.MockPP) {
m.EXPECT().Hintf(pp.HintExperimentalShoutrrr, "You are using the experimental shoutrrr support added in 1.12.0. Please report bugs at %s", pp.IssueReportingURL) //nolint:lll
},
},
"ill-formed": {
true, "meow-meow-meow://cute",
Expand All @@ -66,6 +70,7 @@ func TestReadAndAppendShoutrrrURL(t *testing.T) {
},
false,
func(m *mocks.MockPP) {
m.EXPECT().Hintf(pp.HintExperimentalShoutrrr, "You are using the experimental shoutrrr support added in 1.12.0. Please report bugs at %s", pp.IssueReportingURL) //nolint:lll
m.EXPECT().Noticef(pp.EmojiUserError, `Could not create shoutrrr client: %v`, gomock.Any())
},
},
Expand All @@ -82,7 +87,9 @@ func TestReadAndAppendShoutrrrURL(t *testing.T) {
require.Equal(t, []string{"Generic", "Pushover"}, s.ServiceDescriptions)
},
true,
nil,
func(m *mocks.MockPP) {
m.EXPECT().Hintf(pp.HintExperimentalShoutrrr, "You are using the experimental shoutrrr support added in 1.12.0. Please report bugs at %s", pp.IssueReportingURL) //nolint:lll
},
},
} {
t.Run(name, func(t *testing.T) {
Expand Down
3 changes: 3 additions & 0 deletions internal/config/env_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ func ReadProvider(ppfmt pp.PP, key, keyDeprecated string, field *provider.Provid
)
return false
}
ppfmt.Hintf(pp.HintExperimentalLocalWithInterface,
`You are using the experimental provider "local:%s" added in 1.15.0. Please report bugs at %s`,
parts[1], pp.IssueReportingURL)
*field = provider.NewLocalWithInterface(parts[1])
return true
case len(parts) == 2 && parts[0] == "url":
Expand Down
7 changes: 6 additions & 1 deletion internal/config/env_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,12 @@ func TestReadProvider(t *testing.T) {
"cloudflare.doh": {true, " \tcloudflare.doh ", false, "", none, doh, true, nil},
"none": {true, " none ", false, "", trace, none, true, nil},
"local": {true, " local ", false, "", trace, local, true, nil},
"local:lo": {true, " local : lo ", false, "", trace, localLoopback, true, nil},
"local:lo": {
true, " local : lo ", false, "", trace, localLoopback, true,
func(m *mocks.MockPP) {
m.EXPECT().Hintf(pp.HintExperimentalLocalWithInterface, `You are using the experimental provider "local:%s" added in 1.15.0. Please report bugs at %s`, "lo", pp.IssueReportingURL) //nolint:lll
},
},
"local:": {
true, " local: ", false, "", trace, trace, false,
func(m *mocks.MockPP) {
Expand Down
4 changes: 4 additions & 0 deletions internal/config/env_waf.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ func ReadAndAppendWAFListNames(ppfmt pp.PP, key string, field *[]api.WAFList) bo
return true
}

ppfmt.Hintf(pp.HintExperimentalWAF,
"You're using the new WAF list manipulation feature (added in 1.14.0). Please report bugs at %s",
pp.IssueReportingURL)

lists := make([]api.WAFList, 0, len(vals))

for _, val := range vals {
Expand Down
24 changes: 21 additions & 3 deletions internal/config/env_waf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,22 @@ func TestReadAndAppendWAFListNames(t *testing.T) {
nil,
[]api.WAFList{{AccountID: "hey", Name: "hello"}},
true,
nil,
func(m *mocks.MockPP) {
m.EXPECT().Hintf(pp.HintExperimentalWAF,
"You're using the new WAF list manipulation feature (added in 1.14.0). Please report bugs at %s",
pp.IssueReportingURL)
},
},
"two": {
true, "hey/hello,here/aloha",
nil,
[]api.WAFList{{AccountID: "hey", Name: "hello"}, {AccountID: "here", Name: "aloha"}},
true,
nil,
func(m *mocks.MockPP) {
m.EXPECT().Hintf(pp.HintExperimentalWAF,
"You're using the new WAF list manipulation feature (added in 1.14.0). Please report bugs at %s",
pp.IssueReportingURL)
},
},
"one+two": {
true, "hey/hello,here/aloha",
Expand All @@ -53,14 +61,21 @@ func TestReadAndAppendWAFListNames(t *testing.T) {
{AccountID: "here", Name: "aloha"},
},
true,
nil,
func(m *mocks.MockPP) {
m.EXPECT().Hintf(pp.HintExperimentalWAF,
"You're using the new WAF list manipulation feature (added in 1.14.0). Please report bugs at %s",
pp.IssueReportingURL)
},
},
"invalid-format": {
true, "+++",
[]api.WAFList{{AccountID: "there", Name: "ciao"}},
[]api.WAFList{{AccountID: "there", Name: "ciao"}},
false,
func(m *mocks.MockPP) {
m.EXPECT().Hintf(pp.HintExperimentalWAF,
"You're using the new WAF list manipulation feature (added in 1.14.0). Please report bugs at %s",
pp.IssueReportingURL)
m.EXPECT().Noticef(pp.EmojiUserError, `List %q should be in format "account-id/list-name"`, "+++")
},
},
Expand All @@ -75,6 +90,9 @@ func TestReadAndAppendWAFListNames(t *testing.T) {
},
true,
func(m *mocks.MockPP) {
m.EXPECT().Hintf(pp.HintExperimentalWAF,
"You're using the new WAF list manipulation feature (added in 1.14.0). Please report bugs at %s",
pp.IssueReportingURL)
m.EXPECT().Noticef(pp.EmojiUserWarning, "List name %q contains invalid character %q", "!!!", "!")
},
},
Expand Down
3 changes: 3 additions & 0 deletions internal/pp/hint.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ const (
HintMismatchedRecordAttributes
HintMismatchedWAFListAttributes
Hint1111Blockage
HintExperimentalShoutrrr // introduced in 1.12.0
HintExperimentalWAF // introduced in 1.14.0
HintExperimentalLocalWithInterface // introduced in 1.15.0
)

0 comments on commit 9450ade

Please sign in to comment.