This commit is contained in:
Mangirdas Judeikis 2021-08-10 08:52:38 +01:00
Родитель 853a637c38
Коммит bc49980ffa
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: AA071F630E926BBD
6 изменённых файлов: 26 добавлений и 40 удалений

Просмотреть файл

@ -146,7 +146,7 @@ func New(ctx context.Context, log *logrus.Entry, _env env.Interface, db database
dns: dns.NewManager(_env, localFPAuthorizer),
storage: storage,
subnet: subnet.NewManager(_env, r.SubscriptionID, fpAuthorizer),
subnet: subnet.NewManager(_env.Environment(), r.SubscriptionID, fpAuthorizer),
graph: graph.NewManager(log, aead, storage),
}, nil
}

Просмотреть файл

@ -9,7 +9,6 @@ import (
"testing"
mgmtnetwork "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2019-07-01/network"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/to"
"github.com/golang/mock/gomock"
machinev1beta1 "github.com/openshift/machine-api-operator/pkg/apis/machine/v1beta1"
@ -19,25 +18,19 @@ import (
azureproviderv1beta1 "sigs.k8s.io/cluster-api-provider-azure/pkg/apis/azureprovider/v1beta1"
arov1alpha1 "github.com/Azure/ARO-RP/pkg/operator/apis/aro.openshift.io/v1alpha1"
mocksubnet "github.com/Azure/ARO-RP/pkg/util/mocks/subnet"
mock_subnet "github.com/Azure/ARO-RP/pkg/util/mocks/subnet"
"github.com/Azure/ARO-RP/pkg/util/subnet"
)
var (
subscriptionId = "0000000-0000-0000-0000-000000000000"
vnet = azure.Resource{
SubscriptionID: subscriptionId,
ResourceGroup: "vnet-rg",
ResourceName: "vnet-name",
}
clusterResourceGroupName = "aro-iljrzb5a"
infraId = "abcd"
clusterResourceGroupId = "/subscriptions/" + subscriptionId + "/resourcegroups/" + clusterResourceGroupName
vnetResourceGroup = "vnet-rg"
vnetResourceGroupResourceId = "/subscriptions/" + subscriptionId + "/resourcegroups/" + vnetResourceGroup
vnetName = "vnet"
subnetNameWorker = "worker"
subnetNameMaster = "master"
subscriptionId = "0000000-0000-0000-0000-000000000000"
clusterResourceGroupName = "aro-iljrzb5a"
infraId = "abcd"
clusterResourceGroupId = "/subscriptions/" + subscriptionId + "/resourcegroups/" + clusterResourceGroupName
vnetResourceGroup = "vnet-rg"
vnetName = "vnet"
subnetNameWorker = "worker"
subnetNameMaster = "master"
nsgv1NodeResourceId = clusterResourceGroupId + "/providers/Microsoft.Network/networkSecurityGroups/" + infraId + subnet.NSGNodeSuffixV1
nsgv1MasterResourceId = clusterResourceGroupId + "/providers/Microsoft.Network/networkSecurityGroups/" + infraId + subnet.NSGControlPlaneSuffixV1
@ -54,15 +47,6 @@ func getValidClusterInstance() *arov1alpha1.Cluster {
}
}
func getValidWorkerMachine() *machinev1beta1.Machine {
return &machinev1beta1.Machine{
ObjectMeta: metav1.ObjectMeta{
Name: "worker",
Namespace: machineSetsNamespace,
},
}
}
func getValidSubnet() *mgmtnetwork.Subnet {
return &mgmtnetwork.Subnet{
SubnetPropertiesFormat: &mgmtnetwork.SubnetPropertiesFormat{
@ -109,7 +93,7 @@ func TestReconcileManager(t *testing.T) {
for _, tt := range []struct {
name string
subnetMock func(*mocksubnet.MockManager)
subnetMock func(*mock_subnet.MockManager)
maocli func() (*maofake.Clientset, error)
instance func(*arov1alpha1.Cluster)
wantErr error
@ -129,7 +113,7 @@ func TestReconcileManager(t *testing.T) {
return maofake.NewSimpleClientset(machine1, machine2), nil
},
subnetMock: func(mock *mocksubnet.MockManager) {
subnetMock: func(mock *mock_subnet.MockManager) {
resourceId := "/subscriptions/" + subscriptionId + "/resourceGroups/" + vnetResourceGroup + "/providers/Microsoft.Network/virtualNetworks/" + vnetName + "/subnets/" + subnetNameMaster
subnetObjectMaster := getValidSubnet()
@ -156,7 +140,7 @@ func TestReconcileManager(t *testing.T) {
return maofake.NewSimpleClientset(machine1, machine2), nil
},
subnetMock: func(mock *mocksubnet.MockManager) {
subnetMock: func(mock *mock_subnet.MockManager) {
resourceId := "/subscriptions/" + subscriptionId + "/resourceGroups/" + vnetResourceGroup + "/providers/Microsoft.Network/virtualNetworks/" + vnetName + "/subnets/" + subnetNameMaster
subnetObjectMaster := getValidSubnet()
@ -192,7 +176,7 @@ func TestReconcileManager(t *testing.T) {
return maofake.NewSimpleClientset(machine1, machine2), nil
},
subnetMock: func(mock *mocksubnet.MockManager) {
subnetMock: func(mock *mock_subnet.MockManager) {
resourceId := "/subscriptions/" + subscriptionId + "/resourceGroups/" + vnetResourceGroup + "/providers/Microsoft.Network/virtualNetworks/" + vnetName + "/subnets/" + subnetNameMaster
subnetObjectMaster := getValidSubnet()
@ -223,7 +207,7 @@ func TestReconcileManager(t *testing.T) {
return maofake.NewSimpleClientset(machine1, machine2), nil
},
subnetMock: func(mock *mocksubnet.MockManager) {
subnetMock: func(mock *mock_subnet.MockManager) {
resourceId := "/subscriptions/" + subscriptionId + "/resourceGroups/" + vnetResourceGroup + "/providers/Microsoft.Network/virtualNetworks/" + vnetName + "/subnets/" + subnetNameMaster
subnetObjectMaster := getValidSubnet()
@ -254,7 +238,7 @@ func TestReconcileManager(t *testing.T) {
return maofake.NewSimpleClientset(machine1, machine2), nil
},
subnetMock: func(mock *mocksubnet.MockManager) {
subnetMock: func(mock *mock_subnet.MockManager) {
resourceId := "/subscriptions/" + subscriptionId + "/resourceGroups/" + vnetResourceGroup + "/providers/Microsoft.Network/virtualNetworks/" + vnetName + "/subnets/" + subnetNameMaster
subnetObjectMaster := getValidSubnet()
@ -283,7 +267,7 @@ func TestReconcileManager(t *testing.T) {
controller := gomock.NewController(t)
defer controller.Finish()
manager := mocksubnet.NewMockManager(controller)
manager := mock_subnet.NewMockManager(controller)
if tt.subnetMock != nil {
tt.subnetMock(manager)
}

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -50,11 +50,15 @@ spec:
content:
type: string
type: object
clusterResourceGroupId:
type: string
domain:
type: string
features:
description: FeaturesSpec defines ARO operator feature gates
properties:
ReconcileSubnets:
type: boolean
reconcileAlertWebhook:
type: boolean
reconcileBanner:
@ -67,8 +71,6 @@ spec:
type: boolean
reconcileMonitoringConfig:
type: boolean
reconcileNSGs:
type: boolean
reconcileNodeDrainer:
type: boolean
reconcilePullSecret:

Просмотреть файл

@ -49,7 +49,7 @@ func NewResourceCleaner(log *logrus.Entry, env env.Core, shouldDelete checkFn, d
privatelinkservicescli: network.NewPrivateLinkServicesClient(env.Environment(), env.SubscriptionID(), authorizer),
securitygroupscli: network.NewSecurityGroupsClient(env.Environment(), env.SubscriptionID(), authorizer),
subnet: subnet.NewManager(env, env.SubscriptionID(), authorizer),
subnet: subnet.NewManager(env.Environment(), env.SubscriptionID(), authorizer),
// ShouldDelete decides whether the resource group gets deleted
shouldDelete: shouldDelete,

Просмотреть файл

@ -15,7 +15,7 @@ import (
"github.com/apparentlymart/go-cidr/cidr"
"github.com/Azure/ARO-RP/pkg/api"
"github.com/Azure/ARO-RP/pkg/env"
"github.com/Azure/ARO-RP/pkg/util/azureclient"
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/network"
)
@ -29,9 +29,9 @@ type manager struct {
subnets network.SubnetsClient
}
func NewManager(env env.Core, subscriptionID string, spAuthorizer autorest.Authorizer) Manager {
func NewManager(azEnv *azureclient.AROEnvironment, subscriptionID string, spAuthorizer autorest.Authorizer) Manager {
return &manager{
subnets: network.NewSubnetsClient(env.Environment(), subscriptionID, spAuthorizer),
subnets: network.NewSubnetsClient(azEnv, subscriptionID, spAuthorizer),
}
}