From e1cd4f2b98d5e6d1e25455950ea8b49191fe7e88 Mon Sep 17 00:00:00 2001 From: louiseschmidtgen Date: Wed, 5 Jun 2024 09:39:38 +0200 Subject: [PATCH] put some fakes --- .../pkg/k8sd/features/fake/load-balancer.go | 13 +++++++++++++ src/k8s/pkg/k8sd/features/fake/network.go | 18 ++++++++++++++++++ .../k8sd/features/implementation_default.go | 10 +++++----- 3 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 src/k8s/pkg/k8sd/features/fake/load-balancer.go create mode 100644 src/k8s/pkg/k8sd/features/fake/network.go diff --git a/src/k8s/pkg/k8sd/features/fake/load-balancer.go b/src/k8s/pkg/k8sd/features/fake/load-balancer.go new file mode 100644 index 000000000..76cee1154 --- /dev/null +++ b/src/k8s/pkg/k8sd/features/fake/load-balancer.go @@ -0,0 +1,13 @@ +package fake + +import ( + "context" + + "github.com/canonical/k8s/pkg/k8sd/types" + "github.com/canonical/k8s/pkg/snap" +) + +// ApplyLoadBalancer is a dummy implementation of the ApplyLoadBalancer function. It does nothing and returns nil. +func ApplyLoadBalancer(ctx context.Context, snap snap.Snap, loadbalancer types.LoadBalancer, network types.Network, _ types.Annotations) error { + return nil +} diff --git a/src/k8s/pkg/k8sd/features/fake/network.go b/src/k8s/pkg/k8sd/features/fake/network.go new file mode 100644 index 000000000..863504113 --- /dev/null +++ b/src/k8s/pkg/k8sd/features/fake/network.go @@ -0,0 +1,18 @@ +package fake + +import ( + "context" + + "github.com/canonical/k8s/pkg/k8sd/types" + "github.com/canonical/k8s/pkg/snap" +) + +// ApplyNetwork is a dummy implementation of the ApplyNetwork function. It does nothing and returns nil. +func ApplyNetwork(ctx context.Context, snap snap.Snap, cfg types.Network, _ types.Annotations) error { + return nil +} + +// CheckNetwork is a dummy implementation of the CheckNetwork function. It does nothing and returns true. +func CheckNetwork(ctx context.Context, snap snap.Snap) (bool, error) { + return true, nil +} diff --git a/src/k8s/pkg/k8sd/features/implementation_default.go b/src/k8s/pkg/k8sd/features/implementation_default.go index bec54918f..288ab455f 100644 --- a/src/k8s/pkg/k8sd/features/implementation_default.go +++ b/src/k8s/pkg/k8sd/features/implementation_default.go @@ -1,9 +1,9 @@ package features import ( - "github.com/canonical/k8s/pkg/k8sd/features/cilium" "github.com/canonical/k8s/pkg/k8sd/features/contour" "github.com/canonical/k8s/pkg/k8sd/features/coredns" + "github.com/canonical/k8s/pkg/k8sd/features/fake" "github.com/canonical/k8s/pkg/k8sd/features/localpv" metrics_server "github.com/canonical/k8s/pkg/k8sd/features/metrics-server" ) @@ -15,9 +15,9 @@ import ( // LocalPV Rawfile CSI is used for local-storage. var Implementation Interface = &implementation{ applyDNS: coredns.ApplyDNS, - applyNetwork: cilium.ApplyNetwork, - applyLoadBalancer: cilium.ApplyLoadBalancer, - applyIngress: contour.ApplyIngress, //TODO: remove default overwrite for testing + applyNetwork: fake.ApplyNetwork, //TODO: remove default overwrite for testing + applyLoadBalancer: fake.ApplyLoadBalancer, + applyIngress: contour.ApplyIngress, applyGateway: contour.ApplyGateway, applyMetricsServer: metrics_server.ApplyMetricsServer, applyLocalStorage: localpv.ApplyLocalStorage, @@ -25,6 +25,6 @@ var Implementation Interface = &implementation{ // StatusChecks implements the Canonical Kubernetes built-in feature status checks. var StatusChecks StatusInterface = &statusChecks{ - checkNetwork: cilium.CheckNetwork, + checkNetwork: fake.CheckNetwork, checkDNS: coredns.CheckDNS, }