mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2026-03-01 05:51:00 +01:00
feat(pihole): deprecate v5 API support (#6123)
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
This commit is contained in:
parent
ee87a9a991
commit
7579ce231c
@ -22,6 +22,7 @@ import (
|
||||
"slices"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"sigs.k8s.io/external-dns/endpoint"
|
||||
"sigs.k8s.io/external-dns/plan"
|
||||
@ -32,6 +33,10 @@ import (
|
||||
// in the environment.
|
||||
var ErrNoPiholeServer = errors.New("no pihole server found in the environment or flags")
|
||||
|
||||
const (
|
||||
warningMsg = "Pi-hole v5 API support is deprecated. Set --pihole-api-version=\"6\" to use the Pi-hole v6 API. The v5 API will be removed in a future release."
|
||||
)
|
||||
|
||||
// PiholeProvider is an implementation of Provider for Pi-hole Local DNS.
|
||||
type PiholeProvider struct {
|
||||
provider.BaseProvider
|
||||
@ -69,6 +74,7 @@ func NewPiholeProvider(cfg PiholeConfig) (*PiholeProvider, error) {
|
||||
case "6":
|
||||
api, err = newPiholeClientV6(cfg)
|
||||
default:
|
||||
log.Warn(warningMsg)
|
||||
api, err = newPiholeClient(cfg)
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
@ -21,7 +21,10 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/require"
|
||||
"sigs.k8s.io/external-dns/endpoint"
|
||||
"sigs.k8s.io/external-dns/internal/testutils"
|
||||
"sigs.k8s.io/external-dns/plan"
|
||||
)
|
||||
|
||||
@ -81,6 +84,42 @@ func TestNewPiholeProvider(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewPiholeProvider_APIVersions(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
config PiholeConfig
|
||||
wantMsg bool
|
||||
}{
|
||||
{
|
||||
name: "API version 5 with server",
|
||||
config: PiholeConfig{
|
||||
APIVersion: "5",
|
||||
Server: "test.example.com",
|
||||
},
|
||||
wantMsg: true,
|
||||
},
|
||||
{
|
||||
name: "API version 6 with server",
|
||||
config: PiholeConfig{
|
||||
APIVersion: "6",
|
||||
Server: "test.example.com",
|
||||
},
|
||||
wantMsg: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
hook := testutils.LogsUnderTestWithLogLevel(log.DebugLevel, t)
|
||||
_, err := NewPiholeProvider(tt.config)
|
||||
require.NoError(t, err)
|
||||
if tt.wantMsg {
|
||||
testutils.TestHelperLogContains(warningMsg, hook, t)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestProvider_InitialState(t *testing.T) {
|
||||
requests := requestTracker{}
|
||||
p := &PiholeProvider{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user