Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Resource: azurerm_workloads_sap_three_tier_virtual_instance #24384

Merged
merged 23 commits into from Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .github/labeler-issue-triage.yml
Expand Up @@ -347,3 +347,6 @@ service/virtual-desktops:

service/vmware:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_vmware_((.|\n)*)###'

service/workloads:
- '### (|New or )Affected Resource\(s\)\/Data Source\(s\)((.|\n)*)azurerm_workloads_sap_three_tier_virtual_instance((.|\n)*)###'
5 changes: 5 additions & 0 deletions .github/labeler-pull-request-triage.yml
Expand Up @@ -584,3 +584,8 @@ service/vmware:
- changed-files:
- any-glob-to-any-file:
- internal/services/vmware/**/*

service/workloads:
- changed-files:
- any-glob-to-any-file:
- internal/services/workloads/**/*
3 changes: 2 additions & 1 deletion .teamcity/components/generated/services.kt
Expand Up @@ -128,5 +128,6 @@ var services = mapOf(
"vmware" to "VMware",
"videoanalyzer" to "Video Analyzer",
"voiceservices" to "Voice Services",
"web" to "Web"
"web" to "Web",
"workloads" to "Workloads"
)
5 changes: 4 additions & 1 deletion .teamcity/components/settings.kt
Expand Up @@ -189,5 +189,8 @@ var serviceTestConfigurationOverrides = mapOf(
"voiceservices" to testConfiguration(parallelism = 3, locationOverride = LocationConfiguration("westcentralus", "westcentralus", "westcentralus", false)),

// Offset start hour to avoid collision with new App Service, reduce frequency of testing days
"web" to testConfiguration(startHour = 3, daysOfWeek = "1,3,5", locationOverride = LocationConfiguration("westeurope", "francecentral", "eastus2", true))
"web" to testConfiguration(startHour = 3, daysOfWeek = "1,3,5", locationOverride = LocationConfiguration("westeurope", "francecentral", "eastus2", true)),

// Workloads has quota available in certain locations
"workloads" to testConfiguration(parallelism = 1, locationOverride = LocationConfiguration("eastus", "westeurope", "francecentral", false))
)
4 changes: 4 additions & 0 deletions internal/acceptance/testcase.go
Expand Up @@ -143,5 +143,9 @@ func (td TestData) externalProviders() map[string]resource.ExternalProvider {
VersionConstraint: "=0.9.1",
Source: "registry.terraform.io/hashicorp/time",
},
"tls": {
VersionConstraint: "=4.0.4",
Source: "registry.terraform.io/hashicorp/tls",
},
}
}
7 changes: 7 additions & 0 deletions internal/clients/client.go
Expand Up @@ -21,6 +21,7 @@ import (
servicenetworking_v2023_05_01_preview "github.com/hashicorp/go-azure-sdk/resource-manager/servicenetworking/2023-05-01-preview"
storagecache_2023_05_01 "github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2023-05-01"
timeseriesinsights_v2020_05_15 "github.com/hashicorp/go-azure-sdk/resource-manager/timeseriesinsights/2020-05-15"
workloads_v2023_04_01 "github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2023-04-01"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
aadb2c "github.com/hashicorp/terraform-provider-azurerm/internal/services/aadb2c/client"
Expand Down Expand Up @@ -144,6 +145,7 @@ import (
vmware "github.com/hashicorp/terraform-provider-azurerm/internal/services/vmware/client"
voiceServices "github.com/hashicorp/terraform-provider-azurerm/internal/services/voiceservices/client"
web "github.com/hashicorp/terraform-provider-azurerm/internal/services/web/client"
workloads "github.com/hashicorp/terraform-provider-azurerm/internal/services/workloads/client"
)

type Client struct {
Expand Down Expand Up @@ -276,6 +278,7 @@ type Client struct {
Vmware *vmware.Client
VoiceServices *voiceServices.Client
Web *web.Client
Workloads *workloads_v2023_04_01.Client
}

// NOTE: it should be possible for this method to become Private once the top level Client's removed
Expand Down Expand Up @@ -618,5 +621,9 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error
}
client.Web = web.NewClient(o)

if client.Workloads, err = workloads.NewClient(o); err != nil {
return fmt.Errorf("building clients for Workloads: %+v", err)
}

return nil
}
2 changes: 2 additions & 0 deletions internal/provider/services.go
Expand Up @@ -129,6 +129,7 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/internal/services/vmware"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/voiceservices"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/web"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/workloads"
)

//go:generate go run ../tools/generator-services/main.go -path=../../
Expand Down Expand Up @@ -208,6 +209,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration {
vmware.Registration{},
voiceservices.Registration{},
web.Registration{},
workloads.Registration{},
}
services = append(services, autoRegisteredTypedServices()...)
return services
Expand Down
16 changes: 16 additions & 0 deletions internal/services/network/validate/network_interface_name.go
@@ -0,0 +1,16 @@
package validate

import (
"fmt"
"regexp"
)

func NetworkInterfaceName(v interface{}, k string) (warnings []string, errors []error) {
value := v.(string)

if matched := regexp.MustCompile(`^[0-9a-zA-Z][0-9a-zA-Z_.-]{0,62}[0-9a-zA-Z_]$`).Match([]byte(value)); !matched {
errors = append(errors, fmt.Errorf("%q must be between 2 and 64 characters in length. It must begin with a letter or number, end with a letter, number or underscore, and may contain only letters, numbers, underscores, periods or hyphens.", k))
}

return warnings, errors
}
56 changes: 56 additions & 0 deletions internal/services/network/validate/network_interface_name_test.go
@@ -0,0 +1,56 @@
package validate

import (
"strings"
"testing"
)

func TestNetworkInterfaceName(t *testing.T) {
cases := []struct {
Input string
Valid bool
}{
{
Input: "",
Valid: false,
},
{
Input: "-a",
Valid: false,
},
{
Input: "1_n.i-c",
Valid: true,
},
{
Input: "01nic",
Valid: true,
},
{
Input: "01nic01",
Valid: true,
},
{
Input: strings.Repeat("s", 63),
Valid: true,
},
{
Input: strings.Repeat("s", 64),
Valid: true,
},
{
Input: strings.Repeat("s", 65),
Valid: false,
},
}

for _, tc := range cases {
t.Logf("[DEBUG] Testing Value %s", tc.Input)
_, errors := NetworkInterfaceName(tc.Input, "name")
valid := len(errors) == 0

if tc.Valid != valid {
t.Fatalf("Expected %t but got %t", tc.Valid, valid)
}
}
}
@@ -0,0 +1,84 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package parse

// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten

import (
"fmt"
"strings"

"github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids"
)

type LegacyStorageShareResourceManagerId struct {
SubscriptionId string
ResourceGroup string
StorageAccountName string
FileServiceName string
ShareName string
}

func NewLegacyStorageShareResourceManagerID(subscriptionId, resourceGroup, storageAccountName, fileServiceName, shareName string) LegacyStorageShareResourceManagerId {
return LegacyStorageShareResourceManagerId{
SubscriptionId: subscriptionId,
ResourceGroup: resourceGroup,
StorageAccountName: storageAccountName,
FileServiceName: fileServiceName,
ShareName: shareName,
}
}

func (id LegacyStorageShareResourceManagerId) String() string {
segments := []string{
fmt.Sprintf("Share Name %q", id.ShareName),
fmt.Sprintf("File Service Name %q", id.FileServiceName),
fmt.Sprintf("Storage Account Name %q", id.StorageAccountName),
fmt.Sprintf("Resource Group %q", id.ResourceGroup),
}
segmentsStr := strings.Join(segments, " / ")
return fmt.Sprintf("%s: (%s)", "Legacy Storage Share Resource Manager", segmentsStr)
}

func (id LegacyStorageShareResourceManagerId) ID() string {
fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/%s/fileServices/%s/shares/%s"
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.StorageAccountName, id.FileServiceName, id.ShareName)
}

// LegacyStorageShareResourceManagerID parses a LegacyStorageShareResourceManager ID into an LegacyStorageShareResourceManagerId struct
func LegacyStorageShareResourceManagerID(input string) (*LegacyStorageShareResourceManagerId, error) {
id, err := resourceids.ParseAzureResourceID(input)
if err != nil {
return nil, fmt.Errorf("parsing %q as an LegacyStorageShareResourceManager ID: %+v", input, err)
}

resourceId := LegacyStorageShareResourceManagerId{
SubscriptionId: id.SubscriptionID,
ResourceGroup: id.ResourceGroup,
}

if resourceId.SubscriptionId == "" {
return nil, fmt.Errorf("ID was missing the 'subscriptions' element")
}

if resourceId.ResourceGroup == "" {
return nil, fmt.Errorf("ID was missing the 'resourceGroups' element")
}

if resourceId.StorageAccountName, err = id.PopSegment("storageAccounts"); err != nil {
return nil, err
}
if resourceId.FileServiceName, err = id.PopSegment("fileServices"); err != nil {
return nil, err
}
if resourceId.ShareName, err = id.PopSegment("shares"); err != nil {
return nil, err
}

if err := id.ValidateNoEmptySegments(input); err != nil {
return nil, err
}

return &resourceId, nil
}