@@ -21,61 +21,38 @@ const (
2121 defaultMultusNamespace = metav1 .NamespaceSystem
2222)
2323
24- type MultusDeployer struct {
25- client ctrlclient.Client
26- helmChartInfoGetter * config.HelmChartGetter
24+ type helmAddonStrategy struct {
25+ client ctrlclient.Client
26+ helmChart * config.HelmChart
2727}
2828
29- func NewMultusDeployer (client ctrlclient.Client , helmChartInfoGetter * config.HelmChartGetter ) * MultusDeployer {
30- return & MultusDeployer {
31- client : client ,
32- helmChartInfoGetter : helmChartInfoGetter ,
29+ func newHelmAddonStrategy (client ctrlclient.Client , helmChart * config.HelmChart ) helmAddonStrategy {
30+ return helmAddonStrategy {
31+ client : client ,
32+ helmChart : helmChart ,
3333 }
3434}
3535
36- func (m * MultusDeployer ) Deploy (
36+ func (s helmAddonStrategy ) apply (
3737 ctx context.Context ,
3838 cluster * clusterv1.Cluster ,
3939 readinessSocketPath string ,
40- targetNamespace string ,
40+ defaultsNamespace string ,
4141 log logr.Logger ,
4242) error {
43- // Check if Multus deployment is supported for this cloud provider
44- isSupported , providerName := m .isCloudProviderSupported (cluster )
45-
46- // Currently, Multus is only supported for EKS and Nutanix clusters
47- if ! isSupported {
48- log .Info ("Multus deployment is only supported for EKS and Nutanix clusters. Skipping deployment." )
49- return nil
50- }
51-
52- log .Info (fmt .Sprintf ("Cluster is %s. Proceeding with Multus deployment." , providerName ))
53-
54- // Get Multus Helm chart info
55- helmChart , err := m .helmChartInfoGetter .For (ctx , log , config .Multus )
56- if err != nil {
57- // For local testing, provide a placeholder chart info
58- log .Info ("Multus not found in helm-config.yaml, using placeholder chart info for local development" )
59- helmChart = & config.HelmChart {
60- Name : "multus" ,
61- Version : "dev" ,
62- Repository : "" ,
63- }
64- }
65-
6643 // Deploy Multus using HelmAddonApplier with template function
6744 strategy := addons .NewHelmAddonApplier (
6845 addons .NewHelmAddonConfig (
6946 "default-multus-values-template" ,
7047 defaultMultusNamespace ,
7148 defaultMultusReleaseName ,
7249 ),
73- m .client ,
74- helmChart ,
50+ s .client ,
51+ s . helmChart ,
7552 ).WithValueTemplater (templateValuesFunc (readinessSocketPath )).
7653 WithDefaultWaiter ()
7754
78- if err := strategy .Apply (ctx , cluster , targetNamespace , log ); err != nil {
55+ if err := strategy .Apply (ctx , cluster , defaultsNamespace , log ); err != nil {
7956 return fmt .Errorf ("failed to apply Multus deployment: %w" , err )
8057 }
8158
@@ -85,7 +62,7 @@ func (m *MultusDeployer) Deploy(
8562
8663// isCloudProviderSupported checks if the cluster is a supported cloud provider
8764// by inspecting the infrastructure reference.
88- func ( m * MultusDeployer ) isCloudProviderSupported (cluster * clusterv1.Cluster ) (
65+ func isCloudProviderSupported (cluster * clusterv1.Cluster ) (
8966 isSupported bool ,
9067 providerName string ,
9168) {
0 commit comments