Skip to content

Commit

Permalink
Merge branch 'master' into feature/mysql-secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
babbageclunk authored Jul 9, 2021
2 parents 621ba2b + 5df37e7 commit f56cdfb
Show file tree
Hide file tree
Showing 31 changed files with 396 additions and 195 deletions.
2 changes: 1 addition & 1 deletion hack/generated/controllers/crd_cosmosdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func Test_CosmosDB_CRUD(t *testing.T) {
Location: &tc.AzureRegion,
Owner: testcommon.AsOwner(rg.ObjectMeta),
Kind: &kind,
DatabaseAccountOfferType: documentdb.DatabaseAccountsSpecPropertiesDatabaseAccountOfferTypeStandard,
DatabaseAccountOfferType: documentdb.DatabaseAccountCreateUpdatePropertiesDatabaseAccountOfferTypeStandard,
Locations: []documentdb.Location{
{
LocationName: &tc.AzureRegion,
Expand Down
2 changes: 1 addition & 1 deletion hack/generated/controllers/crd_disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func Test_Disk_CRUD(t *testing.T) {

// Perform a simple patch.
patcher := tc.NewResourcePatcher(disk)
networkAccessPolicy := compute.DisksSpecPropertiesNetworkAccessPolicyDenyAll
networkAccessPolicy := compute.DiskPropertiesNetworkAccessPolicyDenyAll
disk.Spec.NetworkAccessPolicy = &networkAccessPolicy
patcher.Patch(disk)

Expand Down
37 changes: 18 additions & 19 deletions hack/generated/controllers/crd_networking_loadbalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/Azure/go-autorest/autorest/to"

network "github.com/Azure/azure-service-operator/hack/generated/_apis/microsoft.network/v1alpha1api20201101"
"github.com/Azure/azure-service-operator/hack/generated/pkg/genruntime"
"github.com/Azure/azure-service-operator/hack/generated/pkg/testcommon"
Expand All @@ -29,9 +31,9 @@ func Test_LoadBalancer_CRUD(t *testing.T) {

// Public IP Address
sku := network.PublicIPAddressSkuNameStandard
publicIPAddress := &network.PublicIPAddresses{
publicIPAddress := &network.PublicIPAddress{
TypeMeta: metav1.TypeMeta{
Kind: reflect.TypeOf(network.PublicIPAddresses{}).Name(),
Kind: reflect.TypeOf(network.PublicIPAddress{}).Name(),
},
ObjectMeta: tc.MakeObjectMetaWithName(tc.Namer.GenerateName("publicip")),
Spec: network.PublicIPAddresses_Spec{
Expand All @@ -40,7 +42,7 @@ func Test_LoadBalancer_CRUD(t *testing.T) {
Sku: &network.PublicIPAddressSku{
Name: &sku,
},
PublicIPAllocationMethod: network.PublicIPAddressesSpecPropertiesPublicIPAllocationMethodStatic,
PublicIPAllocationMethod: network.PublicIPAddressPropertiesFormatPublicIPAllocationMethodStatic,
},
}

Expand All @@ -50,6 +52,7 @@ func Test_LoadBalancer_CRUD(t *testing.T) {
loadBalancerSku := network.LoadBalancerSkuNameStandard
lbName := tc.Namer.GenerateName("loadbalancer")
lbFrontendName := "LoadBalancerFrontend"
protocol := network.InboundNatPoolPropertiesFormatProtocolTcp
loadBalancer := &network.LoadBalancer{
ObjectMeta: tc.MakeObjectMetaWithName(lbName),
Spec: network.LoadBalancers_Spec{
Expand All @@ -58,32 +61,28 @@ func Test_LoadBalancer_CRUD(t *testing.T) {
Sku: &network.LoadBalancerSku{
Name: &loadBalancerSku,
},
FrontendIPConfigurations: []network.FrontendIPConfiguration{
FrontendIPConfigurations: []network.LoadBalancers_Spec_Properties_FrontendIPConfigurations{
{
Name: lbFrontendName,
Properties: &network.FrontendIPConfigurationPropertiesFormat{
PublicIPAddress: &network.SubResource{
Reference: tc.MakeReferenceFromResource(publicIPAddress),
},
PublicIPAddress: &network.SubResource{
Reference: tc.MakeReferenceFromResource(publicIPAddress),
},
},
},
// TODO: The below stuff isn't really necessary for LB CRUD but is required for VMSS...
InboundNatPools: []network.InboundNatPool{
InboundNatPools: []network.LoadBalancers_Spec_Properties_InboundNatPools{
{
Name: "MyFancyNatPool",
Properties: &network.InboundNatPoolPropertiesFormat{
FrontendIPConfiguration: network.SubResource{
Reference: genruntime.ResourceReference{
// TODO: This is still really awkward
ARMID: tc.MakeARMId(rg.Name, "Microsoft.Network", "loadBalancers", lbName, "frontendIPConfigurations", lbFrontendName),
},
FrontendIPConfiguration: &network.SubResource{
Reference: genruntime.ResourceReference{
// TODO: This is still really awkward
ARMID: tc.MakeARMId(rg.Name, "Microsoft.Network", "loadBalancers", lbName, "frontendIPConfigurations", lbFrontendName),
},
Protocol: network.InboundNatPoolPropertiesFormatProtocolTcp,
FrontendPortRangeStart: 50000,
FrontendPortRangeEnd: 51000,
BackendPort: 22,
},
Protocol: &protocol,
FrontendPortRangeStart: to.IntPtr(50_000),
FrontendPortRangeEnd: to.IntPtr(51_000),
BackendPort: to.IntPtr(22),
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions hack/generated/controllers/crd_networking_publicip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ func Test_PublicIP_CRUD(t *testing.T) {
// TODO: Note the microsoft.networking package also defines a PublicIPAddress type, so
// TODO: depluralization of this resource doesn't work because of the collision.
sku := network.PublicIPAddressSkuNameStandard
publicIPAddress := &network.PublicIPAddresses{
publicIPAddress := &network.PublicIPAddress{
ObjectMeta: tc.MakeObjectMetaWithName(tc.Namer.GenerateName("publicip")),
Spec: network.PublicIPAddresses_Spec{
Location: tc.AzureRegion,
Owner: testcommon.AsOwner(rg.ObjectMeta),
Sku: &network.PublicIPAddressSku{
Name: &sku,
},
PublicIPAllocationMethod: network.PublicIPAddressesSpecPropertiesPublicIPAllocationMethodStatic,
PublicIPAllocationMethod: network.PublicIPAddressPropertiesFormatPublicIPAllocationMethodStatic,
},
}

Expand All @@ -55,7 +55,7 @@ func Test_PublicIP_CRUD(t *testing.T) {

// ensure state got updated in Azure
tc.Eventually(func() *int {
updatedIP := &network.PublicIPAddresses{}
updatedIP := &network.PublicIPAddress{}
tc.GetResource(objectKey, updatedIP)
return updatedIP.Status.IdleTimeoutInMinutes
}).Should(Equal(&idleTimeoutInMinutes))
Expand Down
5 changes: 2 additions & 3 deletions hack/generated/controllers/crd_storageaccount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func Test_StorageAccount_CRUD(t *testing.T) {
Location: tc.AzureRegion,
Owner: testcommon.AsOwner(rg.ObjectMeta),
Kind: storage.StorageAccountsSpecKindBlobStorage,
Sku: storage.StorageAccounts_Spec_Sku{
Name: storage.StorageAccountsSpecSkuNameStandardLRS,
Sku: storage.Sku{
Name: storage.SkuNameStandardLRS,
},
// TODO: They mark this property as optional but actually it is required
AccessTier: &accessTier,
Expand Down Expand Up @@ -100,7 +100,6 @@ func StorageAccount_BlobServices_CRUD(tc testcommon.KubePerTestContext, storageA
}

func StorageAccount_BlobServices_Container_CRUD(tc testcommon.KubePerTestContext, blobService metav1.ObjectMeta) {

blobContainer := &storage.StorageAccountsBlobServicesContainer{
ObjectMeta: tc.MakeObjectMeta("container"),
Spec: storage.StorageAccountsBlobServicesContainers_Spec{
Expand Down
98 changes: 45 additions & 53 deletions hack/generated/controllers/crd_vmss_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ import (
"fmt"
"testing"

"github.com/Azure/go-autorest/autorest/to"
. "github.com/onsi/gomega"
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"sigs.k8s.io/controller-runtime/pkg/client"

compute "github.com/Azure/azure-service-operator/hack/generated/_apis/microsoft.compute/v1alpha1api20201201"
network "github.com/Azure/azure-service-operator/hack/generated/_apis/microsoft.network/v1alpha1api20201101"
resources "github.com/Azure/azure-service-operator/hack/generated/_apis/microsoft.resources/v1alpha1api20200601"
"github.com/Azure/azure-service-operator/hack/generated/pkg/genruntime"
"github.com/Azure/azure-service-operator/hack/generated/pkg/testcommon"
"github.com/Azure/go-autorest/autorest/to"
. "github.com/onsi/gomega"
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

func newVNETForVMSS(tc testcommon.KubePerTestContext, owner genruntime.KnownResourceReference) *network.VirtualNetwork {
Expand All @@ -43,25 +44,26 @@ func newSubnetForVMSS(tc testcommon.KubePerTestContext, owner genruntime.KnownRe
}
}

func newPublicIPAddressForVMSS(tc testcommon.KubePerTestContext, owner genruntime.KnownResourceReference) *network.PublicIPAddresses {
func newPublicIPAddressForVMSS(tc testcommon.KubePerTestContext, owner genruntime.KnownResourceReference) *network.PublicIPAddress {
publicIPAddressSku := network.PublicIPAddressSkuNameStandard
return &network.PublicIPAddresses{
return &network.PublicIPAddress{
ObjectMeta: tc.MakeObjectMetaWithName(tc.Namer.GenerateName("publicip")),
Spec: network.PublicIPAddresses_Spec{
Location: tc.AzureRegion,
Owner: owner,
Sku: &network.PublicIPAddressSku{
Name: &publicIPAddressSku,
},
PublicIPAllocationMethod: network.PublicIPAddressesSpecPropertiesPublicIPAllocationMethodStatic,
PublicIPAllocationMethod: network.PublicIPAddressPropertiesFormatPublicIPAllocationMethodStatic,
},
}
}

func newLoadBalancerForVMSS(tc testcommon.KubePerTestContext, rg *resources.ResourceGroup, publicIPAddress *network.PublicIPAddresses) *network.LoadBalancer {
func newLoadBalancerForVMSS(tc testcommon.KubePerTestContext, rg *resources.ResourceGroup, publicIPAddress *network.PublicIPAddress) *network.LoadBalancer {
loadBalancerSku := network.LoadBalancerSkuNameStandard
lbName := tc.Namer.GenerateName("loadbalancer")
lbFrontendName := "LoadBalancerFrontend"
protocol := network.InboundNatPoolPropertiesFormatProtocolTcp
return &network.LoadBalancer{
ObjectMeta: tc.MakeObjectMetaWithName(lbName),
Spec: network.LoadBalancers_Spec{
Expand All @@ -70,31 +72,27 @@ func newLoadBalancerForVMSS(tc testcommon.KubePerTestContext, rg *resources.Reso
Sku: &network.LoadBalancerSku{
Name: &loadBalancerSku,
},
FrontendIPConfigurations: []network.FrontendIPConfiguration{
FrontendIPConfigurations: []network.LoadBalancers_Spec_Properties_FrontendIPConfigurations{
{
Name: lbFrontendName,
Properties: &network.FrontendIPConfigurationPropertiesFormat{
PublicIPAddress: &network.SubResource{
Reference: tc.MakeReferenceFromResource(publicIPAddress),
},
PublicIPAddress: &network.SubResource{
Reference: tc.MakeReferenceFromResource(publicIPAddress),
},
},
},
InboundNatPools: []network.InboundNatPool{
InboundNatPools: []network.LoadBalancers_Spec_Properties_InboundNatPools{
{
Name: "MyFancyNatPool",
Properties: &network.InboundNatPoolPropertiesFormat{
FrontendIPConfiguration: network.SubResource{
Reference: genruntime.ResourceReference{
// TODO: Getting this is SUPER awkward
ARMID: tc.MakeARMId(rg.Name, "Microsoft.Network", "loadBalancers", lbName, "frontendIPConfigurations", lbFrontendName),
},
FrontendIPConfiguration: &network.SubResource{
Reference: genruntime.ResourceReference{
// TODO: Getting this is SUPER awkward
ARMID: tc.MakeARMId(rg.Name, "Microsoft.Network", "loadBalancers", lbName, "frontendIPConfigurations", lbFrontendName),
},
Protocol: network.InboundNatPoolPropertiesFormatProtocolTcp,
FrontendPortRangeStart: 50000,
FrontendPortRangeEnd: 51000,
BackendPort: 22,
},
Protocol: &protocol,
FrontendPortRangeStart: to.IntPtr(50_000),
FrontendPortRangeEnd: to.IntPtr(51_000),
BackendPort: to.IntPtr(22),
},
},
},
Expand Down Expand Up @@ -132,7 +130,7 @@ func newVMSS(
UpgradePolicy: &compute.UpgradePolicy{
Mode: &upgradePolicyMode,
},
VirtualMachineProfile: &compute.VirtualMachineScaleSetVMProfile{
VirtualMachineProfile: &compute.VirtualMachineScaleSets_Spec_Properties_VirtualMachineProfile{
StorageProfile: &compute.VirtualMachineScaleSetStorageProfile{
ImageReference: &compute.ImageReference{
Publisher: to.StringPtr("Canonical"),
Expand All @@ -156,24 +154,20 @@ func newVMSS(
},
},
},
NetworkProfile: &compute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []compute.VirtualMachineScaleSetNetworkConfiguration{
NetworkProfile: &compute.VirtualMachineScaleSets_Spec_Properties_VirtualMachineProfile_NetworkProfile{
NetworkInterfaceConfigurations: []compute.VirtualMachineScaleSets_Spec_Properties_VirtualMachineProfile_NetworkProfile_NetworkInterfaceConfigurations{
{
Name: "mynicconfig",
Properties: &compute.VirtualMachineScaleSetNetworkConfigurationProperties{
Primary: to.BoolPtr(true),
IpConfigurations: []compute.VirtualMachineScaleSetIPConfiguration{
{
Name: "myipconfiguration",
Properties: &compute.VirtualMachineScaleSetIPConfigurationProperties{
Subnet: &compute.ApiEntityReference{
Reference: tc.MakeReferencePtrFromResource(subnet),
},
LoadBalancerInboundNatPools: []compute.SubResource{
{
Reference: &inboundNATPoolRef,
},
},
Name: "mynicconfig",
Primary: to.BoolPtr(true),
IpConfigurations: []compute.VirtualMachineScaleSets_Spec_Properties_VirtualMachineProfile_NetworkProfile_NetworkInterfaceConfigurations_Properties_IpConfigurations{
{
Name: "myipconfiguration",
Subnet: &compute.ApiEntityReference{
Reference: tc.MakeReferencePtrFromResource(subnet),
},
LoadBalancerInboundNatPools: []compute.SubResource{
{
Reference: &inboundNATPoolRef,
},
},
},
Expand Down Expand Up @@ -206,18 +200,16 @@ func Test_VMSS_CRUD(t *testing.T) {
// Perform a simple patch to add a basic custom script extension
patcher := tc.NewResourcePatcher(vmss)
extensionName := "mycustomextension"
vmss.Spec.VirtualMachineProfile.ExtensionProfile = &compute.VirtualMachineScaleSetExtensionProfile{
Extensions: []compute.VirtualMachineScaleSetExtension{
vmss.Spec.VirtualMachineProfile.ExtensionProfile = &compute.VirtualMachineScaleSets_Spec_Properties_VirtualMachineProfile_ExtensionProfile{
Extensions: []compute.VirtualMachineScaleSets_Spec_Properties_VirtualMachineProfile_ExtensionProfile_Extensions{
{
Name: &extensionName,
Properties: &compute.GenericExtension{
Publisher: "Microsoft.Azure.Extensions",
Type: "CustomScript",
TypeHandlerVersion: "2.0",
Settings: map[string]v1.JSON{
"commandToExecute": {
Raw: []byte(`"/bin/bash -c \"echo hello\""`),
},
Name: &extensionName,
Publisher: to.StringPtr("Microsoft.Azure.Extensions"),
Type: to.StringPtr("CustomScript"),
TypeHandlerVersion: to.StringPtr("2.0"),
Settings: map[string]v1.JSON{
"commandToExecute": {
Raw: []byte(`"/bin/bash -c \"echo hello\""`),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import (
. "github.com/onsi/gomega"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/Azure/go-autorest/autorest/to"

compute "github.com/Azure/azure-service-operator/hack/generated/_apis/microsoft.compute/v1alpha1api20201201"
resources "github.com/Azure/azure-service-operator/hack/generated/_apis/microsoft.resources/v1alpha1api20200601"
storage "github.com/Azure/azure-service-operator/hack/generated/_apis/microsoft.storage/v1alpha1api20210401"
"github.com/Azure/azure-service-operator/hack/generated/pkg/armclient"
"github.com/Azure/azure-service-operator/hack/generated/pkg/reconcilers"
"github.com/Azure/azure-service-operator/hack/generated/pkg/testcommon"
"github.com/Azure/go-autorest/autorest/to"
)

func newStorageAccountWithInvalidKeyExpiration(tc testcommon.KubePerTestContext, rg *resources.ResourceGroup) *storage.StorageAccount {
Expand All @@ -32,8 +33,8 @@ func newStorageAccountWithInvalidKeyExpiration(tc testcommon.KubePerTestContext,
Location: tc.AzureRegion,
Owner: testcommon.AsOwner(rg.ObjectMeta),
Kind: storage.StorageAccountsSpecKindBlobStorage,
Sku: storage.StorageAccounts_Spec_Sku{
Name: storage.StorageAccountsSpecSkuNameStandardLRS,
Sku: storage.Sku{
Name: storage.SkuNameStandardLRS,
},
AccessTier: &accessTier,
KeyPolicy: &storage.KeyPolicy{
Expand All @@ -60,7 +61,7 @@ func newVMSSWithInvalidPublisher(tc testcommon.KubePerTestContext, rg *resources
UpgradePolicy: &compute.UpgradePolicy{
Mode: &upgradePolicyMode,
},
VirtualMachineProfile: &compute.VirtualMachineScaleSetVMProfile{
VirtualMachineProfile: &compute.VirtualMachineScaleSets_Spec_Properties_VirtualMachineProfile{
StorageProfile: &compute.VirtualMachineScaleSetStorageProfile{
ImageReference: &compute.ImageReference{
Publisher: to.StringPtr("this publisher"),
Expand All @@ -73,8 +74,8 @@ func newVMSSWithInvalidPublisher(tc testcommon.KubePerTestContext, rg *resources
ComputerNamePrefix: to.StringPtr("computer"),
AdminUsername: &adminUsername,
},
NetworkProfile: &compute.VirtualMachineScaleSetNetworkProfile{
NetworkInterfaceConfigurations: []compute.VirtualMachineScaleSetNetworkConfiguration{
NetworkProfile: &compute.VirtualMachineScaleSets_Spec_Properties_VirtualMachineProfile_NetworkProfile{
NetworkInterfaceConfigurations: []compute.VirtualMachineScaleSets_Spec_Properties_VirtualMachineProfile_NetworkProfile_NetworkInterfaceConfigurations{
{
Name: "mynicconfig",
},
Expand Down
Loading

0 comments on commit f56cdfb

Please sign in to comment.