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 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
3 changes: 3 additions & 0 deletions .github/labeler-issue-triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,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
Original file line number Diff line number Diff line change
Expand Up @@ -599,3 +599,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
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,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
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
storagecache_2023_05_01 "github.com/hashicorp/go-azure-sdk/resource-manager/storagecache/2023-05-01"
systemcentervirtualmachinemanager_2023_10_07 "github.com/hashicorp/go-azure-sdk/resource-manager/systemcentervirtualmachinemanager/2023-10-07"
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 @@ -149,6 +150,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 @@ -284,6 +286,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 @@ -656,5 +659,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
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,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 @@ -216,6 +217,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
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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)
}
}
}
17 changes: 17 additions & 0 deletions internal/services/workloads/client/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package client

import (
sapvirtualinstances_v2023_04_01 "github.com/hashicorp/go-azure-sdk/resource-manager/workloads/2023-04-01"
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)

func NewClient(o *common.ClientOptions) (*sapvirtualinstances_v2023_04_01.Client, error) {
client, err := sapvirtualinstances_v2023_04_01.NewClientWithBaseURI(o.Environment.ResourceManager, func(c *resourcemanager.Client) {
o.Configure(c, o.Authorizers.ResourceManager)
})
if err != nil {
return nil, err
}
return client, nil
}
37 changes: 37 additions & 0 deletions internal/services/workloads/registration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package workloads

import (
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
)

type Registration struct{}

var _ sdk.TypedServiceRegistration = Registration{}

func (r Registration) AssociatedGitHubLabel() string {
return "service/workloads"
}

// Name is the name of this Service
func (r Registration) Name() string {
return "Workloads"
}

// WebsiteCategories returns a list of categories which can be used for the sidebar
func (r Registration) WebsiteCategories() []string {
return []string{
"Workloads",
}
}

// DataSources returns a list of Data Sources supported by this Service
func (r Registration) DataSources() []sdk.DataSource {
return []sdk.DataSource{}
}

// Resources returns a list of Resources supported by this Service
func (r Registration) Resources() []sdk.Resource {
return []sdk.Resource{
WorkloadsSAPThreeTierVirtualInstanceResource{},
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package validate

import (
"fmt"
"regexp"
)

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

if matched := regexp.MustCompile(`^[A-Z][A-Z0-9][A-Z0-9]$`).Match([]byte(value)); !matched {
errors = append(errors, fmt.Errorf("%q must have three characters. The first character must be alphabetic. The second and third characters must be alphanumerical. All alphabetic characters should be uppercase.", k))
return warnings, errors
}

return warnings, errors
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package validate

import "testing"

func TestSAPVirtualInstanceName(t *testing.T) {
cases := []struct {
Input string
Valid bool
}{
{
Input: "",
Valid: false,
},
{
Input: "x01",
Valid: false,
},
{
Input: "xx",
Valid: false,
},
{
Input: "x0222",
Valid: false,
},
{
Input: "X01",
Valid: true,
},
{
Input: "XAA",
Valid: true,
},
}

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

if tc.Valid != valid {
t.Fatalf("Expected %t but got %t", tc.Valid, valid)
}
}
}
Loading
Loading