diff --git a/internal/resources/device_and_app_management/beta/winget_app/model.go b/internal/resources/device_and_app_management/beta/winget_app/model.go index 7c7eeb89..1e287074 100644 --- a/internal/resources/device_and_app_management/beta/winget_app/model.go +++ b/internal/resources/device_and_app_management/beta/winget_app/model.go @@ -13,7 +13,7 @@ type WinGetAppResourceModel struct { DisplayName types.String `tfsdk:"display_name"` Description types.String `tfsdk:"description"` Publisher types.String `tfsdk:"publisher"` - LargeIcon *MimeContentModel `tfsdk:"large_icon"` + LargeIcon types.Object `tfsdk:"large_icon"` CreatedDateTime types.String `tfsdk:"created_date_time"` LastModifiedDateTime types.String `tfsdk:"last_modified_date_time"` IsFeatured types.Bool `tfsdk:"is_featured"` diff --git a/internal/resources/device_and_app_management/beta/winget_app/resource.go b/internal/resources/device_and_app_management/beta/winget_app/resource.go index 921897f6..a1e23b5a 100644 --- a/internal/resources/device_and_app_management/beta/winget_app/resource.go +++ b/internal/resources/device_and_app_management/beta/winget_app/resource.go @@ -103,10 +103,12 @@ func (r *WinGetAppResource) Schema(ctx context.Context, req resource.SchemaReque " run_as_account = \"user\"\n" + " }\n" + "}\n" + - "```\n\n" + - "Can be set using the `PACKAGE_IDENTIFIER` environment variable.", + "```\n\n", Validators: []validator.String{ - stringvalidator.RegexMatches(regexp.MustCompile(`^[a-zA-Z0-9]{12}$`), "package_identifier must be a 12-character alphanumeric string (upper or lowercase)."), + stringvalidator.RegexMatches( + regexp.MustCompile(`^[A-Z0-9]{12}$`), + "package_identifier must be a 12-character string containing only uppercase letters and numbers.", + ), }, }, "is_featured": schema.BoolAttribute{ diff --git a/internal/resources/device_and_app_management/beta/winget_app/state.go b/internal/resources/device_and_app_management/beta/winget_app/state.go index 24cec4bc..cd340188 100644 --- a/internal/resources/device_and_app_management/beta/winget_app/state.go +++ b/internal/resources/device_and_app_management/beta/winget_app/state.go @@ -4,6 +4,7 @@ import ( "context" "github.com/deploymenttheory/terraform-provider-microsoft365/internal/resources/common/state" + "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/microsoftgraph/msgraph-beta-sdk-go/models" @@ -41,13 +42,28 @@ func MapRemoteStateToTerraform(ctx context.Context, data *WinGetAppResourceModel data.SupersededAppCount = state.Int32PtrToTypeInt64(remoteResource.GetSupersededAppCount()) // Handle LargeIcon + largeIconObj := types.ObjectNull( + map[string]attr.Type{ + "type": types.StringType, + "value": types.StringType, + }, + ) + if largeIcon := remoteResource.GetLargeIcon(); largeIcon != nil { - data.LargeIcon = &MimeContentModel{ - Type: types.StringValue(state.StringPtrToString(largeIcon.GetTypeEscaped())), - Value: types.StringValue(string(largeIcon.GetValue())), - } + largeIconObj, _ = types.ObjectValue( + map[string]attr.Type{ + "type": types.StringType, + "value": types.StringType, + }, + map[string]attr.Value{ + "type": types.StringValue(state.StringPtrToString(largeIcon.GetTypeEscaped())), + "value": types.StringValue(state.ByteToString(largeIcon.GetValue())), + }, + ) } + data.LargeIcon = largeIconObj + // Handle InstallExperience if installExperience := remoteResource.GetInstallExperience(); installExperience != nil { data.InstallExperience = &WinGetAppInstallExperienceModel{