Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
chenlin07 committed Oct 26, 2023
1 parent c105f6d commit c76752b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,21 +293,7 @@ func (r *AKODeploymentConfigReconciler) reconcileAviInfraSetting(
log.Info("ControlPlaneNetwork is empty in akoDeploymentConfig, skip creating AVIInfraSetting")
return res, nil
}
return res, r.Patch(ctx, r.createAviInfraSetting(adc), client.Apply, client.ForceOwnership, client.FieldOwner("field-owner"))
}

// AviInfraSetting is a top-level type
type AviInfraSetting struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec AviInfraSettingSpec `json:"spec,omitempty"`
}

type AviInfraSettingSpec struct {
Network akov1beta1.AviInfraSettingNetwork `json:"network,omitempty"`
SeGroup akov1beta1.AviInfraSettingSeGroup `json:"seGroup,omitempty"`
L7Settings akov1beta1.AviInfraL7Settings `json:"l7Settings,omitempty"`
NSXSettings *akov1beta1.AviInfraNSXSettings `json:"nsxSettings,omitempty"`
return res, r.Patch(ctx, r.createAviInfraSetting(adc), client.Apply, client.ForceOwnership, client.FieldOwner("akodeploymentconfig-controller"))
}

func (r *AKODeploymentConfigReconciler) createAviInfraSetting(adc *akoov1alpha1.AKODeploymentConfig) *unstructured.Unstructured {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2020 VMware, Inc.
// SPDX-License-Identifier: Apache-2.0

package akodeploymentconfig

import (
akov1beta1 "github.com/vmware/load-balancer-and-ingress-services-for-kubernetes/pkg/apis/ako/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// AviInfraSetting is a top-level type
type AviInfraSetting struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec AviInfraSettingSpec `json:"spec,omitempty"`
}

// AviInfraSettingSpec consists of the main AviInfraSetting settings
// Redefine AviInfraSettingSpec so that NSXSettings value is not required when reconciling AKODeploymentConfig
type AviInfraSettingSpec struct {
Network akov1beta1.AviInfraSettingNetwork `json:"network,omitempty"`
SeGroup akov1beta1.AviInfraSettingSeGroup `json:"seGroup,omitempty"`
L7Settings akov1beta1.AviInfraL7Settings `json:"l7Settings,omitempty"`
NSXSettings *akov1beta1.AviInfraNSXSettings `json:"nsxSettings,omitempty"`
}

0 comments on commit c76752b

Please sign in to comment.