Skip to content

Commit

Permalink
Refactor settings catalog settings construction to use a local config…
Browse files Browse the repository at this point in the history
… model and improve debug logging
  • Loading branch information
ShocOne committed Dec 6, 2024
1 parent 1d1d0d0 commit 65e3698
Show file tree
Hide file tree
Showing 3 changed files with 772 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@ import (
func ConstructSettingsCatalogSettings(ctx context.Context, settingsJSON types.String) []graphmodels.DeviceManagementConfigurationSettingable {
tflog.Debug(ctx, "Constructing settings catalog settings")

if err := json.Unmarshal([]byte(settingsJSON.ValueString()), &sharedmodels.DeviceConfigV2GraphServiceModel); err != nil {
var configModel sharedmodels.DeviceConfigV2GraphServiceModel

if err := json.Unmarshal([]byte(settingsJSON.ValueString()), &configModel); err != nil {
tflog.Error(ctx, "Failed to unmarshal settings JSON", map[string]interface{}{
"error": err.Error(),
})
return nil
}

// Add debug logging after unmarshaling
tflog.Debug(ctx, "Unmarshaled settings data", map[string]interface{}{
"data": sharedmodels.DeviceConfigV2GraphServiceModel,
"data": configModel,
})

settingsCollection := make([]graphmodels.DeviceManagementConfigurationSettingable, 0)

for _, detail := range sharedmodels.DeviceConfigV2GraphServiceModel.SettingsDetails {
for _, detail := range configModel.SettingsDetails {
baseSetting := graphmodels.NewDeviceManagementConfigurationSetting()

switch detail.SettingInstance.ODataType {
Expand Down
Loading

0 comments on commit 65e3698

Please sign in to comment.