diff --git a/.secrets.baseline b/.secrets.baseline index 618f58d428..0b3ce98f4b 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "go.mod|go.sum|.*.map|^.secrets.baseline$", "lines": null }, - "generated_at": "2023-09-14T15:01:09Z", + "generated_at": "2023-09-19T16:31:40Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -828,7 +828,7 @@ "hashed_secret": "da8cae6284528565678de15e03d461e23fe22538", "is_secret": false, "is_verified": false, - "line_number": 1714, + "line_number": 1845, "type": "Secret Keyword", "verified_result": null }, @@ -836,7 +836,7 @@ "hashed_secret": "1a0334cfa65f4be58b9d914b8e96e9d9478bfbac", "is_secret": false, "is_verified": false, - "line_number": 3236, + "line_number": 3242, "type": "Secret Keyword", "verified_result": null } @@ -846,7 +846,7 @@ "hashed_secret": "c8b6f5ef11b9223ac35a5663975a466ebe7ebba9", "is_secret": false, "is_verified": false, - "line_number": 1757, + "line_number": 1763, "type": "Secret Keyword", "verified_result": null }, @@ -854,7 +854,7 @@ "hashed_secret": "8abf4899c01104241510ba87685ad4de76b0c437", "is_secret": false, "is_verified": false, - "line_number": 1763, + "line_number": 1769, "type": "Secret Keyword", "verified_result": null } @@ -1288,7 +1288,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 105, + "line_number": 114, "type": "Secret Keyword", "verified_result": null } @@ -1318,7 +1318,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 49, + "line_number": 58, "type": "Secret Keyword", "verified_result": null }, @@ -1326,7 +1326,7 @@ "hashed_secret": "90a487e543acb2a46de4f28f6012de33bb854568", "is_secret": false, "is_verified": false, - "line_number": 283, + "line_number": 307, "type": "Secret Keyword", "verified_result": null } @@ -1346,7 +1346,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 85, + "line_number": 94, "type": "Secret Keyword", "verified_result": null }, @@ -1354,7 +1354,7 @@ "hashed_secret": "505032eaf8a3acf9b094a326dfb1cd0537c75a0d", "is_secret": false, "is_verified": false, - "line_number": 340, + "line_number": 364, "type": "Secret Keyword", "verified_result": null } @@ -1364,7 +1364,7 @@ "hashed_secret": "3046d9f6cfaaeea6eed9bb7a4ab010fe49b0cfd4", "is_secret": false, "is_verified": false, - "line_number": 54, + "line_number": 63, "type": "Secret Keyword", "verified_result": null } @@ -2002,7 +2002,7 @@ "hashed_secret": "884a58e4c2c5d195d3876787bdc63af6c5af2924", "is_secret": false, "is_verified": false, - "line_number": 508, + "line_number": 633, "type": "Secret Keyword", "verified_result": null } @@ -2022,7 +2022,7 @@ "hashed_secret": "b02fa7fd7ca08b5dc86c2548e40f8a21171ef977", "is_secret": false, "is_verified": false, - "line_number": 492, + "line_number": 509, "type": "Secret Keyword", "verified_result": null } @@ -2885,6 +2885,16 @@ "verified_result": null } ], + "ibm/service/satellite/resource_ibm_satellite_storage_configuration_test.go": [ + { + "hashed_secret": "f32b67c7e26342af42efabc674d441dca0a281c5", + "is_secret": false, + "is_verified": false, + "line_number": 118, + "type": "Secret Keyword", + "verified_result": null + } + ], "ibm/service/scc/data_source_ibm_scc_provider_type_instance_test.go": [ { "hashed_secret": "83747cea2b26d7652ed39218ddcdb1461c570535", @@ -2915,16 +2925,6 @@ "verified_result": null } ], - "ibm/service/satellite/resource_ibm_satellite_storage_configuration_test.go": [ - { - "hashed_secret": "f32b67c7e26342af42efabc674d441dca0a281c5", - "is_secret": false, - "is_verified": false, - "line_number": 118, - "type": "Secret Keyword", - "verified_result": null - } - ], "ibm/service/schematics/data_source_ibm_schematics_action.go": [ { "hashed_secret": "49f3bb8f759241df51c899d3725d877bad58f66e", @@ -3646,7 +3646,7 @@ "hashed_secret": "f855f5027fd8fdb2df3f6a6f1cf858fffcbedb0c", "is_secret": false, "is_verified": false, - "line_number": 89080, + "line_number": 92841, "type": "Secret Keyword", "verified_result": null }, @@ -3654,7 +3654,7 @@ "hashed_secret": "5fb0fa884132a8724a8d7cba55853737e442adbd", "is_secret": false, "is_verified": false, - "line_number": 111658, + "line_number": 115304, "type": "Secret Keyword", "verified_result": null }, @@ -3662,11 +3662,21 @@ "hashed_secret": "1e5c2f367f02e47a8c160cda1cd9d91decbac441", "is_secret": false, "is_verified": false, - "line_number": 141194, + "line_number": 145758, "type": "Secret Keyword", "verified_result": null } ], + "website/docs/d/cd_toolchains.html.markdown": [ + { + "hashed_secret": "8d204a8e6f883c0691207b5eed52ab2889568f71", + "is_secret": false, + "is_verified": false, + "line_number": 18, + "type": "Hex High Entropy String", + "verified_result": null + } + ], "website/docs/d/cis_waf_groups.html.markdown": [ { "hashed_secret": "ece6e4a51cf5a18845f07c95832586a96d5fcf4c", @@ -3961,310 +3971,6 @@ "line_number": 19, "type": "Hex High Entropy String", "verified_result": null - }, - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 83, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 85, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_appconfig.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 102, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 104, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_artifactory.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 105, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 107, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_bitbucketgit.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 127, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 129, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_custom.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 100, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 102, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_devopsinsights.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 83, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 85, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_eventnotifications.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 92, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 94, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_githubconsolidated.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 143, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 145, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_gitlab.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 139, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 141, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_hashicorpvault.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 107, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 109, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_hostedgit.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 132, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 134, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_jenkins.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 96, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 98, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_jira.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 98, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 100, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_keyprotect.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 96, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 98, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_nexus.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 101, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 103, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_pagerduty.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 92, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 94, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_pipeline.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 89, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 91, - "type": "Secret Keyword", - "verified_result": null } ], "website/docs/r/cd_toolchain_tool_privateworker.html.markdown": [ @@ -4275,94 +3981,6 @@ "line_number": 21, "type": "Secret Keyword", "verified_result": null - }, - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 92, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 94, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_saucelabs.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 91, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 93, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_secretsmanager.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 99, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 101, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_securitycompliance.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 109, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 111, - "type": "Secret Keyword", - "verified_result": null - } - ], - "website/docs/r/cd_toolchain_tool_slack.html.markdown": [ - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 108, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 110, - "type": "Secret Keyword", - "verified_result": null } ], "website/docs/r/cd_toolchain_tool_sonarqube.html.markdown": [ @@ -4373,22 +3991,6 @@ "line_number": 22, "type": "Secret Keyword", "verified_result": null - }, - { - "hashed_secret": "d47dcacc720a39e236679ac3e311a0d58bb6519e", - "is_secret": false, - "is_verified": false, - "line_number": 98, - "type": "Secret Keyword", - "verified_result": null - }, - { - "hashed_secret": "e66e7d67fdf3c596c435fc7828b13205e4950a0f", - "is_secret": false, - "is_verified": false, - "line_number": 100, - "type": "Secret Keyword", - "verified_result": null } ], "website/docs/r/cis_alert.html.markdown": [ @@ -5156,7 +4758,7 @@ } ] }, - "version": "0.13.1+ibm.61.dss", + "version": "0.13.1+ibm.52.dss", "word_list": { "file": null, "hash": null diff --git a/go.mod b/go.mod index 599e5f7196..967343a2cc 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/IBM/cloudant-go-sdk v0.0.43 github.com/IBM/code-engine-go-sdk v0.0.0-20230606173928-4863db061918 github.com/IBM/container-registry-go-sdk v1.1.0 - github.com/IBM/continuous-delivery-go-sdk v1.1.2 + github.com/IBM/continuous-delivery-go-sdk v1.2.0 github.com/IBM/event-notifications-go-admin-sdk v0.2.4 github.com/IBM/eventstreams-go-sdk v1.2.0 github.com/IBM/go-sdk-core/v3 v3.2.4 diff --git a/go.sum b/go.sum index f6529a1759..fa449a9f87 100644 --- a/go.sum +++ b/go.sum @@ -125,6 +125,8 @@ github.com/IBM/container-registry-go-sdk v1.1.0 h1:sYyknIod8R4RJZQqAheiduP6wbSTp github.com/IBM/container-registry-go-sdk v1.1.0/go.mod h1:4TwsCnQtVfZ4Vkapy/KPvQBKFc3VOyUZYkwRU4FTPrs= github.com/IBM/continuous-delivery-go-sdk v1.1.2 h1:UHwwak2RVTSZGtIV+SjH0vALqSvA+Vwkd1PHAbGgGrc= github.com/IBM/continuous-delivery-go-sdk v1.1.2/go.mod h1:A9rI1HPbccBBFgwJxXB999yXXpj1l+MnlE+rsxKtxw0= +github.com/IBM/continuous-delivery-go-sdk v1.2.0 h1:FcgB5EvVrZLUnyR4S/mBocHHo9gJ5IQkSlCa6nqmr2A= +github.com/IBM/continuous-delivery-go-sdk v1.2.0/go.mod h1:oW51tS5/MDCcEM7lUvjK1H9GFC/oKsRbyYfmvGyMGmw= github.com/IBM/event-notifications-go-admin-sdk v0.2.4 h1:WWUxwrKQxvExEK+xaAQOs6gP54LvJDPi3KatDTMfwh0= github.com/IBM/event-notifications-go-admin-sdk v0.2.4/go.mod h1:1TlGAFP47DybbovJfHtYYgSI8xpLL8Q0wao6vsAlb6c= github.com/IBM/eventstreams-go-sdk v1.2.0 h1:eP0afHArMGjwhGqvZAhhu/3EDKRch2JehpveqF1TUjs= diff --git a/ibm/provider/provider.go b/ibm/provider/provider.go index e8fc58fe0b..c11ecd0d7b 100644 --- a/ibm/provider/provider.go +++ b/ibm/provider/provider.go @@ -797,6 +797,7 @@ func Provider() *schema.Provider { // Added for Toolchain "ibm_cd_toolchain": cdtoolchain.DataSourceIBMCdToolchain(), + "ibm_cd_toolchains": cdtoolchain.DataSourceIBMCdToolchains(), "ibm_cd_toolchain_tool_keyprotect": cdtoolchain.DataSourceIBMCdToolchainToolKeyprotect(), "ibm_cd_toolchain_tool_secretsmanager": cdtoolchain.DataSourceIBMCdToolchainToolSecretsmanager(), "ibm_cd_toolchain_tool_bitbucketgit": cdtoolchain.DataSourceIBMCdToolchainToolBitbucketgit(), diff --git a/ibm/service/cdtoolchain/data_source_ibm_cd_toolchains.go b/ibm/service/cdtoolchain/data_source_ibm_cd_toolchains.go new file mode 100644 index 0000000000..fb27446528 --- /dev/null +++ b/ibm/service/cdtoolchain/data_source_ibm_cd_toolchains.go @@ -0,0 +1,170 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package cdtoolchain + +import ( + "context" + "fmt" + "log" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM/continuous-delivery-go-sdk/cdtoolchainv2" +) + +func DataSourceIBMCdToolchains() *schema.Resource { + return &schema.Resource{ + ReadContext: dataSourceIBMCdToolchainsRead, + + Schema: map[string]*schema.Schema{ + "resource_group_id": &schema.Schema{ + Type: schema.TypeString, + Required: true, + Description: "The resource group ID where the toolchains exist.", + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Description: "Name of toolchain to look up.", + }, + "toolchains": &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Description: "Toolchain results returned from the collection.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Toolchain ID.", + }, + "name": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Toolchain name.", + }, + "description": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Describes the toolchain.", + }, + "account_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Account ID where toolchain can be found.", + }, + "location": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Toolchain region.", + }, + "resource_group_id": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Resource group where the toolchain is located.", + }, + "crn": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Toolchain CRN.", + }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "URI that can be used to retrieve toolchain.", + }, + "ui_href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "URL of a user-facing user interface for this toolchain.", + }, + "created_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Toolchain creation timestamp.", + }, + "updated_at": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Latest toolchain update timestamp.", + }, + "created_by": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "Identity that created the toolchain.", + }, + }, + }, + }, + }, + } +} + +func dataSourceIBMCdToolchainsRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + cdToolchainClient, err := meta.(conns.ClientSession).CdToolchainV2() + if err != nil { + return diag.FromErr(err) + } + + listToolchainsOptions := &cdtoolchainv2.ListToolchainsOptions{} + + listToolchainsOptions.SetResourceGroupID(d.Get("resource_group_id").(string)) + if _, ok := d.GetOk("name"); ok { + listToolchainsOptions.SetName(d.Get("name").(string)) + } + + var pager *cdtoolchainv2.ToolchainsPager + pager, err = cdToolchainClient.NewToolchainsPager(listToolchainsOptions) + if err != nil { + return diag.FromErr(err) + } + + allItems, err := pager.GetAll() + if err != nil { + log.Printf("[DEBUG] ToolchainsPager.GetAll() failed %s", err) + return diag.FromErr(fmt.Errorf("ToolchainsPager.GetAll() failed %s", err)) + } + + d.SetId(dataSourceIBMCdToolchainsID(d)) + + mapSlice := []map[string]interface{}{} + for _, modelItem := range allItems { + modelMap, err := dataSourceIBMCdToolchainsToolchainModelToMap(&modelItem) + if err != nil { + return diag.FromErr(err) + } + mapSlice = append(mapSlice, modelMap) + } + + if err = d.Set("toolchains", mapSlice); err != nil { + return diag.FromErr(fmt.Errorf("Error setting toolchains %s", err)) + } + + return nil +} + +// dataSourceIBMCdToolchainsID returns a reasonable ID for the list. +func dataSourceIBMCdToolchainsID(d *schema.ResourceData) string { + return time.Now().UTC().String() +} + +func dataSourceIBMCdToolchainsToolchainModelToMap(model *cdtoolchainv2.ToolchainModel) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["id"] = model.ID + modelMap["name"] = model.Name + modelMap["description"] = model.Description + modelMap["account_id"] = model.AccountID + modelMap["location"] = model.Location + modelMap["resource_group_id"] = model.ResourceGroupID + modelMap["crn"] = model.CRN + modelMap["href"] = model.Href + modelMap["ui_href"] = model.UIHref + modelMap["created_at"] = model.CreatedAt.String() + modelMap["updated_at"] = model.UpdatedAt.String() + modelMap["created_by"] = model.CreatedBy + return modelMap, nil +} diff --git a/ibm/service/cdtoolchain/data_source_ibm_cd_toolchains_test.go b/ibm/service/cdtoolchain/data_source_ibm_cd_toolchains_test.go new file mode 100644 index 0000000000..2aa93b56f0 --- /dev/null +++ b/ibm/service/cdtoolchain/data_source_ibm_cd_toolchains_test.go @@ -0,0 +1,55 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package cdtoolchain_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" +) + +func TestAccIBMCdToolchainsDataSourceBasic(t *testing.T) { + tcName := fmt.Sprintf("tf_tc_ds_name_%d", acctest.RandIntRange(10, 100)) + rgName := acc.CdResourceGroupName + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccCheckIBMCdToolchainsDataSourceConfigBasic(tcName, rgName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_cd_toolchains.cd_toolchains", "id"), + resource.TestCheckResourceAttrSet("data.ibm_cd_toolchains.cd_toolchains", "resource_group_id"), + resource.TestCheckResourceAttrSet("data.ibm_cd_toolchains.cd_toolchains", "toolchains.0.name"), + resource.TestCheckResourceAttr("data.ibm_cd_toolchains.cd_toolchains", "toolchains.0.name", tcName), + ), + }, + }, + }) +} + +func testAccCheckIBMCdToolchainsDataSourceConfigBasic(tcName string, rgName string) string { + return fmt.Sprintf(` + data "ibm_resource_group" "resource_group" { + name = "%s" + } + + resource "ibm_cd_toolchain" "cd_toolchain" { + name = "%s" + resource_group_id = data.ibm_resource_group.resource_group.id + } + + data "ibm_cd_toolchains" "cd_toolchains" { + resource_group_id = data.ibm_resource_group.resource_group.id + name = "%s" + depends_on = [ + ibm_cd_toolchain.cd_toolchain + ] + } + `, rgName, tcName, tcName) +} diff --git a/website/docs/d/cd_toolchains.html.markdown b/website/docs/d/cd_toolchains.html.markdown new file mode 100644 index 0000000000..39605b63b1 --- /dev/null +++ b/website/docs/d/cd_toolchains.html.markdown @@ -0,0 +1,55 @@ +--- +layout: "ibm" +page_title: "IBM : ibm_cd_toolchains" +description: |- + Get information about cd_toolchains +subcategory: "CD Toolchain" +--- + +# ibm_cd_toolchains + +Provides a read-only data source to retrieve information about cd_toolchains. You can then reference the fields of the data source in other resources within the same configuration by using interpolation syntax. + +## Example Usage + +```hcl +data "ibm_cd_toolchains" "cd_toolchains" { + name = "TestToolchainV2" + resource_group_id = "6a9a01f2cff54a7f966f803d92877123" +} +``` + +## Argument Reference + +You can specify the following arguments for this data source. + +* `name` - (Optional, String) Name of toolchain to look up. + * Constraints: The maximum length is `128` characters. The minimum length is `0` characters. The value must match regular expression `/^([^\\x00-\\x7F]|[a-zA-Z0-9-._ ])+$/`. +* `resource_group_id` - (Required, String) The resource group ID where the toolchains exist. + * Constraints: The maximum length is `32` characters. The minimum length is `32` characters. The value must match regular expression `/^[0-9a-f]{32}$/`. + +## Attribute Reference + +After your data source is created, you can read values from the following attributes. + +* `id` - The unique identifier of the cd_toolchains. +* `toolchains` - (List) Toolchain results returned from the collection. + * Constraints: The maximum length is `200` items. The minimum length is `0` items. +Nested schema for **toolchains**: + * `account_id` - (String) Account ID where toolchain can be found. + * `created_at` - (String) Toolchain creation timestamp. + * `created_by` - (String) Identity that created the toolchain. + * `crn` - (String) Toolchain CRN. + * `description` - (String) Describes the toolchain. + * Constraints: The maximum length is `500` characters. The minimum length is `0` characters. The value must match regular expression `/^(.*?)$/`. + * `href` - (String) URI that can be used to retrieve toolchain. + * `id` - (String) Toolchain ID. + * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[89abAB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}$/`. + * `location` - (String) Toolchain region. + * `name` - (String) Toolchain name. + * Constraints: The maximum length is `128` characters. The minimum length is `0` characters. The value must match regular expression `/^([^\\x00-\\x7F]|[a-zA-Z0-9-._ ])+$/`. + * `resource_group_id` - (Forces new resource, String) Resource group where the toolchain is located. + * Constraints: The maximum length is `32` characters. The minimum length is `32` characters. The value must match regular expression `/^[0-9a-f]{32}$/`. + * `ui_href` - (String) URL of a user-facing user interface for this toolchain. + * `updated_at` - (String) Latest toolchain update timestamp. +