forked from hashicorp/terraform-provider-azurerm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…ashicorp#24497) * fix `SENTINEL` as name * update code * update code * update per comments * update test * refresh vendor --------- Co-authored-by: Zhen Teng <[email protected]>
- Loading branch information
Showing
3 changed files
with
85 additions
and
6 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
internal/services/securitycenter/migration/security_center_setting_v0_to_v1.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package migration | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"strings" | ||
|
||
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" | ||
) | ||
|
||
var _ pluginsdk.StateUpgrade = SecurityCenterSettingsV0ToV1{} | ||
|
||
type SecurityCenterSettingsV0ToV1 struct{} | ||
|
||
func (SecurityCenterSettingsV0ToV1) Schema() map[string]*pluginsdk.Schema { | ||
return map[string]*pluginsdk.Schema{ | ||
"enabled": { | ||
Required: true, | ||
Type: pluginsdk.TypeBool, | ||
}, | ||
"setting_name": { | ||
Required: true, | ||
Type: pluginsdk.TypeString, | ||
}, | ||
} | ||
} | ||
|
||
func (SecurityCenterSettingsV0ToV1) UpgradeFunc() pluginsdk.StateUpgraderFunc { | ||
return func(ctx context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { | ||
log.Println("[DEBUG] Migrating Security Center Settings from v0 to v1 format") | ||
oldId := strings.Split(rawState["id"].(string), "/") | ||
if oldId[len(oldId)-1] == "SENTINEL" { | ||
oldId[len(oldId)-1] = "Sentinel" | ||
} | ||
newId := strings.Join(oldId, "/") | ||
|
||
log.Printf("[DEBUG] Updating ID from %q to %q", oldId, newId) | ||
|
||
rawState["id"] = newId | ||
|
||
return rawState, nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters