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_system_center_virtual_machine_manager_virtual_machine_instance #27622

Open
wants to merge 52 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
e3ac09d
New Resource: azurerm_system_center_virtual_machine_manager_virtual_m…
neil-yechenwei Dec 5, 2023
ada2088
update code
neil-yechenwei Dec 5, 2023
8e5a5bf
update code
neil-yechenwei Apr 10, 2024
5b46fee
update code
neil-yechenwei Apr 11, 2024
997cf29
update code
neil-yechenwei Apr 11, 2024
6f7d2ea
update code
neil-yechenwei Apr 11, 2024
abe39d6
merge latest change
neil-yechenwei Jun 21, 2024
7b084ed
merge latest change
neil-yechenwei Jun 24, 2024
2fb19a0
rename property
neil-yechenwei Jun 24, 2024
7c6fa7e
Merge remote-tracking branch 'upstream/main' into systemcentervirtual…
neil-yechenwei Sep 13, 2024
bf3371f
add md file and tc
neil-yechenwei Sep 13, 2024
1d36a47
update schema
neil-yechenwei Sep 14, 2024
71bfa14
remove requiredwith
neil-yechenwei Sep 14, 2024
da46bb1
update shcema
neil-yechenwei Sep 18, 2024
53c70b2
update schema
neil-yechenwei Sep 18, 2024
7483211
mark os.computer_name to required
neil-yechenwei Sep 18, 2024
5104437
update schema
neil-yechenwei Sep 19, 2024
65b0065
expand os
neil-yechenwei Sep 19, 2024
906c477
add validation for storage disk name
neil-yechenwei Sep 19, 2024
a3499b1
add validation
neil-yechenwei Sep 20, 2024
f9d483b
add tc
neil-yechenwei Sep 20, 2024
5e6dada
add restart
neil-yechenwei Sep 20, 2024
ad411da
remove default value
neil-yechenwei Sep 20, 2024
2f31577
update validation for vnetid
neil-yechenwei Sep 20, 2024
550d3e2
remove readonly property createDiffdisk
neil-yechenwei Sep 23, 2024
57963ec
add stop
neil-yechenwei Sep 24, 2024
54a190b
update tc
neil-yechenwei Sep 25, 2024
157aa81
update tc to add avs
neil-yechenwei Sep 25, 2024
718d648
update tc to test vnetid
neil-yechenwei Sep 25, 2024
141f00f
update md
neil-yechenwei Sep 25, 2024
6bf3cf9
update md
neil-yechenwei Sep 25, 2024
6a8cb7a
update description
neil-yechenwei Sep 25, 2024
7e03756
update default value
neil-yechenwei Sep 25, 2024
ec3454c
remove default value
neil-yechenwei Sep 26, 2024
4f8fba0
sort funcs
neil-yechenwei Sep 26, 2024
2f41cfb
use d.getrawconfig
neil-yechenwei Sep 28, 2024
3991768
Merge remote-tracking branch 'upstream/main' into systemcentervirtual…
neil-yechenwei Oct 8, 2024
8e49e12
not stop instance while updating av
neil-yechenwei Oct 9, 2024
da10920
not stop instance while updating infra
neil-yechenwei Oct 9, 2024
71fbc3c
add forcenew for hardwareprofile
neil-yechenwei Oct 9, 2024
8f41593
add forcenew for hardwareprofile
neil-yechenwei Oct 9, 2024
426e128
update tc
neil-yechenwei Oct 10, 2024
2a4099e
set disk_size_gb with maxDiskSizeGB
neil-yechenwei Oct 10, 2024
56c8c0e
update comment for iskSizeGB
neil-yechenwei Oct 10, 2024
0cb29b9
update tc
neil-yechenwei Oct 11, 2024
9c76c3e
update tc
neil-yechenwei Oct 11, 2024
dac8f9b
fmt files
neil-yechenwei Oct 11, 2024
e3fed47
Merge remote-tracking branch 'upstream/main' into systemcentervirtual…
neil-yechenwei Oct 12, 2024
9d7a3b3
update code per comments
neil-yechenwei Oct 14, 2024
0ea07d0
add storagedisk in tc
neil-yechenwei Oct 15, 2024
4e69b8b
update tc
neil-yechenwei Oct 16, 2024
13a9bc8
update tc
neil-yechenwei Oct 16, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package parse

import (
"fmt"
"strings"

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

var _ resourceids.ResourceId = &SystemCenterVirtualMachineManagerVirtualMachineInstanceId{}

type SystemCenterVirtualMachineManagerVirtualMachineInstanceId struct {
Scope string
}

func NewSystemCenterVirtualMachineManagerVirtualMachineInstanceID(scope string) SystemCenterVirtualMachineManagerVirtualMachineInstanceId {
return SystemCenterVirtualMachineManagerVirtualMachineInstanceId{
Scope: scope,
}
}

func SystemCenterVirtualMachineManagerVirtualMachineInstanceID(input string) (*SystemCenterVirtualMachineManagerVirtualMachineInstanceId, error) {
parser := resourceids.NewParserFromResourceIdType(&SystemCenterVirtualMachineManagerVirtualMachineInstanceId{})
parsed, err := parser.Parse(input, false)
if err != nil {
return nil, fmt.Errorf("parsing %q: %+v", input, err)
}

id := SystemCenterVirtualMachineManagerVirtualMachineInstanceId{}
if err := id.FromParseResult(*parsed); err != nil {
return nil, err
}

return &id, nil
}

func SystemCenterVirtualMachineManagerVirtualMachineInstanceIDInsensitively(input string) (*SystemCenterVirtualMachineManagerVirtualMachineInstanceId, error) {
parser := resourceids.NewParserFromResourceIdType(&SystemCenterVirtualMachineManagerVirtualMachineInstanceId{})
parsed, err := parser.Parse(input, true)
if err != nil {
return nil, fmt.Errorf("parsing %q: %+v", input, err)
}

id := SystemCenterVirtualMachineManagerVirtualMachineInstanceId{}
if err := id.FromParseResult(*parsed); err != nil {
return nil, err
}

return &id, nil
}

func (id *SystemCenterVirtualMachineManagerVirtualMachineInstanceId) FromParseResult(input resourceids.ParseResult) error {
var ok bool

if id.Scope, ok = input.Parsed["scope"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "scope", input)
}

return nil
}

func (id SystemCenterVirtualMachineManagerVirtualMachineInstanceId) ID() string {
fmtString := "/%s/providers/Microsoft.ScVmm/virtualMachineInstances/default"
return fmt.Sprintf(fmtString, strings.TrimPrefix(id.Scope, "/"))
}

func (id SystemCenterVirtualMachineManagerVirtualMachineInstanceId) Segments() []resourceids.Segment {
return []resourceids.Segment{
resourceids.ScopeSegment("scope", "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.HybridCompute/machines/some-machine"),
resourceids.StaticSegment("staticProviders", "providers", "providers"),
resourceids.ResourceProviderSegment("staticMicrosoftScVmm", "Microsoft.ScVmm", "Microsoft.ScVmm"),
resourceids.StaticSegment("staticVirtualMachineInstances", "virtualMachineInstances", "virtualMachineInstances"),
resourceids.StaticSegment("staticDefault", "default", "default"),
}
}

func (id SystemCenterVirtualMachineManagerVirtualMachineInstanceId) String() string {
components := []string{
fmt.Sprintf("Scope: %q", id.Scope),
}
return fmt.Sprintf("System Center Virtual Machine Manager Virtual Machine Instance (%s)", strings.Join(components, "\n"))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package parse

import (
"testing"

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

var _ resourceids.Id = SystemCenterVirtualMachineManagerVirtualMachineInstanceId{}

func TestSystemCenterVirtualMachineManagerVirtualMachineInstanceIDFormatter(t *testing.T) {
actual := NewSystemCenterVirtualMachineManagerVirtualMachineInstanceID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.HybridCompute/machines/machine1").ID()
expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.HybridCompute/machines/machine1/providers/Microsoft.ScVmm/virtualMachineInstances/default"
if actual != expected {
t.Fatalf("Expected %q but got %q", expected, actual)
}
}

func TestSystemCenterVirtualMachineManagerVirtualMachineInstanceID(t *testing.T) {
testData := []struct {
Input string
Error bool
Expected *SystemCenterVirtualMachineManagerVirtualMachineInstanceId
}{
{
Input: "",
Error: true,
},
{
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.HybridCompute/machines/machine1",
Error: true,
},
{
Input: "/providers/Microsoft.ScVmm/virtualMachineInstances/default",
Error: true,
},
{
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.HybridCompute/machines/machine1/providers/Microsoft.ScVmm/virtualMachineInstances/default",
Expected: &SystemCenterVirtualMachineManagerVirtualMachineInstanceId{
Scope: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.HybridCompute/machines/machine1",
},
},
{
Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.HYBRIDCOMPUTE/MACHINES/MACHINE1",
Error: true,
},
}

for _, v := range testData {
t.Logf("[DEBUG] Testing %q", v.Input)

actual, err := SystemCenterVirtualMachineManagerVirtualMachineInstanceID(v.Input)
if err != nil {
if v.Error {
continue
}

t.Fatalf("Expect a value but got an error: %s", err)
}
if v.Error {
t.Fatal("Expect an error but didn't get one")
}

if actual.Scope != v.Expected.Scope {
t.Fatalf("Expected %q but got %q for ScopeId", v.Expected.Scope, actual.Scope)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func (r Registration) Resources() []sdk.Resource {
SystemCenterVirtualMachineManagerCloudResource{},
SystemCenterVirtualMachineManagerServerResource{},
SystemCenterVirtualMachineManagerAvailabilitySetResource{},
SystemCenterVirtualMachineManagerVirtualMachineInstanceResource{},
SystemCenterVirtualMachineManagerVirtualNetworkResource{},
SystemCenterVirtualMachineManagerVirtualMachineTemplateResource{},
}
Expand Down
Loading
Loading