Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ require (
go.uber.org/automaxprocs v1.6.0
go.uber.org/zap v1.27.1
golang.org/x/crypto v0.50.0
golang.org/x/net v0.53.0
golang.org/x/sync v0.20.0
golang.org/x/time v0.14.0
gopkg.in/ini.v1 v1.67.1
Expand Down Expand Up @@ -108,7 +109,6 @@ require (
go.yaml.in/yaml/v2 v2.4.4 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/mod v0.35.0 // indirect
golang.org/x/net v0.53.0 // indirect
golang.org/x/oauth2 v0.36.0 // indirect
golang.org/x/sys v0.43.0 // indirect
golang.org/x/term v0.42.0 // indirect
Expand Down
11 changes: 11 additions & 0 deletions pkg/clean/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/vmware-tanzu/nsx-operator/pkg/logger"
"github.com/vmware-tanzu/nsx-operator/pkg/nsx"
"github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/common"
"github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/dns"
"github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/inventory"
"github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/ipaddressallocation"
"github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/nsxserviceaccount"
Expand Down Expand Up @@ -115,6 +116,10 @@ func InitializeCleanupService(cf *config.NSXOperatorConfig, nsxClient *nsx.Clien
if err != nil {
return nil, err
}
dnsRecordService, err := dns.InitializeDNSRecordService(commonService, vpcService)
if err != nil {
return nil, err
}
subnetPortService, err := subnetport.InitializeSubnetPort(commonService, vpcService, ipAddressAllocationService)
if err != nil {
return nil, err
Expand Down Expand Up @@ -155,6 +160,11 @@ func InitializeCleanupService(cf *config.NSXOperatorConfig, nsxClient *nsx.Clien
return ipAddressAllocationService, nil
}
}
wrapInitializeDNSRecordService := func(service common.Service) cleanupFunc {
return func() (interface{}, error) {
return dnsRecordService, nil
}
}
wrapInitializeSubnetBinding := func(service common.Service) cleanupFunc {
return func() (interface{}, error) {
return subnetbinding.InitializeService(service)
Expand Down Expand Up @@ -213,6 +223,7 @@ func InitializeCleanupService(cf *config.NSXOperatorConfig, nsxClient *nsx.Clien
loggedAdd("StaticRoute", wrapInitializeStaticRoute(commonService))
loggedAdd("VPC", wrapInitializeVPC(commonService))
loggedAdd("IPAddressAllocation", wrapInitializeIPAddressAllocation(commonService))
loggedAdd("DNSRecord", wrapInitializeDNSRecordService(commonService))
loggedAdd("Inventory", wrapInitializeInventory(commonService))
loggedAdd("LBInfraCleaner", wrapInitializeLBInfraCleaner(commonService))
loggedAdd("HealthCleaner", wrapInitializeHealthCleaner(commonService))
Expand Down
9 changes: 8 additions & 1 deletion pkg/clean/clean_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/vmware-tanzu/nsx-operator/pkg/config"
"github.com/vmware-tanzu/nsx-operator/pkg/nsx"
"github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/common"
"github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/dns"
"github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/inventory"
"github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/ipaddressallocation"
"github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/nsxserviceaccount"
Expand Down Expand Up @@ -187,6 +188,9 @@ func TestInitializeCleanupService_Success(t *testing.T) {
patches.ApplyFunc(ipaddressallocation.InitializeIPAddressAllocation, func(service common.Service, vpcService common.VPCServiceProvider, flag bool) (*ipaddressallocation.IPAddressAllocationService, error) {
return &ipaddressallocation.IPAddressAllocationService{}, nil
})
patches.ApplyFunc(dns.InitializeDNSRecordService, func(service common.Service, vpcService common.VPCServiceProvider) (*dns.DNSRecordService, error) {
return &dns.DNSRecordService{}, nil
})
patches.ApplyFunc(subnetbinding.InitializeService, func(service common.Service) (*subnetbinding.BindingService, error) {
return &subnetbinding.BindingService{}, nil
})
Expand Down Expand Up @@ -216,7 +220,7 @@ func TestInitializeCleanupService_Success(t *testing.T) {
// vpcPreCleaners: SubnetPort, SubnetBinding, SubnetIPReservation, Inventory, SecurityPolicy, LBInfraCleaner, NSXServiceAccount, HealthCleaner = 8
assert.Len(t, cleanupService.vpcPreCleaners, 7)
assert.Len(t, cleanupService.vpcChildrenCleaners, 5)
assert.Len(t, cleanupService.infraCleaners, 2)
assert.Len(t, cleanupService.infraCleaners, 3)
}

func TestInitializeCleanupService_VPCError(t *testing.T) {
Expand Down Expand Up @@ -245,6 +249,9 @@ func TestInitializeCleanupService_VPCError(t *testing.T) {
patches.ApplyFunc(ipaddressallocation.InitializeIPAddressAllocation, func(service common.Service, vpcService common.VPCServiceProvider, flag bool) (*ipaddressallocation.IPAddressAllocationService, error) {
return &ipaddressallocation.IPAddressAllocationService{}, nil
})
patches.ApplyFunc(dns.InitializeDNSRecordService, func(service common.Service, vpcService common.VPCServiceProvider) (*dns.DNSRecordService, error) {
return &dns.DNSRecordService{}, nil
})
patches.ApplyFunc(subnetbinding.InitializeService, func(service common.Service) (*subnetbinding.BindingService, error) {
return &subnetbinding.BindingService{}, nil
})
Expand Down
127 changes: 127 additions & 0 deletions pkg/mock/dnsrecordprovider/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pkg/mock/dnsrecordprovider/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Package mocks provides MockDNSRecordProvider for dns.DNSRecordProvider.
// client.go is hand-written: github.com/golang/mock/mockgen@v1.6 cannot parse generic sets.Set in interface methods.
package mocks
108 changes: 108 additions & 0 deletions pkg/mock/dnsrecordsclient/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/mock/dnsrecordsclient/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Package mocks contains a generated mock for projects.DnsRecordsClient.
//
//go:generate go run github.com/golang/mock/mockgen@v1.6.0 -destination=client.go -package=mocks github.com/vmware/vsphere-automation-sdk-go/services/nsxt/orgs/projects DnsRecordsClient
package mocks
Loading
Loading