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

SM fixes #5045

Merged
merged 36 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
317590f
SC addition
Nov 15, 2023
babc0f9
SC addition
Nov 15, 2023
8071667
SC addition
Nov 15, 2023
60abaf9
update function updated
Nov 19, 2023
8477dde
SC unit tests added
Nov 22, 2023
2f38ba5
Merge branch 'IBM-Cloud:master' into master
yonatanyell Nov 22, 2023
972a9b9
SC unit tests added
Nov 28, 2023
59c5e72
d
Dec 6, 2023
2ff98ad
tests fixes
Dec 6, 2023
b9e8416
Merge remote-tracking branch 'origin/master'
Dec 6, 2023
40ea122
tests fixes
Dec 6, 2023
f3a195f
update sdk
TatyanaBol Dec 11, 2023
8fa09ae
.secrets.baseline update
Dec 11, 2023
a6b779c
.secrets.baseline update
Dec 11, 2023
1f1e01a
Merge branch 'master' into master
yonatanyell Dec 11, 2023
cea9bd4
.secrets.baseline update
Dec 11, 2023
0d333f9
Merge remote-tracking branch 'origin/master'
Dec 11, 2023
ad75820
Update sm_service_credentials_secret_metadata.html.markdown
IdanAdar Dec 13, 2023
5ece471
Merge branch 'master' of github.com:yonatanyell/terraform-provider-ibm
Dec 26, 2023
e91f429
bugs fixes
Dec 26, 2023
c44ff91
bugs fixes
Dec 26, 2023
74626d8
bugs fixes
Dec 26, 2023
bd730d7
Merge branch 'master' into master
yonatanyell Dec 28, 2023
fbf61c6
docs bugs fixes
Jan 3, 2024
fbc7294
Merge remote-tracking branch 'origin/master'
Jan 3, 2024
25f8094
Merge branch 'IBM-Cloud:master' into master
yonatanyell Jan 3, 2024
e63a564
preferred_chain added for public cert lets encrypt configuration
Jan 15, 2024
daa771b
Merge branch 'IBM-Cloud:master' into master
yonatanyell Jan 15, 2024
ef612d9
support for creating secret version for username password & version_c…
Jan 15, 2024
6e7b866
Merge remote-tracking branch 'origin/master'
Jan 15, 2024
3bb189a
support for creating secret version for username password & version_c…
Jan 15, 2024
47ea09c
support for creating secret version for username password & version_c…
Jan 17, 2024
27241e5
support for creating secret version for username password & version_c…
Jan 17, 2024
c1ca0e7
support for creating secret version for username password & version_c…
Jan 17, 2024
988d3df
support for creating secret version for username password & version_c…
Jan 17, 2024
fd3a343
Merge branch 'master' into master
yonatanyell Jan 21, 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
76 changes: 29 additions & 47 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"files": "go.mod|go.sum|.*.map|^.secrets.baseline$",
"lines": null
},
"generated_at": "2023-12-26T12:35:45Z",
"generated_at": "2024-01-17T13:22:37Z",
"plugins_used": [
{
"name": "AWSKeyDetector"
Expand Down Expand Up @@ -760,23 +760,23 @@
"hashed_secret": "731438016c5ab94431f61820f35e3ae5f8ad6004",
"is_secret": false,
"is_verified": false,
"line_number": 428,
"line_number": 432,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "12da2e35d6b50c902c014f1ab9e3032650368df7",
"is_secret": false,
"is_verified": false,
"line_number": 434,
"line_number": 438,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "813274ccae5b6b509379ab56982d862f7b5969b6",
"is_secret": false,
"is_verified": false,
"line_number": 1157,
"line_number": 1161,
"type": "Base64 High Entropy String",
"verified_result": null
}
Expand All @@ -794,39 +794,39 @@
"hashed_secret": "c427f185ddcb2440be9b77c8e45f1cd487a2e790",
"is_secret": false,
"is_verified": false,
"line_number": 1451,
"line_number": 1454,
"type": "Base64 High Entropy String",
"verified_result": null
},
{
"hashed_secret": "1f7e33de15e22de9d2eaf502df284ed25ca40018",
"is_secret": false,
"is_verified": false,
"line_number": 1518,
"line_number": 1521,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "1f614c2eb6b3da22d89bd1b9fd47d7cb7c8fc670",
"is_secret": false,
"is_verified": false,
"line_number": 3338,
"line_number": 3342,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "7abfce65b8504403afc25c9790f358d513dfbcc6",
"is_secret": false,
"is_verified": false,
"line_number": 3351,
"line_number": 3355,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "0c2d85bf9a9b1579b16f220a4ea8c3d62b2e24b1",
"is_secret": false,
"is_verified": false,
"line_number": 3392,
"line_number": 3396,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down Expand Up @@ -2964,7 +2964,7 @@
"hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd",
"is_secret": false,
"is_verified": false,
"line_number": 1091,
"line_number": 1115,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down Expand Up @@ -2992,7 +2992,7 @@
"hashed_secret": "92f08f2d9a0dc3f0d4cb3796435a48508cf59ecd",
"is_secret": false,
"is_verified": false,
"line_number": 509,
"line_number": 513,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down Expand Up @@ -3556,23 +3556,23 @@
"hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4",
"is_secret": false,
"is_verified": false,
"line_number": 198,
"line_number": 197,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "108b310facc1a193833fc2971fd83081f775ea0c",
"is_secret": false,
"is_verified": false,
"line_number": 389,
"line_number": 388,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f",
"is_secret": false,
"is_verified": false,
"line_number": 392,
"line_number": 391,
"type": "Secret Keyword",
"verified_result": null
}
Expand All @@ -3592,23 +3592,23 @@
"hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4",
"is_secret": false,
"is_verified": false,
"line_number": 109,
"line_number": 108,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f",
"is_secret": false,
"is_verified": false,
"line_number": 430,
"line_number": 429,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "9beb31de125498074813c6f31c0e4df3e54a5489",
"is_secret": false,
"is_verified": false,
"line_number": 646,
"line_number": 645,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down Expand Up @@ -3636,15 +3636,15 @@
"hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4",
"is_secret": false,
"is_verified": false,
"line_number": 297,
"line_number": 296,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f",
"is_secret": false,
"is_verified": false,
"line_number": 538,
"line_number": 537,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down Expand Up @@ -3690,15 +3690,15 @@
"hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4",
"is_secret": false,
"is_verified": false,
"line_number": 397,
"line_number": 396,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f",
"is_secret": false,
"is_verified": false,
"line_number": 637,
"line_number": 636,
"type": "Secret Keyword",
"verified_result": null
}
Expand All @@ -3718,15 +3718,15 @@
"hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4",
"is_secret": false,
"is_verified": false,
"line_number": 39,
"line_number": 44,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f",
"is_secret": false,
"is_verified": false,
"line_number": 144,
"line_number": 152,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down Expand Up @@ -3818,33 +3818,15 @@
"hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4",
"is_secret": false,
"is_verified": false,
"line_number": 190,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f",
"is_secret": false,
"is_verified": false,
"line_number": 443,
"type": "Secret Keyword",
"verified_result": null
}
],
"ibm/service/secretsmanager/resource_ibm_sm_service_credentilas_secret.go": [
{
"hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4",
"is_secret": false,
"is_verified": false,
"line_number": 190,
"line_number": 189,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f",
"is_secret": false,
"is_verified": false,
"line_number": 443,
"line_number": 442,
"type": "Secret Keyword",
"verified_result": null
}
Expand All @@ -3854,15 +3836,15 @@
"hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4",
"is_secret": false,
"is_verified": false,
"line_number": 124,
"line_number": 123,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "b732fb611fd46a38e8667f9972e0cde777fbe37f",
"is_secret": false,
"is_verified": false,
"line_number": 356,
"line_number": 354,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down Expand Up @@ -5002,15 +4984,15 @@
"hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e",
"is_secret": false,
"is_verified": false,
"line_number": 191,
"line_number": 192,
"type": "Secret Keyword",
"verified_result": null
},
{
"hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f",
"is_secret": false,
"is_verified": false,
"line_number": 193,
"line_number": 194,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ func ResourceIbmSmArbitrarySecret() *schema.Resource {
"version_custom_metadata": &schema.Schema{
Type: schema.TypeMap,
Optional: true,
Computed: true,
Description: "The secret version metadata that a user can customize.",
Elem: &schema.Schema{Type: schema.TypeString},
},
Expand Down Expand Up @@ -422,7 +421,7 @@ func resourceIbmSmArbitrarySecretUpdate(context context.Context, d *schema.Resou
// Apply change to version_custom_metadata in current version
secretVersionMetadataPatchModel := new(secretsmanagerv2.SecretVersionMetadataPatch)
secretVersionMetadataPatchModel.VersionCustomMetadata = d.Get("version_custom_metadata").(map[string]interface{})
secretVersionMetadataPatchModelAsPatch, _ := secretVersionMetadataPatchModel.AsPatch()
secretVersionMetadataPatchModelAsPatch, _ := secretVersionMetadataAsPatchFunction(secretVersionMetadataPatchModel)

updateSecretVersionOptions := &secretsmanagerv2.UpdateSecretVersionMetadataOptions{}
updateSecretVersionOptions.SetSecretID(secretId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ func ResourceIbmSmIamCredentialsSecret() *schema.Resource {
"version_custom_metadata": &schema.Schema{
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
Description: "The secret version metadata that a user can customize.",
Elem: &schema.Schema{Type: schema.TypeString},
},
Expand Down Expand Up @@ -408,6 +407,24 @@ func resourceIbmSmIamCredentialsSecretRead(context context.Context, d *schema.Re
return diag.FromErr(fmt.Errorf("Error setting signing_algorithm: %s", err))
}

// Call get version metadata API to get the current version_custom_metadata
getVersionMetdataOptions := &secretsmanagerv2.GetSecretVersionMetadataOptions{}
getVersionMetdataOptions.SetSecretID(secretId)
getVersionMetdataOptions.SetID("current")

versionMetadataIntf, response, err := secretsManagerClient.GetSecretVersionMetadataWithContext(context, getVersionMetdataOptions)
if err != nil {
log.Printf("[DEBUG] GetSecretVersionMetadataWithContext failed %s\n%s", err, response)
return diag.FromErr(fmt.Errorf("GetSecretVersionMetadataWithContext failed %s\n%s", err, response))
}

versionMetadata := versionMetadataIntf.(*secretsmanagerv2.IAMCredentialsSecretVersionMetadata)
if versionMetadata.VersionCustomMetadata != nil {
if err = d.Set("version_custom_metadata", versionMetadata.VersionCustomMetadata); err != nil {
return diag.FromErr(fmt.Errorf("Error setting version_custom_metadata: %s", err))
}
}

return nil
}

Expand Down Expand Up @@ -475,6 +492,27 @@ func resourceIbmSmIamCredentialsSecretUpdate(context context.Context, d *schema.
}
}

if d.HasChange("version_custom_metadata") {
// Apply change to version_custom_metadata in current version
secretVersionMetadataPatchModel := new(secretsmanagerv2.SecretVersionMetadataPatch)
secretVersionMetadataPatchModel.VersionCustomMetadata = d.Get("version_custom_metadata").(map[string]interface{})
secretVersionMetadataPatchModelAsPatch, _ := secretVersionMetadataAsPatchFunction(secretVersionMetadataPatchModel)

updateSecretVersionOptions := &secretsmanagerv2.UpdateSecretVersionMetadataOptions{}
updateSecretVersionOptions.SetSecretID(secretId)
updateSecretVersionOptions.SetID("current")
updateSecretVersionOptions.SetSecretVersionMetadataPatch(secretVersionMetadataPatchModelAsPatch)
_, response, err := secretsManagerClient.UpdateSecretVersionMetadataWithContext(context, updateSecretVersionOptions)
if err != nil {
if hasChange {
// Call the read function to update the Terraform state with the change already applied to the metadata
resourceIbmSmIamCredentialsSecretRead(context, d, meta)
}
log.Printf("[DEBUG] UpdateSecretVersionMetadataWithContext failed %s\n%s", err, response)
return diag.FromErr(fmt.Errorf("UpdateSecretVersionMetadataWithContext failed %s\n%s", err, response))
}
}

return resourceIbmSmIamCredentialsSecretRead(context, d, meta)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func ResourceIbmSmImportedCertificate() *schema.Resource {
"version_custom_metadata": &schema.Schema{
Type: schema.TypeMap,
Optional: true,
Computed: true,
Description: "The secret version metadata that a user can customize.",
Elem: &schema.Schema{Type: schema.TypeString},
},
Expand Down Expand Up @@ -537,7 +536,7 @@ func resourceIbmSmImportedCertificateUpdate(context context.Context, d *schema.R
// Apply change to version_custom_metadata in current version
secretVersionMetadataPatchModel := new(secretsmanagerv2.SecretVersionMetadataPatch)
secretVersionMetadataPatchModel.VersionCustomMetadata = d.Get("version_custom_metadata").(map[string]interface{})
secretVersionMetadataPatchModelAsPatch, _ := secretVersionMetadataPatchModel.AsPatch()
secretVersionMetadataPatchModelAsPatch, _ := secretVersionMetadataAsPatchFunction(secretVersionMetadataPatchModel)

updateSecretVersionOptions := &secretsmanagerv2.UpdateSecretVersionMetadataOptions{}
updateSecretVersionOptions.SetSecretID(secretId)
Expand Down
3 changes: 1 addition & 2 deletions ibm/service/secretsmanager/resource_ibm_sm_kv_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func ResourceIbmSmKvSecret() *schema.Resource {
"version_custom_metadata": &schema.Schema{
Type: schema.TypeMap,
Optional: true,
Computed: true,
Description: "The secret version metadata that a user can customize.",
Elem: &schema.Schema{Type: schema.TypeString},
},
Expand Down Expand Up @@ -396,7 +395,7 @@ func resourceIbmSmKvSecretUpdate(context context.Context, d *schema.ResourceData
// Apply change to version_custom_metadata in current version
secretVersionMetadataPatchModel := new(secretsmanagerv2.SecretVersionMetadataPatch)
secretVersionMetadataPatchModel.VersionCustomMetadata = d.Get("version_custom_metadata").(map[string]interface{})
secretVersionMetadataPatchModelAsPatch, _ := secretVersionMetadataPatchModel.AsPatch()
secretVersionMetadataPatchModelAsPatch, _ := secretVersionMetadataAsPatchFunction(secretVersionMetadataPatchModel)

updateSecretVersionOptions := &secretsmanagerv2.UpdateSecretVersionMetadataOptions{}
updateSecretVersionOptions.SetSecretID(secretId)
Expand Down
Loading
Loading