Skip to content

Commit

Permalink
Added code, tests, and documentation for certificate_root
Browse files Browse the repository at this point in the history
  • Loading branch information
omaraibrahim authored and kavya498 committed Mar 31, 2023
1 parent d022c91 commit 2afe9db
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ibm/service/database/data_source_ibm_database_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ func DataSourceIBMDatabaseConnection() *schema.Resource {
"ibm_database_connection",
"endpoint_type"),
},
"certificate_root": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Description: "Optional certificate root path to prepend certificate names. Certificates would be stored in this directory for use by other commands.",
},
"postgres": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -1646,6 +1651,10 @@ func DataSourceIBMDatabaseConnectionRead(context context.Context, d *schema.Reso
getConnectionOptions.SetUserID(d.Get("user_id").(string))
getConnectionOptions.SetEndpointType(d.Get("endpoint_type").(string))

if _, ok := d.GetOk("certificate_root"); ok {
getConnectionOptions.SetCertificateRoot(d.Get("certificate_root").(string))
}

connection, response, err := cloudDatabasesClient.GetConnectionWithContext(context, getConnectionOptions)
if err != nil {
log.Printf("[DEBUG] GetConnectionWithContext failed %s\n%s", err, response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestAccIBMDatabaseConnectionDataSourceBasic(t *testing.T) {
resource.TestCheckResourceAttrSet("data.ibm_database_connection.database_connection", "user_type"),
resource.TestCheckResourceAttrSet("data.ibm_database_connection.database_connection", "user_id"),
resource.TestCheckResourceAttrSet("data.ibm_database_connection.database_connection", "endpoint_type"),
resource.TestCheckResourceAttrSet("data.ibm_database_connection.database_connection", "certificate_root"),
),
},
},
Expand Down Expand Up @@ -63,6 +64,7 @@ func testAccCheckIBMDatabaseInstancePostgresql(name string) string {
user_type = "database"
user_id = "user_id"
endpoint_type = "public"
certificate_root = "./test/path"
}
`
}
1 change: 1 addition & 0 deletions website/docs/d/database_connection.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Review the argument reference that you can specify for your data source.
* `deployment_id` - (Required, String) Deployment ID.
* `user_id` - (Required, String) User ID.
* `user_type` - (Required, String) User type.
* `certificate_root` - (Optional, String) Optional certificate root path to prepend certificate names. Certificates would be stored in this directory for use by other commands.

## Attribute Reference

Expand Down

0 comments on commit 2afe9db

Please sign in to comment.