diff --git a/go.mod b/go.mod index cc36c73f92..aa2213c15a 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/IBM/cloud-databases-go-sdk v0.3.0 github.com/IBM/cloudant-go-sdk v0.0.43 github.com/IBM/container-registry-go-sdk v0.0.15 - github.com/IBM/continuous-delivery-go-sdk v0.1.9 + github.com/IBM/continuous-delivery-go-sdk v1.0.3 github.com/IBM/event-notifications-go-admin-sdk v0.1.2 github.com/IBM/eventstreams-go-sdk v1.2.0 github.com/IBM/go-sdk-core/v5 v5.10.2 diff --git a/go.sum b/go.sum index 4343f922b2..fbc2896589 100644 --- a/go.sum +++ b/go.sum @@ -55,8 +55,8 @@ github.com/IBM/cloudant-go-sdk v0.0.43 h1:YxTy4RpAEezX32YIWnds76hrBREmO4u6IkBz1W github.com/IBM/cloudant-go-sdk v0.0.43/go.mod h1:WeYrJPaHTw19943ndWnVfwMIlZ5z0XUM2uEXNBrwZ1M= github.com/IBM/container-registry-go-sdk v0.0.15 h1:sfEXm4qNj9ZCwTlFOsdjF5P/lvajU/Sc22yNlzg0F9I= github.com/IBM/container-registry-go-sdk v0.0.15/go.mod h1:KqSZFO4VIK9QAyF8O1JW6jkyzkfE/BNKUIo+OdzIDk4= -github.com/IBM/continuous-delivery-go-sdk v0.1.9 h1:KzKJmLzQ6NQcGqlLKDoiLRqoPVlx+Qwtkksh0hLsIrI= -github.com/IBM/continuous-delivery-go-sdk v0.1.9/go.mod h1:/pSji7d4POPVd1tQA9CLrNT1XMsCJMGLqOtTwXbWAdE= +github.com/IBM/continuous-delivery-go-sdk v1.0.3 h1:4NrO2raR/hShPO6+Dth0oasG+8hR8Igzado/q2Ltgfk= +github.com/IBM/continuous-delivery-go-sdk v1.0.3/go.mod h1:/pSji7d4POPVd1tQA9CLrNT1XMsCJMGLqOtTwXbWAdE= github.com/IBM/event-notifications-go-admin-sdk v0.1.2 h1:LLA12WFqSD0+Uf16SNdErcu2MVK4EnyXHJmDIkKkudE= github.com/IBM/event-notifications-go-admin-sdk v0.1.2/go.mod h1:VCtV/cAN8qSPeWEjIWeXOQGTq6LCWP9yZEk7wt3g0HM= github.com/IBM/eventstreams-go-sdk v1.2.0 h1:eP0afHArMGjwhGqvZAhhu/3EDKRch2JehpveqF1TUjs= diff --git a/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline.go b/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline.go index e62ffcb298..9ddf05a3e1 100644 --- a/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline.go +++ b/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. +// Copyright IBM Corp. 2023 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline @@ -39,7 +39,7 @@ func DataSourceIBMCdTektonPipeline() *schema.Resource { "resource_group": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The ID of the resource group in which the pipeline was created.", + Description: "The resource group in which the pipeline was created.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "id": &schema.Schema{ @@ -115,7 +115,7 @@ func DataSourceIBMCdTektonPipeline() *schema.Resource { "tool": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "Reference to the repository tool, in the parent toolchain, that contains the pipeline definition.", + Description: "Reference to the repository tool in the parent toolchain.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "id": &schema.Schema{ @@ -132,10 +132,15 @@ func DataSourceIBMCdTektonPipeline() *schema.Resource { }, }, }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "API URL for interacting with the definition.", + }, "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "UUID.", + Description: "The aggregated definition ID.", }, }, }, @@ -156,6 +161,11 @@ func DataSourceIBMCdTektonPipeline() *schema.Resource { Computed: true, Description: "Property value. Any string value is valid.", }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "API URL for interacting with the property.", + }, "enum": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -216,7 +226,7 @@ func DataSourceIBMCdTektonPipeline() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "ID.", + Description: "The Trigger ID.", }, "properties": &schema.Schema{ Type: schema.TypeList, @@ -234,6 +244,11 @@ func DataSourceIBMCdTektonPipeline() *schema.Resource { Computed: true, Description: "Property value. Any string value is valid.", }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "API URL for interacting with the trigger property.", + }, "enum": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -252,11 +267,6 @@ func DataSourceIBMCdTektonPipeline() *schema.Resource { Computed: true, Description: "A dot notation path for `integration` type properties only, that selects a value from the tool integration. If left blank the full tool integration data will be used.", }, - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "API URL for interacting with the trigger property.", - }, }, }, }, @@ -453,6 +463,11 @@ func DataSourceIBMCdTektonPipeline() *schema.Resource { Computed: true, Description: "URL for this pipeline showing the list of pipeline runs.", }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "API URL for interacting with the pipeline.", + }, "build_number": &schema.Schema{ Type: schema.TypeInt, Computed: true, @@ -505,7 +520,7 @@ func dataSourceIBMCdTektonPipelineRead(context context.Context, d *schema.Resour resourceGroup := []map[string]interface{}{} if tektonPipeline.ResourceGroup != nil { - modelMap, err := dataSourceIBMCdTektonPipelineTektonPipelineResourceGroupToMap(tektonPipeline.ResourceGroup) + modelMap, err := dataSourceIBMCdTektonPipelineResourceGroupReferenceToMap(tektonPipeline.ResourceGroup) if err != nil { return diag.FromErr(err) } @@ -593,6 +608,10 @@ func dataSourceIBMCdTektonPipelineRead(context context.Context, d *schema.Resour return diag.FromErr(fmt.Errorf("Error setting runs_url: %s", err)) } + if err = d.Set("href", tektonPipeline.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + } + if err = d.Set("build_number", flex.IntValue(tektonPipeline.BuildNumber)); err != nil { return diag.FromErr(fmt.Errorf("Error setting build_number: %s", err)) } @@ -612,7 +631,7 @@ func dataSourceIBMCdTektonPipelineRead(context context.Context, d *schema.Resour return nil } -func dataSourceIBMCdTektonPipelineTektonPipelineResourceGroupToMap(model *cdtektonpipelinev2.TektonPipelineResourceGroup) (map[string]interface{}, error) { +func dataSourceIBMCdTektonPipelineResourceGroupReferenceToMap(model *cdtektonpipelinev2.ResourceGroupReference) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { modelMap["id"] = *model.ID @@ -640,6 +659,9 @@ func dataSourceIBMCdTektonPipelineDefinitionToMap(model *cdtektonpipelinev2.Defi } modelMap["source"] = []map[string]interface{}{sourceMap} } + if model.Href != nil { + modelMap["href"] = *model.Href + } if model.ID != nil { modelMap["id"] = *model.ID } @@ -676,7 +698,7 @@ func dataSourceIBMCdTektonPipelineDefinitionSourcePropertiesToMap(model *cdtekto modelMap["path"] = *model.Path } if model.Tool != nil { - toolMap, err := dataSourceIBMCdTektonPipelineDefinitionSourcePropertiesToolToMap(model.Tool) + toolMap, err := dataSourceIBMCdTektonPipelineToolToMap(model.Tool) if err != nil { return modelMap, err } @@ -685,7 +707,7 @@ func dataSourceIBMCdTektonPipelineDefinitionSourcePropertiesToMap(model *cdtekto return modelMap, nil } -func dataSourceIBMCdTektonPipelineDefinitionSourcePropertiesToolToMap(model *cdtektonpipelinev2.DefinitionSourcePropertiesTool) (map[string]interface{}, error) { +func dataSourceIBMCdTektonPipelineToolToMap(model *cdtektonpipelinev2.Tool) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { modelMap["id"] = *model.ID @@ -701,6 +723,9 @@ func dataSourceIBMCdTektonPipelinePropertyToMap(model *cdtektonpipelinev2.Proper if model.Value != nil { modelMap["value"] = *model.Value } + if model.Href != nil { + modelMap["href"] = *model.Href + } if model.Enum != nil { modelMap["enum"] = model.Enum } @@ -743,7 +768,7 @@ func dataSourceIBMCdTektonPipelineTriggerToMap(model cdtektonpipelinev2.TriggerI if model.Properties != nil { properties := []map[string]interface{}{} for _, propertiesItem := range model.Properties { - propertiesItemMap, err := dataSourceIBMCdTektonPipelineTriggerPropertiesItemToMap(&propertiesItem) + propertiesItemMap, err := dataSourceIBMCdTektonPipelineTriggerPropertyToMap(&propertiesItem) if err != nil { return modelMap, err } @@ -799,7 +824,7 @@ func dataSourceIBMCdTektonPipelineTriggerToMap(model cdtektonpipelinev2.TriggerI } } -func dataSourceIBMCdTektonPipelineTriggerPropertiesItemToMap(model *cdtektonpipelinev2.TriggerPropertiesItem) (map[string]interface{}, error) { +func dataSourceIBMCdTektonPipelineTriggerPropertyToMap(model *cdtektonpipelinev2.TriggerProperty) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Name != nil { modelMap["name"] = *model.Name @@ -807,6 +832,9 @@ func dataSourceIBMCdTektonPipelineTriggerPropertiesItemToMap(model *cdtektonpipe if model.Value != nil { modelMap["value"] = *model.Value } + if model.Href != nil { + modelMap["href"] = *model.Href + } if model.Enum != nil { modelMap["enum"] = model.Enum } @@ -816,9 +844,6 @@ func dataSourceIBMCdTektonPipelineTriggerPropertiesItemToMap(model *cdtektonpipe if model.Path != nil { modelMap["path"] = *model.Path } - if model.Href != nil { - modelMap["href"] = *model.Href - } return modelMap, nil } @@ -869,7 +894,7 @@ func dataSourceIBMCdTektonPipelineTriggerSourcePropertiesToMap(model *cdtektonpi modelMap["hook_id"] = *model.HookID } if model.Tool != nil { - toolMap, err := dataSourceIBMCdTektonPipelineTriggerSourcePropertiesToolToMap(model.Tool) + toolMap, err := dataSourceIBMCdTektonPipelineToolToMap(model.Tool) if err != nil { return modelMap, err } @@ -878,14 +903,6 @@ func dataSourceIBMCdTektonPipelineTriggerSourcePropertiesToMap(model *cdtektonpi return modelMap, nil } -func dataSourceIBMCdTektonPipelineTriggerSourcePropertiesToolToMap(model *cdtektonpipelinev2.TriggerSourcePropertiesTool) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = *model.ID - } - return modelMap, nil -} - func dataSourceIBMCdTektonPipelineGenericSecretToMap(model *cdtektonpipelinev2.GenericSecret) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Type != nil { @@ -926,7 +943,7 @@ func dataSourceIBMCdTektonPipelineTriggerManualTriggerToMap(model *cdtektonpipel if model.Properties != nil { properties := []map[string]interface{}{} for _, propertiesItem := range model.Properties { - propertiesItemMap, err := dataSourceIBMCdTektonPipelineTriggerManualTriggerPropertiesItemToMap(&propertiesItem) + propertiesItemMap, err := dataSourceIBMCdTektonPipelineTriggerPropertyToMap(&propertiesItem) if err != nil { return modelMap, err } @@ -953,29 +970,6 @@ func dataSourceIBMCdTektonPipelineTriggerManualTriggerToMap(model *cdtektonpipel return modelMap, nil } -func dataSourceIBMCdTektonPipelineTriggerManualTriggerPropertiesItemToMap(model *cdtektonpipelinev2.TriggerManualTriggerPropertiesItem) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Name != nil { - modelMap["name"] = *model.Name - } - if model.Value != nil { - modelMap["value"] = *model.Value - } - if model.Enum != nil { - modelMap["enum"] = model.Enum - } - if model.Type != nil { - modelMap["type"] = *model.Type - } - if model.Path != nil { - modelMap["path"] = *model.Path - } - if model.Href != nil { - modelMap["href"] = *model.Href - } - return modelMap, nil -} - func dataSourceIBMCdTektonPipelineTriggerScmTriggerToMap(model *cdtektonpipelinev2.TriggerScmTrigger) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Type != nil { @@ -996,7 +990,7 @@ func dataSourceIBMCdTektonPipelineTriggerScmTriggerToMap(model *cdtektonpipeline if model.Properties != nil { properties := []map[string]interface{}{} for _, propertiesItem := range model.Properties { - propertiesItemMap, err := dataSourceIBMCdTektonPipelineTriggerScmTriggerPropertiesItemToMap(&propertiesItem) + propertiesItemMap, err := dataSourceIBMCdTektonPipelineTriggerPropertyToMap(&propertiesItem) if err != nil { return modelMap, err } @@ -1033,29 +1027,6 @@ func dataSourceIBMCdTektonPipelineTriggerScmTriggerToMap(model *cdtektonpipeline return modelMap, nil } -func dataSourceIBMCdTektonPipelineTriggerScmTriggerPropertiesItemToMap(model *cdtektonpipelinev2.TriggerScmTriggerPropertiesItem) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Name != nil { - modelMap["name"] = *model.Name - } - if model.Value != nil { - modelMap["value"] = *model.Value - } - if model.Enum != nil { - modelMap["enum"] = model.Enum - } - if model.Type != nil { - modelMap["type"] = *model.Type - } - if model.Path != nil { - modelMap["path"] = *model.Path - } - if model.Href != nil { - modelMap["href"] = *model.Href - } - return modelMap, nil -} - func dataSourceIBMCdTektonPipelineTriggerTimerTriggerToMap(model *cdtektonpipelinev2.TriggerTimerTrigger) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Type != nil { @@ -1076,7 +1047,7 @@ func dataSourceIBMCdTektonPipelineTriggerTimerTriggerToMap(model *cdtektonpipeli if model.Properties != nil { properties := []map[string]interface{}{} for _, propertiesItem := range model.Properties { - propertiesItemMap, err := dataSourceIBMCdTektonPipelineTriggerTimerTriggerPropertiesItemToMap(&propertiesItem) + propertiesItemMap, err := dataSourceIBMCdTektonPipelineTriggerPropertyToMap(&propertiesItem) if err != nil { return modelMap, err } @@ -1109,29 +1080,6 @@ func dataSourceIBMCdTektonPipelineTriggerTimerTriggerToMap(model *cdtektonpipeli return modelMap, nil } -func dataSourceIBMCdTektonPipelineTriggerTimerTriggerPropertiesItemToMap(model *cdtektonpipelinev2.TriggerTimerTriggerPropertiesItem) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Name != nil { - modelMap["name"] = *model.Name - } - if model.Value != nil { - modelMap["value"] = *model.Value - } - if model.Enum != nil { - modelMap["enum"] = model.Enum - } - if model.Type != nil { - modelMap["type"] = *model.Type - } - if model.Path != nil { - modelMap["path"] = *model.Path - } - if model.Href != nil { - modelMap["href"] = *model.Href - } - return modelMap, nil -} - func dataSourceIBMCdTektonPipelineTriggerGenericTriggerToMap(model *cdtektonpipelinev2.TriggerGenericTrigger) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Type != nil { @@ -1152,7 +1100,7 @@ func dataSourceIBMCdTektonPipelineTriggerGenericTriggerToMap(model *cdtektonpipe if model.Properties != nil { properties := []map[string]interface{}{} for _, propertiesItem := range model.Properties { - propertiesItemMap, err := dataSourceIBMCdTektonPipelineTriggerGenericTriggerPropertiesItemToMap(&propertiesItem) + propertiesItemMap, err := dataSourceIBMCdTektonPipelineTriggerPropertyToMap(&propertiesItem) if err != nil { return modelMap, err } @@ -1188,26 +1136,3 @@ func dataSourceIBMCdTektonPipelineTriggerGenericTriggerToMap(model *cdtektonpipe } return modelMap, nil } - -func dataSourceIBMCdTektonPipelineTriggerGenericTriggerPropertiesItemToMap(model *cdtektonpipelinev2.TriggerGenericTriggerPropertiesItem) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.Name != nil { - modelMap["name"] = *model.Name - } - if model.Value != nil { - modelMap["value"] = *model.Value - } - if model.Enum != nil { - modelMap["enum"] = model.Enum - } - if model.Type != nil { - modelMap["type"] = *model.Type - } - if model.Path != nil { - modelMap["path"] = *model.Path - } - if model.Href != nil { - modelMap["href"] = *model.Href - } - return modelMap, nil -} diff --git a/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_definition.go b/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_definition.go index 97b223d26a..a917757772 100644 --- a/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_definition.go +++ b/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_definition.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. +// Copyright IBM Corp. 2023 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline @@ -70,7 +70,7 @@ func DataSourceIBMCdTektonPipelineDefinition() *schema.Resource { "tool": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "Reference to the repository tool, in the parent toolchain, that contains the pipeline definition.", + Description: "Reference to the repository tool in the parent toolchain.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "id": &schema.Schema{ @@ -87,6 +87,11 @@ func DataSourceIBMCdTektonPipelineDefinition() *schema.Resource { }, }, }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "API URL for interacting with the definition.", + }, }, } } @@ -122,6 +127,10 @@ func dataSourceIBMCdTektonPipelineDefinitionRead(context context.Context, d *sch return diag.FromErr(fmt.Errorf("Error setting source %s", err)) } + if err = d.Set("href", definition.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + } + return nil } @@ -155,7 +164,7 @@ func dataSourceIBMCdTektonPipelineDefinitionDefinitionSourcePropertiesToMap(mode modelMap["path"] = *model.Path } if model.Tool != nil { - toolMap, err := dataSourceIBMCdTektonPipelineDefinitionDefinitionSourcePropertiesToolToMap(model.Tool) + toolMap, err := dataSourceIBMCdTektonPipelineDefinitionToolToMap(model.Tool) if err != nil { return modelMap, err } @@ -164,7 +173,7 @@ func dataSourceIBMCdTektonPipelineDefinitionDefinitionSourcePropertiesToMap(mode return modelMap, nil } -func dataSourceIBMCdTektonPipelineDefinitionDefinitionSourcePropertiesToolToMap(model *cdtektonpipelinev2.DefinitionSourcePropertiesTool) (map[string]interface{}, error) { +func dataSourceIBMCdTektonPipelineDefinitionToolToMap(model *cdtektonpipelinev2.Tool) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { modelMap["id"] = *model.ID diff --git a/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_definition_test.go b/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_definition_test.go index 16154278d7..8531510caf 100644 --- a/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_definition_test.go +++ b/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_definition_test.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. +// Copyright IBM Corp. 2023 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline_test diff --git a/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_property.go b/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_property.go index 51be57daf9..dbb849eff8 100644 --- a/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_property.go +++ b/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_property.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. +// Copyright IBM Corp. 2023 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline @@ -40,6 +40,11 @@ func DataSourceIBMCdTektonPipelineProperty() *schema.Resource { Computed: true, Description: "Property value. Any string value is valid.", }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "API URL for interacting with the property.", + }, "enum": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -89,6 +94,10 @@ func dataSourceIBMCdTektonPipelinePropertyRead(context context.Context, d *schem return diag.FromErr(fmt.Errorf("Error setting value: %s", err)) } + if err = d.Set("href", property.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + } + if err = d.Set("type", property.Type); err != nil { return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) } diff --git a/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_property_test.go b/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_property_test.go index a6f574f63f..34c6264e7b 100644 --- a/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_property_test.go +++ b/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_property_test.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. +// Copyright IBM Corp. 2023 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline_test @@ -14,13 +14,15 @@ import ( ) func TestAccIBMCdTektonPipelinePropertyDataSourceBasic(t *testing.T) { + propertyName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + propertyType := "secure" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIBMCdTektonPipelinePropertyDataSourceConfigBasic(""), + Config: testAccCheckIBMCdTektonPipelinePropertyDataSourceConfigBasic("", propertyName, propertyType), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "id"), resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "pipeline_id"), @@ -35,8 +37,8 @@ func TestAccIBMCdTektonPipelinePropertyDataSourceBasic(t *testing.T) { func TestAccIBMCdTektonPipelinePropertyDataSourceAllArgs(t *testing.T) { propertyName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - propertyValue := fmt.Sprintf("tf_value_%d", acctest.RandIntRange(10, 100)) propertyType := "text" + propertyValue := fmt.Sprintf("tf_value_%d", acctest.RandIntRange(10, 100)) propertyPath := fmt.Sprintf("tf_path_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ @@ -44,13 +46,14 @@ func TestAccIBMCdTektonPipelinePropertyDataSourceAllArgs(t *testing.T) { Providers: acc.TestAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIBMCdTektonPipelinePropertyDataSourceConfig("", propertyName, propertyValue, propertyType, propertyPath), + Config: testAccCheckIBMCdTektonPipelinePropertyDataSourceConfig("", propertyName, propertyType, propertyValue, propertyPath), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "id"), resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "pipeline_id"), resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "property_name"), resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "name"), resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "value"), + resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "href"), resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "type"), ), }, @@ -58,7 +61,7 @@ func TestAccIBMCdTektonPipelinePropertyDataSourceAllArgs(t *testing.T) { }) } -func testAccCheckIBMCdTektonPipelinePropertyDataSourceConfigBasic(propertyPipelineID string) string { +func testAccCheckIBMCdTektonPipelinePropertyDataSourceConfigBasic(propertyPipelineID string, propertyName string, propertyType string) string { rgName := acc.CdResourceGroupName tcName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) return fmt.Sprintf(` @@ -100,7 +103,7 @@ func testAccCheckIBMCdTektonPipelinePropertyDataSourceConfigBasic(propertyPipeli `, rgName, tcName) } -func testAccCheckIBMCdTektonPipelinePropertyDataSourceConfig(propertyPipelineID string, propertyName string, propertyValue string, propertyType string, propertyPath string) string { +func testAccCheckIBMCdTektonPipelinePropertyDataSourceConfig(propertyPipelineID string, propertyName string, propertyType string, propertyValue string, propertyPath string) string { rgName := acc.CdResourceGroupName tcName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) return fmt.Sprintf(` diff --git a/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_test.go b/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_test.go index c9896981fb..2912b65314 100644 --- a/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_test.go +++ b/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_test.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. +// Copyright IBM Corp. 2023 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline_test @@ -36,6 +36,8 @@ func TestAccIBMCdTektonPipelineDataSourceBasic(t *testing.T) { resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline.cd_tekton_pipeline", "worker.#"), resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline.cd_tekton_pipeline", "runs_url"), resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline.cd_tekton_pipeline", "build_number"), + resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline.cd_tekton_pipeline", "enable_notifications"), + resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline.cd_tekton_pipeline", "enable_partial_cloning"), resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline.cd_tekton_pipeline", "enabled"), ), }, @@ -67,6 +69,7 @@ func TestAccIBMCdTektonPipelineDataSourceAllArgs(t *testing.T) { resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline.cd_tekton_pipeline", "triggers.#"), resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline.cd_tekton_pipeline", "worker.#"), resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline.cd_tekton_pipeline", "runs_url"), + resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline.cd_tekton_pipeline", "href"), resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline.cd_tekton_pipeline", "build_number"), resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline.cd_tekton_pipeline", "enable_notifications"), resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline.cd_tekton_pipeline", "enable_partial_cloning"), diff --git a/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_trigger.go b/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_trigger.go index a0c5e43d7b..907fbca2a9 100644 --- a/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_trigger.go +++ b/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_trigger.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. +// Copyright IBM Corp. 2023 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline @@ -67,6 +67,11 @@ func DataSourceIBMCdTektonPipelineTrigger() *schema.Resource { Computed: true, Description: "Property value. Any string value is valid.", }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "API URL for interacting with the trigger property.", + }, "enum": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -85,11 +90,6 @@ func DataSourceIBMCdTektonPipelineTrigger() *schema.Resource { Computed: true, Description: "A dot notation path for `integration` type properties only, that selects a value from the tool integration. If left blank the full tool integration data will be used.", }, - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "API URL for interacting with the trigger property.", - }, }, }, }, @@ -303,7 +303,7 @@ func dataSourceIBMCdTektonPipelineTriggerRead(context context.Context, d *schema properties := []map[string]interface{}{} if trigger.Properties != nil { for _, modelItem := range trigger.Properties { - modelMap, err := dataSourceIBMCdTektonPipelineTriggerTriggerPropertiesItemToMap(&modelItem) + modelMap, err := dataSourceIBMCdTektonPipelineTriggerTriggerPropertyToMap(&modelItem) if err != nil { return diag.FromErr(err) } @@ -379,7 +379,7 @@ func dataSourceIBMCdTektonPipelineTriggerRead(context context.Context, d *schema return nil } -func dataSourceIBMCdTektonPipelineTriggerTriggerPropertiesItemToMap(model *cdtektonpipelinev2.TriggerPropertiesItem) (map[string]interface{}, error) { +func dataSourceIBMCdTektonPipelineTriggerTriggerPropertyToMap(model *cdtektonpipelinev2.TriggerProperty) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.Name != nil { modelMap["name"] = *model.Name @@ -387,6 +387,9 @@ func dataSourceIBMCdTektonPipelineTriggerTriggerPropertiesItemToMap(model *cdtek if model.Value != nil { modelMap["value"] = *model.Value } + if model.Href != nil { + modelMap["href"] = *model.Href + } if model.Enum != nil { modelMap["enum"] = model.Enum } @@ -396,9 +399,6 @@ func dataSourceIBMCdTektonPipelineTriggerTriggerPropertiesItemToMap(model *cdtek if model.Path != nil { modelMap["path"] = *model.Path } - if model.Href != nil { - modelMap["href"] = *model.Href - } return modelMap, nil } @@ -449,7 +449,7 @@ func dataSourceIBMCdTektonPipelineTriggerTriggerSourcePropertiesToMap(model *cdt modelMap["hook_id"] = *model.HookID } if model.Tool != nil { - toolMap, err := dataSourceIBMCdTektonPipelineTriggerTriggerSourcePropertiesToolToMap(model.Tool) + toolMap, err := dataSourceIBMCdTektonPipelineTriggerToolToMap(model.Tool) if err != nil { return modelMap, err } @@ -458,7 +458,7 @@ func dataSourceIBMCdTektonPipelineTriggerTriggerSourcePropertiesToMap(model *cdt return modelMap, nil } -func dataSourceIBMCdTektonPipelineTriggerTriggerSourcePropertiesToolToMap(model *cdtektonpipelinev2.TriggerSourcePropertiesTool) (map[string]interface{}, error) { +func dataSourceIBMCdTektonPipelineTriggerToolToMap(model *cdtektonpipelinev2.Tool) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { modelMap["id"] = *model.ID diff --git a/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_trigger_property.go b/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_trigger_property.go index 023604bb2f..5774b468ba 100644 --- a/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_trigger_property.go +++ b/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_trigger_property.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. +// Copyright IBM Corp. 2023 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline @@ -45,6 +45,11 @@ func DataSourceIBMCdTektonPipelineTriggerProperty() *schema.Resource { Computed: true, Description: "Property value. Any string value is valid.", }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "API URL for interacting with the trigger property.", + }, "enum": &schema.Schema{ Type: schema.TypeList, Computed: true, @@ -95,6 +100,10 @@ func dataSourceIBMCdTektonPipelineTriggerPropertyRead(context context.Context, d return diag.FromErr(fmt.Errorf("Error setting value: %s", err)) } + if err = d.Set("href", triggerProperty.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + } + if err = d.Set("type", triggerProperty.Type); err != nil { return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) } diff --git a/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_trigger_property_test.go b/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_trigger_property_test.go index 4a72c9a30e..213bb8f016 100644 --- a/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_trigger_property_test.go +++ b/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_trigger_property_test.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. +// Copyright IBM Corp. 2023 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline_test @@ -14,13 +14,15 @@ import ( ) func TestAccIBMCdTektonPipelineTriggerPropertyDataSourceBasic(t *testing.T) { + triggerPropertyName := "trig-prop-1" + triggerPropertyType := "text" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIBMCdTektonPipelineTriggerPropertyDataSourceConfigBasic("", ""), + Config: testAccCheckIBMCdTektonPipelineTriggerPropertyDataSourceConfigBasic("", "", triggerPropertyName, triggerPropertyType), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "id"), resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "property_name"), @@ -34,8 +36,8 @@ func TestAccIBMCdTektonPipelineTriggerPropertyDataSourceBasic(t *testing.T) { func TestAccIBMCdTektonPipelineTriggerPropertyDataSourceAllArgs(t *testing.T) { triggerPropertyName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - triggerPropertyValue := fmt.Sprintf("tf_value_%d", acctest.RandIntRange(10, 100)) triggerPropertyType := "text" + triggerPropertyValue := fmt.Sprintf("tf_value_%d", acctest.RandIntRange(10, 100)) triggerPropertyPath := fmt.Sprintf("tf_path_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ @@ -43,12 +45,13 @@ func TestAccIBMCdTektonPipelineTriggerPropertyDataSourceAllArgs(t *testing.T) { Providers: acc.TestAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIBMCdTektonPipelineTriggerPropertyDataSourceConfig("", "", triggerPropertyName, triggerPropertyValue, triggerPropertyType, triggerPropertyPath), + Config: testAccCheckIBMCdTektonPipelineTriggerPropertyDataSourceConfig("", "", triggerPropertyName, triggerPropertyType, triggerPropertyValue, triggerPropertyPath), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "id"), resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "property_name"), resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "name"), resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "value"), + resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "href"), resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "type"), ), }, @@ -56,7 +59,7 @@ func TestAccIBMCdTektonPipelineTriggerPropertyDataSourceAllArgs(t *testing.T) { }) } -func testAccCheckIBMCdTektonPipelineTriggerPropertyDataSourceConfigBasic(triggerPropertyPipelineID string, triggerPropertyTriggerID string) string { +func testAccCheckIBMCdTektonPipelineTriggerPropertyDataSourceConfigBasic(triggerPropertyPipelineID string, triggerPropertyTriggerID string, triggerPropertyName string, triggerPropertyType string) string { rgName := acc.CdResourceGroupName tcName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) return fmt.Sprintf(` @@ -107,12 +110,12 @@ func testAccCheckIBMCdTektonPipelineTriggerPropertyDataSourceConfigBasic(trigger } resource "ibm_cd_tekton_pipeline_trigger" "cd_tekton_pipeline_trigger" { pipeline_id = ibm_cd_toolchain_tool_pipeline.ibm_cd_toolchain_tool_pipeline.tool_id - type = "manual" - event_listener = "listener" depends_on = [ ibm_cd_tekton_pipeline_definition.cd_tekton_pipeline_definition ] name = "trigger" + type = "manual" + event_listener = "listener" } resource "ibm_cd_tekton_pipeline_trigger_property" "cd_tekton_pipeline_trigger_property" { pipeline_id = ibm_cd_tekton_pipeline.cd_tekton_pipeline.pipeline_id @@ -129,7 +132,7 @@ func testAccCheckIBMCdTektonPipelineTriggerPropertyDataSourceConfigBasic(trigger `, rgName, tcName) } -func testAccCheckIBMCdTektonPipelineTriggerPropertyDataSourceConfig(triggerPropertyPipelineID string, triggerPropertyTriggerID string, triggerPropertyName string, triggerPropertyValue string, triggerPropertyType string, triggerPropertyPath string) string { +func testAccCheckIBMCdTektonPipelineTriggerPropertyDataSourceConfig(triggerPropertyPipelineID string, triggerPropertyTriggerID string, triggerPropertyName string, triggerPropertyType string, triggerPropertyValue string, triggerPropertyPath string) string { rgName := acc.CdResourceGroupName tcName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) return fmt.Sprintf(` @@ -180,24 +183,24 @@ func testAccCheckIBMCdTektonPipelineTriggerPropertyDataSourceConfig(triggerPrope } resource "ibm_cd_tekton_pipeline_trigger" "cd_tekton_pipeline_trigger" { pipeline_id = ibm_cd_toolchain_tool_pipeline.ibm_cd_toolchain_tool_pipeline.tool_id - type = "manual" - event_listener = "listener" depends_on = [ ibm_cd_tekton_pipeline_definition.cd_tekton_pipeline_definition ] name = "trigger" + type = "manual" + event_listener = "listener" } resource "ibm_cd_tekton_pipeline_trigger_property" "cd_tekton_pipeline_trigger_property" { pipeline_id = ibm_cd_tekton_pipeline.cd_tekton_pipeline.pipeline_id trigger_id = ibm_cd_tekton_pipeline_trigger.cd_tekton_pipeline_trigger.trigger_id name = "%s" - value = "%s" type = "%s" + value = "%s" } data "ibm_cd_tekton_pipeline_trigger_property" "cd_tekton_pipeline_trigger_property" { pipeline_id = ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property.pipeline_id trigger_id = ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property.trigger_id property_name = "%s" } - `, rgName, tcName, triggerPropertyName, triggerPropertyValue, triggerPropertyType, triggerPropertyName) + `, rgName, tcName, triggerPropertyName, triggerPropertyType, triggerPropertyValue, triggerPropertyName) } diff --git a/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_trigger_test.go b/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_trigger_test.go index f3ce95193c..1ec836c698 100644 --- a/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_trigger_test.go +++ b/ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline_trigger_test.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. +// Copyright IBM Corp. 2023 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline_test @@ -15,13 +15,16 @@ import ( func TestAccIBMCdTektonPipelineTriggerDataSourceBasic(t *testing.T) { triggerPipelineID := fmt.Sprintf("tf_pipeline_id_%d", acctest.RandIntRange(10, 100)) + triggerType := "manual" + triggerName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + triggerEventListener := "listener" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIBMCdTektonPipelineTriggerDataSourceConfigBasic(triggerPipelineID), + Config: testAccCheckIBMCdTektonPipelineTriggerDataSourceConfigBasic(triggerPipelineID, triggerType, triggerName, triggerEventListener), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_trigger.cd_tekton_pipeline_trigger", "id"), resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_trigger.cd_tekton_pipeline_trigger", "pipeline_id"), @@ -68,7 +71,7 @@ func TestAccIBMCdTektonPipelineTriggerDataSourceAllArgs(t *testing.T) { }) } -func testAccCheckIBMCdTektonPipelineTriggerDataSourceConfigBasic(triggerPipelineID string) string { +func testAccCheckIBMCdTektonPipelineTriggerDataSourceConfigBasic(triggerPipelineID string, triggerType string, triggerName string, triggerEventListener string) string { rgName := acc.CdResourceGroupName tcName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) return fmt.Sprintf(` @@ -119,19 +122,19 @@ func testAccCheckIBMCdTektonPipelineTriggerDataSourceConfigBasic(triggerPipeline } resource "ibm_cd_tekton_pipeline_trigger" "cd_tekton_pipeline_trigger" { pipeline_id = ibm_cd_toolchain_tool_pipeline.ibm_cd_toolchain_tool_pipeline.tool_id - type = "manual" - event_listener = "listener" depends_on = [ ibm_cd_tekton_pipeline_definition.cd_tekton_pipeline_definition ] - name = "trigger" + type = "%s" + name = "%s" + event_listener = "%s" } data "ibm_cd_tekton_pipeline_trigger" "cd_tekton_pipeline_trigger" { pipeline_id = ibm_cd_tekton_pipeline_trigger.cd_tekton_pipeline_trigger.pipeline_id trigger_id = ibm_cd_tekton_pipeline_trigger.cd_tekton_pipeline_trigger.trigger_id } - `, rgName, tcName) + `, rgName, tcName, triggerType, triggerName, triggerEventListener) } func testAccCheckIBMCdTektonPipelineTriggerDataSourceConfig(triggerPipelineID string, triggerType string, triggerName string, triggerEventListener string, triggerMaxConcurrentRuns string, triggerEnabled string, triggerCron string, triggerTimezone string) string { @@ -185,12 +188,12 @@ func testAccCheckIBMCdTektonPipelineTriggerDataSourceConfig(triggerPipelineID st } resource "ibm_cd_tekton_pipeline_trigger" "cd_tekton_pipeline_trigger" { pipeline_id = ibm_cd_toolchain_tool_pipeline.ibm_cd_toolchain_tool_pipeline.tool_id - type = "manual" - event_listener = "listener" depends_on = [ ibm_cd_tekton_pipeline_definition.cd_tekton_pipeline_definition ] + type = "%s" name = "%s" + event_listener = "%s" max_concurrent_runs = %s enabled = %s } @@ -199,5 +202,5 @@ func testAccCheckIBMCdTektonPipelineTriggerDataSourceConfig(triggerPipelineID st pipeline_id = ibm_cd_tekton_pipeline_trigger.cd_tekton_pipeline_trigger.pipeline_id trigger_id = ibm_cd_tekton_pipeline_trigger.cd_tekton_pipeline_trigger.trigger_id } - `, rgName, tcName, triggerName, triggerMaxConcurrentRuns, triggerEnabled) + `, rgName, tcName, triggerType, triggerName, triggerEventListener, triggerMaxConcurrentRuns, triggerEnabled) } diff --git a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline.go b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline.go index 882480aba3..381f4867d0 100644 --- a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline.go +++ b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. +// Copyright IBM Corp. 2023 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline @@ -48,6 +48,7 @@ func ResourceIBMCdTektonPipeline() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Required: true, + ForceNew: true, Description: "ID of the worker.", }, }, @@ -72,7 +73,7 @@ func ResourceIBMCdTektonPipeline() *schema.Resource { "resource_group": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "The ID of the resource group in which the pipeline was created.", + Description: "The resource group in which the pipeline was created.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "id": &schema.Schema{ @@ -153,7 +154,7 @@ func ResourceIBMCdTektonPipeline() *schema.Resource { "tool": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "Reference to the repository tool, in the parent toolchain, that contains the pipeline definition.", + Description: "Reference to the repository tool in the parent toolchain.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "id": &schema.Schema{ @@ -170,10 +171,15 @@ func ResourceIBMCdTektonPipeline() *schema.Resource { }, }, }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "API URL for interacting with the definition.", + }, "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "UUID.", + Description: "The aggregated definition ID.", }, }, }, @@ -196,6 +202,11 @@ func ResourceIBMCdTektonPipeline() *schema.Resource { DiffSuppressFunc: flex.SuppressPipelinePropertyRawSecret, Description: "Property value. Any string value is valid.", }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "API URL for interacting with the property.", + }, "enum": &schema.Schema{ Type: schema.TypeList, Optional: true, @@ -243,7 +254,7 @@ func ResourceIBMCdTektonPipeline() *schema.Resource { }, "href": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "API URL for interacting with the trigger. Only included when fetching the list of pipeline triggers.", }, "event_listener": &schema.Schema{ @@ -254,7 +265,7 @@ func ResourceIBMCdTektonPipeline() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "ID.", + Description: "The Trigger ID.", }, "properties": &schema.Schema{ Type: schema.TypeList, @@ -274,6 +285,11 @@ func ResourceIBMCdTektonPipeline() *schema.Resource { DiffSuppressFunc: flex.SuppressTriggerPropertyRawSecret, Description: "Property value. Any string value is valid.", }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "API URL for interacting with the trigger property.", + }, "enum": &schema.Schema{ Type: schema.TypeList, Optional: true, @@ -290,11 +306,6 @@ func ResourceIBMCdTektonPipeline() *schema.Resource { Optional: true, Description: "A dot notation path for `integration` type properties only, that selects a value from the tool integration. If left blank the full tool integration data will be used.", }, - "href": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "API URL for interacting with the trigger property.", - }, }, }, }, @@ -324,7 +335,6 @@ func ResourceIBMCdTektonPipeline() *schema.Resource { "id": &schema.Schema{ Type: schema.TypeString, Required: true, - ForceNew: true, Description: "ID of the worker.", }, }, @@ -379,7 +389,7 @@ func ResourceIBMCdTektonPipeline() *schema.Resource { }, "blind_connection": &schema.Schema{ Type: schema.TypeBool, - Optional: true, + Computed: true, Description: "True if the repository server is not addressable on the public internet. IBM Cloud will not be able to validate the connection details you provide.", }, "hook_id": &schema.Schema{ @@ -461,7 +471,7 @@ func ResourceIBMCdTektonPipeline() *schema.Resource { }, "webhook_url": &schema.Schema{ Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Webhook URL that can be used to trigger pipeline runs.", }, }, @@ -472,6 +482,11 @@ func ResourceIBMCdTektonPipeline() *schema.Resource { Computed: true, Description: "URL for this pipeline showing the list of pipeline runs.", }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "API URL for interacting with the pipeline.", + }, "build_number": &schema.Schema{ Type: schema.TypeInt, Computed: true, @@ -566,7 +581,7 @@ func resourceIBMCdTektonPipelineRead(context context.Context, d *schema.Resource if err = d.Set("status", tektonPipeline.Status); err != nil { return diag.FromErr(fmt.Errorf("Error setting status: %s", err)) } - resourceGroupMap, err := resourceIBMCdTektonPipelineTektonPipelineResourceGroupToMap(tektonPipeline.ResourceGroup) + resourceGroupMap, err := resourceIBMCdTektonPipelineResourceGroupReferenceToMap(tektonPipeline.ResourceGroup) if err != nil { return diag.FromErr(err) } @@ -622,6 +637,9 @@ func resourceIBMCdTektonPipelineRead(context context.Context, d *schema.Resource if err = d.Set("runs_url", tektonPipeline.RunsURL); err != nil { return diag.FromErr(fmt.Errorf("Error setting runs_url: %s", err)) } + if err = d.Set("href", tektonPipeline.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + } if err = d.Set("build_number", flex.IntValue(tektonPipeline.BuildNumber)); err != nil { return diag.FromErr(fmt.Errorf("Error setting build_number: %s", err)) } @@ -704,13 +722,12 @@ func resourceIBMCdTektonPipelineMapToWorkerIdentity(modelMap map[string]interfac } func resourceIBMCdTektonPipelineWorkerIdentityToMap(model *cdtektonpipelinev2.Worker) (map[string]interface{}, error) { - // TODO we alter cdtektonpipelinev2.WorkerIdentity to cdtektonpipelinev2.Worker in func params. Determine why and if we can fix it modelMap := make(map[string]interface{}) modelMap["id"] = model.ID return modelMap, nil } -func resourceIBMCdTektonPipelineTektonPipelineResourceGroupToMap(model *cdtektonpipelinev2.TektonPipelineResourceGroup) (map[string]interface{}, error) { +func resourceIBMCdTektonPipelineResourceGroupReferenceToMap(model *cdtektonpipelinev2.ResourceGroupReference) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) if model.ID != nil { modelMap["id"] = model.ID @@ -732,9 +749,10 @@ func resourceIBMCdTektonPipelineDefinitionToMap(model *cdtektonpipelinev2.Defini return modelMap, err } modelMap["source"] = []map[string]interface{}{sourceMap} - if model.ID != nil { - modelMap["id"] = model.ID + if model.Href != nil { + modelMap["href"] = model.Href } + modelMap["id"] = model.ID return modelMap, nil } @@ -760,7 +778,7 @@ func resourceIBMCdTektonPipelineDefinitionSourcePropertiesToMap(model *cdtektonp } modelMap["path"] = model.Path if model.Tool != nil { - toolMap, err := resourceIBMCdTektonPipelineDefinitionSourcePropertiesToolToMap(model.Tool) + toolMap, err := resourceIBMCdTektonPipelineToolToMap(model.Tool) if err != nil { return modelMap, err } @@ -769,11 +787,9 @@ func resourceIBMCdTektonPipelineDefinitionSourcePropertiesToMap(model *cdtektonp return modelMap, nil } -func resourceIBMCdTektonPipelineDefinitionSourcePropertiesToolToMap(model *cdtektonpipelinev2.DefinitionSourcePropertiesTool) (map[string]interface{}, error) { +func resourceIBMCdTektonPipelineToolToMap(model *cdtektonpipelinev2.Tool) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } + modelMap["id"] = model.ID return modelMap, nil } @@ -783,6 +799,9 @@ func resourceIBMCdTektonPipelinePropertyToMap(model *cdtektonpipelinev2.Property if model.Value != nil { modelMap["value"] = model.Value } + if model.Href != nil { + modelMap["href"] = model.Href + } if model.Enum != nil { modelMap["enum"] = model.Enum } @@ -823,7 +842,7 @@ func resourceIBMCdTektonPipelineTriggerToMap(model cdtektonpipelinev2.TriggerInt if model.Properties != nil { properties := []map[string]interface{}{} for _, propertiesItem := range model.Properties { - propertiesItemMap, err := resourceIBMCdTektonPipelineTriggerPropertiesItemToMap(&propertiesItem) + propertiesItemMap, err := resourceIBMCdTektonPipelineTriggerPropertyToMap(&propertiesItem) if err != nil { return modelMap, err } @@ -879,12 +898,15 @@ func resourceIBMCdTektonPipelineTriggerToMap(model cdtektonpipelinev2.TriggerInt } } -func resourceIBMCdTektonPipelineTriggerPropertiesItemToMap(model *cdtektonpipelinev2.TriggerPropertiesItem) (map[string]interface{}, error) { +func resourceIBMCdTektonPipelineTriggerPropertyToMap(model *cdtektonpipelinev2.TriggerProperty) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name if model.Value != nil { modelMap["value"] = model.Value } + if model.Href != nil { + modelMap["href"] = model.Href + } if model.Enum != nil { modelMap["enum"] = model.Enum } @@ -892,9 +914,6 @@ func resourceIBMCdTektonPipelineTriggerPropertiesItemToMap(model *cdtektonpipeli if model.Path != nil { modelMap["path"] = model.Path } - if model.Href != nil { - modelMap["href"] = model.Href - } return modelMap, nil } @@ -930,27 +949,15 @@ func resourceIBMCdTektonPipelineTriggerSourcePropertiesToMap(model *cdtektonpipe if model.Pattern != nil { modelMap["pattern"] = model.Pattern } - if model.BlindConnection != nil { - modelMap["blind_connection"] = model.BlindConnection - } + modelMap["blind_connection"] = model.BlindConnection if model.HookID != nil { modelMap["hook_id"] = model.HookID } - if model.Tool != nil { - toolMap, err := resourceIBMCdTektonPipelineTriggerSourcePropertiesToolToMap(model.Tool) - if err != nil { - return modelMap, err - } - modelMap["tool"] = []map[string]interface{}{toolMap} - } - return modelMap, nil -} - -func resourceIBMCdTektonPipelineTriggerSourcePropertiesToolToMap(model *cdtektonpipelinev2.TriggerSourcePropertiesTool) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID + toolMap, err := resourceIBMCdTektonPipelineToolToMap(model.Tool) + if err != nil { + return modelMap, err } + modelMap["tool"] = []map[string]interface{}{toolMap} return modelMap, nil } @@ -986,7 +993,7 @@ func resourceIBMCdTektonPipelineTriggerManualTriggerToMap(model *cdtektonpipelin if model.Properties != nil { properties := []map[string]interface{}{} for _, propertiesItem := range model.Properties { - propertiesItemMap, err := resourceIBMCdTektonPipelineTriggerManualTriggerPropertiesItemToMap(&propertiesItem) + propertiesItemMap, err := resourceIBMCdTektonPipelineTriggerPropertyToMap(&propertiesItem) if err != nil { return modelMap, err } @@ -1011,25 +1018,6 @@ func resourceIBMCdTektonPipelineTriggerManualTriggerToMap(model *cdtektonpipelin return modelMap, nil } -func resourceIBMCdTektonPipelineTriggerManualTriggerPropertiesItemToMap(model *cdtektonpipelinev2.TriggerManualTriggerPropertiesItem) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Value != nil { - modelMap["value"] = model.Value - } - if model.Enum != nil { - modelMap["enum"] = model.Enum - } - modelMap["type"] = model.Type - if model.Path != nil { - modelMap["path"] = model.Path - } - if model.Href != nil { - modelMap["href"] = model.Href - } - return modelMap, nil -} - func resourceIBMCdTektonPipelineTriggerScmTriggerToMap(model *cdtektonpipelinev2.TriggerScmTrigger) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["type"] = model.Type @@ -1042,7 +1030,7 @@ func resourceIBMCdTektonPipelineTriggerScmTriggerToMap(model *cdtektonpipelinev2 if model.Properties != nil { properties := []map[string]interface{}{} for _, propertiesItem := range model.Properties { - propertiesItemMap, err := resourceIBMCdTektonPipelineTriggerScmTriggerPropertiesItemToMap(&propertiesItem) + propertiesItemMap, err := resourceIBMCdTektonPipelineTriggerPropertyToMap(&propertiesItem) if err != nil { return modelMap, err } @@ -1077,25 +1065,6 @@ func resourceIBMCdTektonPipelineTriggerScmTriggerToMap(model *cdtektonpipelinev2 return modelMap, nil } -func resourceIBMCdTektonPipelineTriggerScmTriggerPropertiesItemToMap(model *cdtektonpipelinev2.TriggerScmTriggerPropertiesItem) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Value != nil { - modelMap["value"] = model.Value - } - if model.Enum != nil { - modelMap["enum"] = model.Enum - } - modelMap["type"] = model.Type - if model.Path != nil { - modelMap["path"] = model.Path - } - if model.Href != nil { - modelMap["href"] = model.Href - } - return modelMap, nil -} - func resourceIBMCdTektonPipelineTriggerTimerTriggerToMap(model *cdtektonpipelinev2.TriggerTimerTrigger) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["type"] = model.Type @@ -1108,7 +1077,7 @@ func resourceIBMCdTektonPipelineTriggerTimerTriggerToMap(model *cdtektonpipeline if model.Properties != nil { properties := []map[string]interface{}{} for _, propertiesItem := range model.Properties { - propertiesItemMap, err := resourceIBMCdTektonPipelineTriggerTimerTriggerPropertiesItemToMap(&propertiesItem) + propertiesItemMap, err := resourceIBMCdTektonPipelineTriggerPropertyToMap(&propertiesItem) if err != nil { return modelMap, err } @@ -1139,25 +1108,6 @@ func resourceIBMCdTektonPipelineTriggerTimerTriggerToMap(model *cdtektonpipeline return modelMap, nil } -func resourceIBMCdTektonPipelineTriggerTimerTriggerPropertiesItemToMap(model *cdtektonpipelinev2.TriggerTimerTriggerPropertiesItem) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Value != nil { - modelMap["value"] = model.Value - } - if model.Enum != nil { - modelMap["enum"] = model.Enum - } - modelMap["type"] = model.Type - if model.Path != nil { - modelMap["path"] = model.Path - } - if model.Href != nil { - modelMap["href"] = model.Href - } - return modelMap, nil -} - func resourceIBMCdTektonPipelineTriggerGenericTriggerToMap(model *cdtektonpipelinev2.TriggerGenericTrigger) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["type"] = model.Type @@ -1170,7 +1120,7 @@ func resourceIBMCdTektonPipelineTriggerGenericTriggerToMap(model *cdtektonpipeli if model.Properties != nil { properties := []map[string]interface{}{} for _, propertiesItem := range model.Properties { - propertiesItemMap, err := resourceIBMCdTektonPipelineTriggerGenericTriggerPropertiesItemToMap(&propertiesItem) + propertiesItemMap, err := resourceIBMCdTektonPipelineTriggerPropertyToMap(&propertiesItem) if err != nil { return modelMap, err } @@ -1204,22 +1154,3 @@ func resourceIBMCdTektonPipelineTriggerGenericTriggerToMap(model *cdtektonpipeli } return modelMap, nil } - -func resourceIBMCdTektonPipelineTriggerGenericTriggerPropertiesItemToMap(model *cdtektonpipelinev2.TriggerGenericTriggerPropertiesItem) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - modelMap["name"] = model.Name - if model.Value != nil { - modelMap["value"] = model.Value - } - if model.Enum != nil { - modelMap["enum"] = model.Enum - } - modelMap["type"] = model.Type - if model.Path != nil { - modelMap["path"] = model.Path - } - if model.Href != nil { - modelMap["href"] = model.Href - } - return modelMap, nil -} diff --git a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_definition.go b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_definition.go index 3dd74cf8d3..a95b69a96f 100644 --- a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_definition.go +++ b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_definition.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. +// Copyright IBM Corp. 2023 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline @@ -36,8 +36,9 @@ func ResourceIBMCdTektonPipelineDefinition() *schema.Resource { }, "source": &schema.Schema{ Type: schema.TypeList, + MinItems: 1, MaxItems: 1, - Optional: true, + Required: true, Description: "Source repository containing the Tekton pipeline definition.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -78,7 +79,7 @@ func ResourceIBMCdTektonPipelineDefinition() *schema.Resource { "tool": &schema.Schema{ Type: schema.TypeList, Computed: true, - Description: "Reference to the repository tool, in the parent toolchain, that contains the pipeline definition.", + Description: "Reference to the repository tool in the parent toolchain.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "id": &schema.Schema{ @@ -95,10 +96,15 @@ func ResourceIBMCdTektonPipelineDefinition() *schema.Resource { }, }, }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "API URL for interacting with the definition.", + }, "definition_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "UUID.", + Description: "The aggregated definition ID.", }, }, } @@ -131,13 +137,11 @@ func resourceIBMCdTektonPipelineDefinitionCreate(context context.Context, d *sch createTektonPipelineDefinitionOptions := &cdtektonpipelinev2.CreateTektonPipelineDefinitionOptions{} createTektonPipelineDefinitionOptions.SetPipelineID(d.Get("pipeline_id").(string)) - if _, ok := d.GetOk("source"); ok { - sourceModel, err := resourceIBMCdTektonPipelineDefinitionMapToDefinitionSource(d.Get("source.0").(map[string]interface{})) - if err != nil { - return diag.FromErr(err) - } - createTektonPipelineDefinitionOptions.SetSource(sourceModel) + sourceModel, err := resourceIBMCdTektonPipelineDefinitionMapToDefinitionSource(d.Get("source.0").(map[string]interface{})) + if err != nil { + return diag.FromErr(err) } + createTektonPipelineDefinitionOptions.SetSource(sourceModel) definition, response, err := cdTektonPipelineClient.CreateTektonPipelineDefinitionWithContext(context, createTektonPipelineDefinitionOptions) if err != nil { @@ -179,14 +183,15 @@ func resourceIBMCdTektonPipelineDefinitionRead(context context.Context, d *schem if err = d.Set("pipeline_id", getTektonPipelineDefinitionOptions.PipelineID); err != nil { return diag.FromErr(fmt.Errorf("Error setting pipeline_id: %s", err)) } - if definition.Source != nil { - sourceMap, err := resourceIBMCdTektonPipelineDefinitionDefinitionSourceToMap(definition.Source) - if err != nil { - return diag.FromErr(err) - } - if err = d.Set("source", []map[string]interface{}{sourceMap}); err != nil { - return diag.FromErr(fmt.Errorf("Error setting source: %s", err)) - } + sourceMap, err := resourceIBMCdTektonPipelineDefinitionDefinitionSourceToMap(definition.Source) + if err != nil { + return diag.FromErr(err) + } + if err = d.Set("source", []map[string]interface{}{sourceMap}); err != nil { + return diag.FromErr(fmt.Errorf("Error setting source: %s", err)) + } + if err = d.Set("href", definition.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) } if err = d.Set("definition_id", definition.ID); err != nil { return diag.FromErr(fmt.Errorf("Error setting definition_id: %s", err)) @@ -286,7 +291,7 @@ func resourceIBMCdTektonPipelineDefinitionMapToDefinitionSourceProperties(modelM } model.Path = core.StringPtr(modelMap["path"].(string)) if modelMap["tool"] != nil && len(modelMap["tool"].([]interface{})) > 0 { - ToolModel, err := resourceIBMCdTektonPipelineDefinitionMapToDefinitionSourcePropertiesTool(modelMap["tool"].([]interface{})[0].(map[string]interface{})) + ToolModel, err := resourceIBMCdTektonPipelineDefinitionMapToTool(modelMap["tool"].([]interface{})[0].(map[string]interface{})) if err != nil { return model, err } @@ -295,11 +300,9 @@ func resourceIBMCdTektonPipelineDefinitionMapToDefinitionSourceProperties(modelM return model, nil } -func resourceIBMCdTektonPipelineDefinitionMapToDefinitionSourcePropertiesTool(modelMap map[string]interface{}) (*cdtektonpipelinev2.DefinitionSourcePropertiesTool, error) { - model := &cdtektonpipelinev2.DefinitionSourcePropertiesTool{} - if modelMap["id"] != nil && modelMap["id"].(string) != "" { - model.ID = core.StringPtr(modelMap["id"].(string)) - } +func resourceIBMCdTektonPipelineDefinitionMapToTool(modelMap map[string]interface{}) (*cdtektonpipelinev2.Tool, error) { + model := &cdtektonpipelinev2.Tool{} + model.ID = core.StringPtr(modelMap["id"].(string)) return model, nil } @@ -325,7 +328,7 @@ func resourceIBMCdTektonPipelineDefinitionDefinitionSourcePropertiesToMap(model } modelMap["path"] = model.Path if model.Tool != nil { - toolMap, err := resourceIBMCdTektonPipelineDefinitionDefinitionSourcePropertiesToolToMap(model.Tool) + toolMap, err := resourceIBMCdTektonPipelineDefinitionToolToMap(model.Tool) if err != nil { return modelMap, err } @@ -334,10 +337,8 @@ func resourceIBMCdTektonPipelineDefinitionDefinitionSourcePropertiesToMap(model return modelMap, nil } -func resourceIBMCdTektonPipelineDefinitionDefinitionSourcePropertiesToolToMap(model *cdtektonpipelinev2.DefinitionSourcePropertiesTool) (map[string]interface{}, error) { +func resourceIBMCdTektonPipelineDefinitionToolToMap(model *cdtektonpipelinev2.Tool) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } + modelMap["id"] = model.ID return modelMap, nil } diff --git a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_definition_test.go b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_definition_test.go index 8df2c51fbf..52f82fef3d 100644 --- a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_definition_test.go +++ b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_definition_test.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. +// Copyright IBM Corp. 2023 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline_test diff --git a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_property.go b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_property.go index 8fd65e9a43..9691e2368d 100644 --- a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_property.go +++ b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_property.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. +// Copyright IBM Corp. 2023 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline @@ -40,6 +40,12 @@ func ResourceIBMCdTektonPipelineProperty() *schema.Resource { ValidateFunc: validate.InvokeValidator("ibm_cd_tekton_pipeline_property", "name"), Description: "Property name.", }, + "type": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.InvokeValidator("ibm_cd_tekton_pipeline_property", "type"), + Description: "Property type.", + }, "value": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -53,18 +59,17 @@ func ResourceIBMCdTektonPipelineProperty() *schema.Resource { Description: "Options for `single_select` property type. Only needed when using `single_select` property type.", Elem: &schema.Schema{Type: schema.TypeString}, }, - "type": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_cd_tekton_pipeline_property", "type"), - Description: "Property type.", - }, "path": &schema.Schema{ Type: schema.TypeString, Optional: true, ValidateFunc: validate.InvokeValidator("ibm_cd_tekton_pipeline_property", "path"), Description: "A dot notation path for `integration` type properties only, to select a value from the tool integration. If left blank the full tool integration data will be used.", }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "API URL for interacting with the property.", + }, }, } } @@ -90,6 +95,13 @@ func ResourceIBMCdTektonPipelinePropertyValidator() *validate.ResourceValidator MinValueLength: 1, MaxValueLength: 253, }, + validate.ValidateSchema{ + Identifier: "type", + ValidateFunctionIdentifier: validate.ValidateAllowedStringValue, + Type: validate.TypeString, + Required: true, + AllowedValues: "appconfig, integration, secure, single_select, text", + }, validate.ValidateSchema{ Identifier: "value", ValidateFunctionIdentifier: validate.ValidateRegexpLen, @@ -99,13 +111,6 @@ func ResourceIBMCdTektonPipelinePropertyValidator() *validate.ResourceValidator MinValueLength: 0, MaxValueLength: 4096, }, - validate.ValidateSchema{ - Identifier: "type", - ValidateFunctionIdentifier: validate.ValidateAllowedStringValue, - Type: validate.TypeString, - Required: true, - AllowedValues: "appconfig, integration, secure, single_select, text", - }, validate.ValidateSchema{ Identifier: "path", ValidateFunctionIdentifier: validate.ValidateRegexpLen, @@ -130,9 +135,8 @@ func resourceIBMCdTektonPipelinePropertyCreate(context context.Context, d *schem createTektonPipelinePropertiesOptions := &cdtektonpipelinev2.CreateTektonPipelinePropertiesOptions{} createTektonPipelinePropertiesOptions.SetPipelineID(d.Get("pipeline_id").(string)) - if _, ok := d.GetOk("name"); ok { - createTektonPipelinePropertiesOptions.SetName(d.Get("name").(string)) - } + createTektonPipelinePropertiesOptions.SetName(d.Get("name").(string)) + createTektonPipelinePropertiesOptions.SetType(d.Get("type").(string)) if _, ok := d.GetOk("value"); ok { createTektonPipelinePropertiesOptions.SetValue(d.Get("value").(string)) } @@ -144,9 +148,6 @@ func resourceIBMCdTektonPipelinePropertyCreate(context context.Context, d *schem } createTektonPipelinePropertiesOptions.SetEnum(enum) } - if _, ok := d.GetOk("type"); ok { - createTektonPipelinePropertiesOptions.SetType(d.Get("type").(string)) - } if _, ok := d.GetOk("path"); ok { createTektonPipelinePropertiesOptions.SetPath(d.Get("path").(string)) } @@ -194,6 +195,9 @@ func resourceIBMCdTektonPipelinePropertyRead(context context.Context, d *schema. if err = d.Set("name", property.Name); err != nil { return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) } + if err = d.Set("type", property.Type); err != nil { + return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) + } if err = d.Set("value", property.Value); err != nil { return diag.FromErr(fmt.Errorf("Error setting value: %s", err)) } @@ -202,12 +206,12 @@ func resourceIBMCdTektonPipelinePropertyRead(context context.Context, d *schema. return diag.FromErr(fmt.Errorf("Error setting enum: %s", err)) } } - if err = d.Set("type", property.Type); err != nil { - return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) - } if err = d.Set("path", property.Path); err != nil { return diag.FromErr(fmt.Errorf("Error setting path: %s", err)) } + if err = d.Set("href", property.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + } return nil } @@ -240,6 +244,10 @@ func resourceIBMCdTektonPipelinePropertyUpdate(context context.Context, d *schem return diag.FromErr(fmt.Errorf("Cannot update resource property \"%s\" with the ForceNew annotation."+ " The resource must be re-created to update this property.", "name")) } + if d.HasChange("type") { + replaceTektonPipelinePropertyOptions.SetType(d.Get("type").(string)) + hasChange = true + } if d.Get("type").(string) == "integration" { if d.HasChange("value") || d.HasChange("path") { diff --git a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_property_test.go b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_property_test.go index 6533c543d0..73aaddbcb7 100644 --- a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_property_test.go +++ b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_property_test.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. +// Copyright IBM Corp. 2023 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline_test @@ -19,6 +19,9 @@ import ( func TestAccIBMCdTektonPipelinePropertyBasic(t *testing.T) { var conf cdtektonpipelinev2.Property + name := "property1" + typeVar := "text" + typeVarUpdate := "text" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -26,9 +29,18 @@ func TestAccIBMCdTektonPipelinePropertyBasic(t *testing.T) { CheckDestroy: testAccCheckIBMCdTektonPipelinePropertyDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIBMCdTektonPipelinePropertyConfigBasic(""), + Config: testAccCheckIBMCdTektonPipelinePropertyConfigBasic("", name, typeVar), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckIBMCdTektonPipelinePropertyExists("ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", conf), + resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "name", name), + resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "type", typeVar), + ), + }, + resource.TestStep{ + Config: testAccCheckIBMCdTektonPipelinePropertyConfigBasic("", name, typeVarUpdate), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "name", name), + resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "type", typeVarUpdate), ), }, }, @@ -38,11 +50,11 @@ func TestAccIBMCdTektonPipelinePropertyBasic(t *testing.T) { func TestAccIBMCdTektonPipelinePropertyAllArgs(t *testing.T) { var conf cdtektonpipelinev2.Property name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - value := fmt.Sprintf("tf_value_%d", acctest.RandIntRange(10, 100)) typeVar := "text" + value := fmt.Sprintf("tf_value_%d", acctest.RandIntRange(10, 100)) path := fmt.Sprintf("tf_path_%d", acctest.RandIntRange(10, 100)) - valueUpdate := fmt.Sprintf("tf_value_%d", acctest.RandIntRange(10, 100)) typeVarUpdate := "text" + valueUpdate := fmt.Sprintf("tf_value_%d", acctest.RandIntRange(10, 100)) pathUpdate := fmt.Sprintf("tf_path_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ @@ -51,20 +63,20 @@ func TestAccIBMCdTektonPipelinePropertyAllArgs(t *testing.T) { CheckDestroy: testAccCheckIBMCdTektonPipelinePropertyDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIBMCdTektonPipelinePropertyConfig("", name, value, typeVar, path), + Config: testAccCheckIBMCdTektonPipelinePropertyConfig("", name, typeVar, value, path), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckIBMCdTektonPipelinePropertyExists("ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", conf), resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "name", name), - resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "value", value), resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "type", typeVar), + resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "value", value), ), }, resource.TestStep{ - Config: testAccCheckIBMCdTektonPipelinePropertyConfig("", name, valueUpdate, typeVarUpdate, pathUpdate), + Config: testAccCheckIBMCdTektonPipelinePropertyConfig("", name, typeVarUpdate, valueUpdate, pathUpdate), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "name", name), - resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "value", valueUpdate), resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "type", typeVarUpdate), + resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "value", valueUpdate), ), }, resource.TestStep{ @@ -76,7 +88,7 @@ func TestAccIBMCdTektonPipelinePropertyAllArgs(t *testing.T) { }) } -func testAccCheckIBMCdTektonPipelinePropertyConfigBasic(pipelineID string) string { +func testAccCheckIBMCdTektonPipelinePropertyConfigBasic(pipelineID string, name string, typeVar string) string { rgName := acc.CdResourceGroupName tcName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) return fmt.Sprintf(` @@ -114,7 +126,7 @@ func testAccCheckIBMCdTektonPipelinePropertyConfigBasic(pipelineID string) strin `, rgName, tcName) } -func testAccCheckIBMCdTektonPipelinePropertyConfig(pipelineID string, name string, value string, typeVar string, path string) string { +func testAccCheckIBMCdTektonPipelinePropertyConfig(pipelineID string, name string, typeVar string, value string, path string) string { rgName := acc.CdResourceGroupName tcName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) return fmt.Sprintf(` diff --git a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_test.go b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_test.go index eb7385c0e7..e56f246234 100644 --- a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_test.go +++ b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_test.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. +// Copyright IBM Corp. 2023 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline_test diff --git a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_trigger.go b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_trigger.go index d2c7a5eb6d..2035bee7da 100644 --- a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_trigger.go +++ b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_trigger.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. +// Copyright IBM Corp. 2023 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline @@ -65,18 +65,6 @@ func ResourceIBMCdTektonPipelineTrigger() *schema.Resource { Description: "Worker used to run the trigger. If not specified the trigger will use the default pipeline worker.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "name": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Name of the worker. Computed based on the worker ID.", - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Type of the worker. Computed based on the worker ID.", - }, "id": &schema.Schema{ Type: schema.TypeString, Required: true, @@ -181,30 +169,6 @@ func ResourceIBMCdTektonPipelineTrigger() *schema.Resource { Optional: true, Description: "Git branch or tag pattern to listen to, specify one of branch or pattern only. When specifying a tag to listen to, you can also specify a simple glob pattern such as '!test' or '*master' to match against multiple tags/branches in the repository.", }, - "blind_connection": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "True if the repository server is not addressable on the public internet. IBM Cloud will not be able to validate the connection details you provide.", - }, - "hook_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "ID of the webhook from the repo. Computed upon creation of the trigger.", - }, - "tool": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Reference to the repository tool in the parent toolchain.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "ID of the repository tool instance in the parent toolchain.", - }, - }, - }, - }, }, }, }, @@ -240,6 +204,11 @@ func ResourceIBMCdTektonPipelineTrigger() *schema.Resource { DiffSuppressFunc: flex.SuppressTriggerPropertyRawSecret, Description: "Property value. Any string value is valid.", }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "API URL for interacting with the trigger property.", + }, "enum": &schema.Schema{ Type: schema.TypeList, Optional: true, @@ -256,11 +225,6 @@ func ResourceIBMCdTektonPipelineTrigger() *schema.Resource { Optional: true, Description: "A dot notation path for `integration` type properties only, that selects a value from the tool integration. If left blank the full tool integration data will be used.", }, - "href": &schema.Schema{ - Type: schema.TypeString, - Optional: true, - Description: "API URL for interacting with the trigger property.", - }, }, }, }, @@ -272,7 +236,7 @@ func ResourceIBMCdTektonPipelineTrigger() *schema.Resource { "trigger_id": &schema.Schema{ Type: schema.TypeString, Computed: true, - Description: "ID.", + Description: "The Trigger ID.", }, }, } @@ -294,14 +258,14 @@ func ResourceIBMCdTektonPipelineTriggerValidator() *validate.ResourceValidator { Identifier: "type", ValidateFunctionIdentifier: validate.ValidateAllowedStringValue, Type: validate.TypeString, - Optional: true, + Required: true, AllowedValues: "generic, manual, scm, timer", }, validate.ValidateSchema{ Identifier: "name", ValidateFunctionIdentifier: validate.ValidateRegexpLen, Type: validate.TypeString, - Optional: true, + Required: true, Regexp: `^[a-zA-Z0-9][-0-9a-zA-Z_. ]{1,253}[a-zA-Z0-9]$`, MinValueLength: 1, MaxValueLength: 253, @@ -310,7 +274,7 @@ func ResourceIBMCdTektonPipelineTriggerValidator() *validate.ResourceValidator { Identifier: "event_listener", ValidateFunctionIdentifier: validate.ValidateRegexpLen, Type: validate.TypeString, - Optional: true, + Required: true, Regexp: `^[-0-9a-zA-Z_.]{1,253}$`, MinValueLength: 1, MaxValueLength: 253, @@ -348,15 +312,9 @@ func resourceIBMCdTektonPipelineTriggerCreate(context context.Context, d *schema createTektonPipelineTriggerOptions := &cdtektonpipelinev2.CreateTektonPipelineTriggerOptions{} createTektonPipelineTriggerOptions.SetPipelineID(d.Get("pipeline_id").(string)) - if _, ok := d.GetOk("type"); ok { - createTektonPipelineTriggerOptions.SetType(d.Get("type").(string)) - } - if _, ok := d.GetOk("name"); ok { - createTektonPipelineTriggerOptions.SetName(d.Get("name").(string)) - } - if _, ok := d.GetOk("event_listener"); ok { - createTektonPipelineTriggerOptions.SetEventListener(d.Get("event_listener").(string)) - } + createTektonPipelineTriggerOptions.SetType(d.Get("type").(string)) + createTektonPipelineTriggerOptions.SetName(d.Get("name").(string)) + createTektonPipelineTriggerOptions.SetEventListener(d.Get("event_listener").(string)) if _, ok := d.GetOk("tags"); ok { tags := []string{} for _, tagsItem := range d.Get("tags").([]interface{}) { @@ -365,7 +323,7 @@ func resourceIBMCdTektonPipelineTriggerCreate(context context.Context, d *schema createTektonPipelineTriggerOptions.SetTags(tags) } if _, ok := d.GetOk("worker"); ok { - workerModel, err := resourceIBMCdTektonPipelineTriggerMapToWorker(d.Get("worker.0").(map[string]interface{})) + workerModel, err := resourceIBMCdTektonPipelineTriggerMapToWorkerIdentity(d.Get("worker.0").(map[string]interface{})) if err != nil { return diag.FromErr(err) } @@ -391,7 +349,7 @@ func resourceIBMCdTektonPipelineTriggerCreate(context context.Context, d *schema createTektonPipelineTriggerOptions.SetTimezone(d.Get("timezone").(string)) } if _, ok := d.GetOk("source"); ok { - sourceModel, err := resourceIBMCdTektonPipelineTriggerMapToTriggerSource(d.Get("source.0").(map[string]interface{})) + sourceModel, err := resourceIBMCdTektonPipelineTriggerMapToTriggerSourcePrototype(d.Get("source.0").(map[string]interface{})) if err != nil { return diag.FromErr(err) } @@ -463,7 +421,7 @@ func resourceIBMCdTektonPipelineTriggerRead(context context.Context, d *schema.R } } if trigger.Worker != nil { - workerMap, err := resourceIBMCdTektonPipelineTriggerWorkerToMap(trigger.Worker) + workerMap, err := resourceIBMCdTektonPipelineTriggerWorkerIdentityToMap(trigger.Worker) if err != nil { return diag.FromErr(err) } @@ -493,7 +451,7 @@ func resourceIBMCdTektonPipelineTriggerRead(context context.Context, d *schema.R return diag.FromErr(fmt.Errorf("Error setting timezone: %s", err)) } if trigger.Source != nil { - sourceMap, err := resourceIBMCdTektonPipelineTriggerTriggerSourceToMap(trigger.Source) + sourceMap, err := resourceIBMCdTektonPipelineTriggerTriggerSourcePrototypeToMap(trigger.Source) if err != nil { return diag.FromErr(err) } @@ -512,7 +470,7 @@ func resourceIBMCdTektonPipelineTriggerRead(context context.Context, d *schema.R properties := []map[string]interface{}{} if trigger.Properties != nil { for _, propertiesItem := range trigger.Properties { - propertiesItemMap, err := resourceIBMCdTektonPipelineTriggerTriggerPropertiesItemToMap(&propertiesItem) + propertiesItemMap, err := resourceIBMCdTektonPipelineTriggerTriggerPropertyToMap(&propertiesItem) if err != nil { return diag.FromErr(err) } @@ -555,17 +513,11 @@ func resourceIBMCdTektonPipelineTriggerUpdate(context context.Context, d *schema return diag.FromErr(fmt.Errorf("Cannot update resource property \"%s\" with the ForceNew annotation."+ " The resource must be re-created to update this property.", "pipeline_id")) } - if d.HasChange("type") { + if d.HasChange("type") || d.HasChange("name") || d.HasChange("event_listener") { newType := d.Get("type").(string) patchVals.Type = &newType - hasChange = true - } - if d.HasChange("name") { newName := d.Get("name").(string) patchVals.Name = &newName - hasChange = true - } - if d.HasChange("event_listener") { newEventListener := d.Get("event_listener").(string) patchVals.EventListener = &newEventListener hasChange = true @@ -579,7 +531,7 @@ func resourceIBMCdTektonPipelineTriggerUpdate(context context.Context, d *schema hasChange = true } if d.HasChange("worker") { - worker, err := resourceIBMCdTektonPipelineTriggerMapToWorker(d.Get("worker.0").(map[string]interface{})) + worker, err := resourceIBMCdTektonPipelineTriggerMapToWorkerIdentity(d.Get("worker.0").(map[string]interface{})) if err != nil { return diag.FromErr(err) } @@ -615,7 +567,7 @@ func resourceIBMCdTektonPipelineTriggerUpdate(context context.Context, d *schema hasChange = true } if d.HasChange("source") { - source, err := resourceIBMCdTektonPipelineTriggerMapToTriggerSource(d.Get("source.0").(map[string]interface{})) + source, err := resourceIBMCdTektonPipelineTriggerMapToTriggerSourcePrototype(d.Get("source.0").(map[string]interface{})) if err != nil { return diag.FromErr(err) } @@ -671,14 +623,8 @@ func resourceIBMCdTektonPipelineTriggerDelete(context context.Context, d *schema return nil } -func resourceIBMCdTektonPipelineTriggerMapToWorker(modelMap map[string]interface{}) (*cdtektonpipelinev2.Worker, error) { - model := &cdtektonpipelinev2.Worker{} - if modelMap["name"] != nil && modelMap["name"].(string) != "" { - model.Name = core.StringPtr(modelMap["name"].(string)) - } - if modelMap["type"] != nil && modelMap["type"].(string) != "" { - model.Type = core.StringPtr(modelMap["type"].(string)) - } +func resourceIBMCdTektonPipelineTriggerMapToWorkerIdentity(modelMap map[string]interface{}) (*cdtektonpipelinev2.WorkerIdentity, error) { + model := &cdtektonpipelinev2.WorkerIdentity{} model.ID = core.StringPtr(modelMap["id"].(string)) return model, nil } @@ -703,10 +649,10 @@ func resourceIBMCdTektonPipelineTriggerMapToGenericSecret(modelMap map[string]in return model, nil } -func resourceIBMCdTektonPipelineTriggerMapToTriggerSource(modelMap map[string]interface{}) (*cdtektonpipelinev2.TriggerSource, error) { - model := &cdtektonpipelinev2.TriggerSource{} +func resourceIBMCdTektonPipelineTriggerMapToTriggerSourcePrototype(modelMap map[string]interface{}) (*cdtektonpipelinev2.TriggerSourcePrototype, error) { + model := &cdtektonpipelinev2.TriggerSourcePrototype{} model.Type = core.StringPtr(modelMap["type"].(string)) - PropertiesModel, err := resourceIBMCdTektonPipelineTriggerMapToTriggerSourceProperties(modelMap["properties"].([]interface{})[0].(map[string]interface{})) + PropertiesModel, err := resourceIBMCdTektonPipelineTriggerMapToTriggerSourcePropertiesPrototype(modelMap["properties"].([]interface{})[0].(map[string]interface{})) if err != nil { return model, err } @@ -714,8 +660,8 @@ func resourceIBMCdTektonPipelineTriggerMapToTriggerSource(modelMap map[string]in return model, nil } -func resourceIBMCdTektonPipelineTriggerMapToTriggerSourceProperties(modelMap map[string]interface{}) (*cdtektonpipelinev2.TriggerSourceProperties, error) { - model := &cdtektonpipelinev2.TriggerSourceProperties{} +func resourceIBMCdTektonPipelineTriggerMapToTriggerSourcePropertiesPrototype(modelMap map[string]interface{}) (*cdtektonpipelinev2.TriggerSourcePropertiesPrototype, error) { + model := &cdtektonpipelinev2.TriggerSourcePropertiesPrototype{} model.URL = core.StringPtr(modelMap["url"].(string)) if modelMap["branch"] != nil && modelMap["branch"].(string) != "" { model.Branch = core.StringPtr(modelMap["branch"].(string)) @@ -726,14 +672,8 @@ func resourceIBMCdTektonPipelineTriggerMapToTriggerSourceProperties(modelMap map return model, nil } -func resourceIBMCdTektonPipelineTriggerWorkerToMap(model *cdtektonpipelinev2.Worker) (map[string]interface{}, error) { +func resourceIBMCdTektonPipelineTriggerWorkerIdentityToMap(model *cdtektonpipelinev2.Worker) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) - if model.Name != nil { - modelMap["name"] = model.Name - } - if model.Type != nil { - modelMap["type"] = model.Type - } modelMap["id"] = model.ID return modelMap, nil } @@ -758,10 +698,10 @@ func resourceIBMCdTektonPipelineTriggerGenericSecretToMap(model *cdtektonpipelin return modelMap, nil } -func resourceIBMCdTektonPipelineTriggerTriggerSourceToMap(model *cdtektonpipelinev2.TriggerSource) (map[string]interface{}, error) { +func resourceIBMCdTektonPipelineTriggerTriggerSourcePrototypeToMap(model *cdtektonpipelinev2.TriggerSource) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["type"] = model.Type - propertiesMap, err := resourceIBMCdTektonPipelineTriggerTriggerSourcePropertiesToMap(model.Properties) + propertiesMap, err := resourceIBMCdTektonPipelineTriggerTriggerSourcePropertiesPrototypeToMap(model.Properties) if err != nil { return modelMap, err } @@ -769,7 +709,7 @@ func resourceIBMCdTektonPipelineTriggerTriggerSourceToMap(model *cdtektonpipelin return modelMap, nil } -func resourceIBMCdTektonPipelineTriggerTriggerSourcePropertiesToMap(model *cdtektonpipelinev2.TriggerSourceProperties) (map[string]interface{}, error) { +func resourceIBMCdTektonPipelineTriggerTriggerSourcePropertiesPrototypeToMap(model *cdtektonpipelinev2.TriggerSourceProperties) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["url"] = model.URL if model.Branch != nil { @@ -778,36 +718,18 @@ func resourceIBMCdTektonPipelineTriggerTriggerSourcePropertiesToMap(model *cdtek if model.Pattern != nil { modelMap["pattern"] = model.Pattern } - if model.BlindConnection != nil { - modelMap["blind_connection"] = model.BlindConnection - } - if model.HookID != nil { - modelMap["hook_id"] = model.HookID - } - if model.Tool != nil { - toolMap, err := resourceIBMCdTektonPipelineTriggerTriggerSourcePropertiesToolToMap(model.Tool) - if err != nil { - return modelMap, err - } - modelMap["tool"] = []map[string]interface{}{toolMap} - } return modelMap, nil } -func resourceIBMCdTektonPipelineTriggerTriggerSourcePropertiesToolToMap(model *cdtektonpipelinev2.TriggerSourcePropertiesTool) (map[string]interface{}, error) { - modelMap := make(map[string]interface{}) - if model.ID != nil { - modelMap["id"] = model.ID - } - return modelMap, nil -} - -func resourceIBMCdTektonPipelineTriggerTriggerPropertiesItemToMap(model *cdtektonpipelinev2.TriggerPropertiesItem) (map[string]interface{}, error) { +func resourceIBMCdTektonPipelineTriggerTriggerPropertyToMap(model *cdtektonpipelinev2.TriggerProperty) (map[string]interface{}, error) { modelMap := make(map[string]interface{}) modelMap["name"] = model.Name if model.Value != nil { modelMap["value"] = model.Value } + if model.Href != nil { + modelMap["href"] = model.Href + } if model.Enum != nil { modelMap["enum"] = model.Enum } @@ -815,8 +737,5 @@ func resourceIBMCdTektonPipelineTriggerTriggerPropertiesItemToMap(model *cdtekto if model.Path != nil { modelMap["path"] = model.Path } - if model.Href != nil { - modelMap["href"] = model.Href - } return modelMap, nil } diff --git a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_trigger_property.go b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_trigger_property.go index 6c7c51caf4..235400d669 100644 --- a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_trigger_property.go +++ b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_trigger_property.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. +// Copyright IBM Corp. 2023 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline @@ -47,6 +47,12 @@ func ResourceIBMCdTektonPipelineTriggerProperty() *schema.Resource { ValidateFunc: validate.InvokeValidator("ibm_cd_tekton_pipeline_trigger_property", "name"), Description: "Property name.", }, + "type": &schema.Schema{ + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.InvokeValidator("ibm_cd_tekton_pipeline_trigger_property", "type"), + Description: "Property type.", + }, "value": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -60,18 +66,17 @@ func ResourceIBMCdTektonPipelineTriggerProperty() *schema.Resource { Description: "Options for `single_select` property type. Only needed for `single_select` property type.", Elem: &schema.Schema{Type: schema.TypeString}, }, - "type": &schema.Schema{ - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_cd_tekton_pipeline_trigger_property", "type"), - Description: "Property type.", - }, "path": &schema.Schema{ Type: schema.TypeString, Optional: true, ValidateFunc: validate.InvokeValidator("ibm_cd_tekton_pipeline_trigger_property", "path"), Description: "A dot notation path for `integration` type properties only, to select a value from the tool integration. If left blank the full tool integration data will be used.", }, + "href": &schema.Schema{ + Type: schema.TypeString, + Computed: true, + Description: "API URL for interacting with the trigger property.", + }, }, } } @@ -106,6 +111,13 @@ func ResourceIBMCdTektonPipelineTriggerPropertyValidator() *validate.ResourceVal MinValueLength: 1, MaxValueLength: 253, }, + validate.ValidateSchema{ + Identifier: "type", + ValidateFunctionIdentifier: validate.ValidateAllowedStringValue, + Type: validate.TypeString, + Required: true, + AllowedValues: "appconfig, integration, secure, single_select, text", + }, validate.ValidateSchema{ Identifier: "value", ValidateFunctionIdentifier: validate.ValidateRegexpLen, @@ -115,13 +127,6 @@ func ResourceIBMCdTektonPipelineTriggerPropertyValidator() *validate.ResourceVal MinValueLength: 0, MaxValueLength: 4096, }, - validate.ValidateSchema{ - Identifier: "type", - ValidateFunctionIdentifier: validate.ValidateAllowedStringValue, - Type: validate.TypeString, - Required: true, - AllowedValues: "appconfig, integration, secure, single_select, text", - }, validate.ValidateSchema{ Identifier: "path", ValidateFunctionIdentifier: validate.ValidateRegexpLen, @@ -147,9 +152,8 @@ func resourceIBMCdTektonPipelineTriggerPropertyCreate(context context.Context, d createTektonPipelineTriggerPropertiesOptions.SetPipelineID(d.Get("pipeline_id").(string)) createTektonPipelineTriggerPropertiesOptions.SetTriggerID(d.Get("trigger_id").(string)) - if _, ok := d.GetOk("name"); ok { - createTektonPipelineTriggerPropertiesOptions.SetName(d.Get("name").(string)) - } + createTektonPipelineTriggerPropertiesOptions.SetName(d.Get("name").(string)) + createTektonPipelineTriggerPropertiesOptions.SetType(d.Get("type").(string)) if _, ok := d.GetOk("value"); ok { createTektonPipelineTriggerPropertiesOptions.SetValue(d.Get("value").(string)) } @@ -161,9 +165,6 @@ func resourceIBMCdTektonPipelineTriggerPropertyCreate(context context.Context, d } createTektonPipelineTriggerPropertiesOptions.SetEnum(enum) } - if _, ok := d.GetOk("type"); ok { - createTektonPipelineTriggerPropertiesOptions.SetType(d.Get("type").(string)) - } if _, ok := d.GetOk("path"); ok { createTektonPipelineTriggerPropertiesOptions.SetPath(d.Get("path").(string)) } @@ -215,6 +216,9 @@ func resourceIBMCdTektonPipelineTriggerPropertyRead(context context.Context, d * if err = d.Set("name", triggerProperty.Name); err != nil { return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) } + if err = d.Set("type", triggerProperty.Type); err != nil { + return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) + } if err = d.Set("value", triggerProperty.Value); err != nil { return diag.FromErr(fmt.Errorf("Error setting value: %s", err)) } @@ -223,12 +227,12 @@ func resourceIBMCdTektonPipelineTriggerPropertyRead(context context.Context, d * return diag.FromErr(fmt.Errorf("Error setting enum: %s", err)) } } - if err = d.Set("type", triggerProperty.Type); err != nil { - return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) - } if err = d.Set("path", triggerProperty.Path); err != nil { return diag.FromErr(fmt.Errorf("Error setting path: %s", err)) } + if err = d.Set("href", triggerProperty.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + } return nil } @@ -266,6 +270,10 @@ func resourceIBMCdTektonPipelineTriggerPropertyUpdate(context context.Context, d return diag.FromErr(fmt.Errorf("Cannot update resource property \"%s\" with the ForceNew annotation."+ " The resource must be re-created to update this property.", "name")) } + if d.HasChange("type") { + replaceTektonPipelineTriggerPropertyOptions.SetType(d.Get("type").(string)) + hasChange = true + } if d.Get("type").(string) == "integration" { if d.HasChange("value") || d.HasChange("path") { diff --git a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_trigger_property_test.go b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_trigger_property_test.go index fefb73dd26..f0a0bcaf93 100644 --- a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_trigger_property_test.go +++ b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_trigger_property_test.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. +// Copyright IBM Corp. 2023 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline_test @@ -19,6 +19,9 @@ import ( func TestAccIBMCdTektonPipelineTriggerPropertyBasic(t *testing.T) { var conf cdtektonpipelinev2.TriggerProperty + name := "trig-prop-1" + typeVar := "text" + typeVarUpdate := "text" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -26,9 +29,18 @@ func TestAccIBMCdTektonPipelineTriggerPropertyBasic(t *testing.T) { CheckDestroy: testAccCheckIBMCdTektonPipelineTriggerPropertyDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIBMCdTektonPipelineTriggerPropertyConfigBasic("", ""), + Config: testAccCheckIBMCdTektonPipelineTriggerPropertyConfigBasic("", "", name, typeVar), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckIBMCdTektonPipelineTriggerPropertyExists("ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", conf), + resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "name", name), + resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "type", typeVar), + ), + }, + resource.TestStep{ + Config: testAccCheckIBMCdTektonPipelineTriggerPropertyConfigBasic("", "", name, typeVarUpdate), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "name", name), + resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "type", typeVarUpdate), ), }, }, @@ -38,11 +50,11 @@ func TestAccIBMCdTektonPipelineTriggerPropertyBasic(t *testing.T) { func TestAccIBMCdTektonPipelineTriggerPropertyAllArgs(t *testing.T) { var conf cdtektonpipelinev2.TriggerProperty name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - value := fmt.Sprintf("tf_value_%d", acctest.RandIntRange(10, 100)) typeVar := "text" + value := fmt.Sprintf("tf_value_%d", acctest.RandIntRange(10, 100)) path := fmt.Sprintf("tf_path_%d", acctest.RandIntRange(10, 100)) - valueUpdate := fmt.Sprintf("tf_value_%d", acctest.RandIntRange(10, 100)) typeVarUpdate := "text" + valueUpdate := fmt.Sprintf("tf_value_%d", acctest.RandIntRange(10, 100)) pathUpdate := fmt.Sprintf("tf_path_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ @@ -51,20 +63,20 @@ func TestAccIBMCdTektonPipelineTriggerPropertyAllArgs(t *testing.T) { CheckDestroy: testAccCheckIBMCdTektonPipelineTriggerPropertyDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIBMCdTektonPipelineTriggerPropertyConfig("", "", name, value, typeVar, path), + Config: testAccCheckIBMCdTektonPipelineTriggerPropertyConfig("", "", name, typeVar, value, path), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckIBMCdTektonPipelineTriggerPropertyExists("ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", conf), resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "name", name), - resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "value", value), resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "type", typeVar), + resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "value", value), ), }, resource.TestStep{ - Config: testAccCheckIBMCdTektonPipelineTriggerPropertyConfig("", "", name, valueUpdate, typeVarUpdate, pathUpdate), + Config: testAccCheckIBMCdTektonPipelineTriggerPropertyConfig("", "", name, typeVarUpdate, valueUpdate, pathUpdate), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "name", name), - resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "value", valueUpdate), resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "type", typeVarUpdate), + resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "value", valueUpdate), ), }, resource.TestStep{ @@ -76,7 +88,7 @@ func TestAccIBMCdTektonPipelineTriggerPropertyAllArgs(t *testing.T) { }) } -func testAccCheckIBMCdTektonPipelineTriggerPropertyConfigBasic(pipelineID string, triggerID string) string { +func testAccCheckIBMCdTektonPipelineTriggerPropertyConfigBasic(pipelineID string, triggerID string, name string, typeVar string) string { rgName := acc.CdResourceGroupName tcName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) return fmt.Sprintf(` @@ -127,12 +139,12 @@ func testAccCheckIBMCdTektonPipelineTriggerPropertyConfigBasic(pipelineID string } resource "ibm_cd_tekton_pipeline_trigger" "cd_tekton_pipeline_trigger" { pipeline_id = ibm_cd_toolchain_tool_pipeline.ibm_cd_toolchain_tool_pipeline.tool_id - type = "manual" - event_listener = "listener" depends_on = [ ibm_cd_tekton_pipeline_definition.cd_tekton_pipeline_definition ] name = "trigger" + type = "manual" + event_listener = "listener" } resource "ibm_cd_tekton_pipeline_trigger_property" "cd_tekton_pipeline_trigger_property" { pipeline_id = ibm_cd_tekton_pipeline.cd_tekton_pipeline.pipeline_id @@ -144,7 +156,7 @@ func testAccCheckIBMCdTektonPipelineTriggerPropertyConfigBasic(pipelineID string `, rgName, tcName) } -func testAccCheckIBMCdTektonPipelineTriggerPropertyConfig(pipelineID string, triggerID string, name string, value string, typeVar string, path string) string { +func testAccCheckIBMCdTektonPipelineTriggerPropertyConfig(pipelineID string, triggerID string, name string, typeVar string, value string, path string) string { rgName := acc.CdResourceGroupName tcName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) return fmt.Sprintf(` @@ -195,21 +207,21 @@ func testAccCheckIBMCdTektonPipelineTriggerPropertyConfig(pipelineID string, tri } resource "ibm_cd_tekton_pipeline_trigger" "cd_tekton_pipeline_trigger" { pipeline_id = ibm_cd_toolchain_tool_pipeline.ibm_cd_toolchain_tool_pipeline.tool_id - type = "manual" - event_listener = "listener" depends_on = [ ibm_cd_tekton_pipeline_definition.cd_tekton_pipeline_definition ] name = "trigger" + type = "manual" + event_listener = "listener" } resource "ibm_cd_tekton_pipeline_trigger_property" "cd_tekton_pipeline_trigger_property" { pipeline_id = ibm_cd_tekton_pipeline.cd_tekton_pipeline.pipeline_id trigger_id = ibm_cd_tekton_pipeline_trigger.cd_tekton_pipeline_trigger.trigger_id name = "%s" - value = "%s" type = "%s" + value = "%s" } - `, rgName, tcName, name, value, typeVar) + `, rgName, tcName, name, typeVar, value) } func testAccCheckIBMCdTektonPipelineTriggerPropertyExists(n string, obj cdtektonpipelinev2.TriggerProperty) resource.TestCheckFunc { diff --git a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_trigger_test.go b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_trigger_test.go index 6f12d30264..1ca578350a 100644 --- a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_trigger_test.go +++ b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline_trigger_test.go @@ -1,4 +1,4 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. +// Copyright IBM Corp. 2023 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline_test @@ -20,6 +20,12 @@ import ( func TestAccIBMCdTektonPipelineTriggerBasic(t *testing.T) { var conf cdtektonpipelinev2.Trigger + typeVar := "manual" + name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + eventListener := "listener" + typeVarUpdate := "manual" + nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) + eventListenerUpdate := fmt.Sprintf("tf_event_listener_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -27,15 +33,22 @@ func TestAccIBMCdTektonPipelineTriggerBasic(t *testing.T) { CheckDestroy: testAccCheckIBMCdTektonPipelineTriggerDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIBMCdTektonPipelineTriggerConfigBasic(""), + Config: testAccCheckIBMCdTektonPipelineTriggerConfigBasic("", typeVar, name, eventListener), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckIBMCdTektonPipelineTriggerExists("ibm_cd_tekton_pipeline_trigger.cd_tekton_pipeline_trigger", conf), resource.TestCheckResourceAttrSet("ibm_cd_tekton_pipeline_trigger.cd_tekton_pipeline_trigger", "id"), resource.TestCheckResourceAttrSet("ibm_cd_tekton_pipeline_trigger.cd_tekton_pipeline_trigger", "pipeline_id"), resource.TestCheckResourceAttrSet("ibm_cd_tekton_pipeline_trigger.cd_tekton_pipeline_trigger", "trigger_id"), - resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger.cd_tekton_pipeline_trigger", "type", "manual"), - resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger.cd_tekton_pipeline_trigger", "name", "trigger"), - resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger.cd_tekton_pipeline_trigger", "event_listener", "listener"), + resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger.cd_tekton_pipeline_trigger", "type", typeVar), + resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger.cd_tekton_pipeline_trigger", "name", name), + resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger.cd_tekton_pipeline_trigger", "event_listener", eventListener), + ), + }, + resource.TestStep{ + Config: testAccCheckIBMCdTektonPipelineTriggerConfigBasic("", typeVarUpdate, nameUpdate, eventListenerUpdate), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger.cd_tekton_pipeline_trigger", "name", nameUpdate), + resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger.cd_tekton_pipeline_trigger", "event_listener", eventListenerUpdate), ), }, }, @@ -121,7 +134,7 @@ func TestAccIBMCdTektonPipelineTriggerAllArgs(t *testing.T) { }) } -func testAccCheckIBMCdTektonPipelineTriggerConfigBasic(pipelineID string) string { +func testAccCheckIBMCdTektonPipelineTriggerConfigBasic(pipelineID string, typeVar string, name string, eventListener string) string { rgName := acc.CdResourceGroupName tcName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) return fmt.Sprintf(` @@ -172,14 +185,14 @@ func testAccCheckIBMCdTektonPipelineTriggerConfigBasic(pipelineID string) string } resource "ibm_cd_tekton_pipeline_trigger" "cd_tekton_pipeline_trigger" { pipeline_id = ibm_cd_toolchain_tool_pipeline.ibm_cd_toolchain_tool_pipeline.tool_id - type = "manual" - event_listener = "listener" depends_on = [ ibm_cd_tekton_pipeline_definition.cd_tekton_pipeline_definition ] - name = "trigger" + type = "%s" + name = "%s" + event_listener = "%s" } - `, rgName, tcName) + `, rgName, tcName, typeVar, name, eventListener) } func testAccCheckIBMCdTektonPipelineTriggerConfig(pipelineID string, typeVar string, name string, eventListener string, maxConcurrentRuns string, enabled string, cron string, timezone string) string { @@ -233,11 +246,11 @@ func testAccCheckIBMCdTektonPipelineTriggerConfig(pipelineID string, typeVar str } resource "ibm_cd_tekton_pipeline_trigger" "cd_tekton_pipeline_trigger" { pipeline_id = ibm_cd_toolchain_tool_pipeline.ibm_cd_toolchain_tool_pipeline.tool_id - type = "manual" - event_listener = "listener" depends_on = [ ibm_cd_tekton_pipeline_definition.cd_tekton_pipeline_definition ] + type = "manual" + event_listener = "listener" name = "%s" tags = [ "tag1", "tag2" ] max_concurrent_runs = %s diff --git a/website/docs/d/cd_tekton_pipeline.html.markdown b/website/docs/d/cd_tekton_pipeline.html.markdown index f1f6aba061..4efdcaa494 100644 --- a/website/docs/d/cd_tekton_pipeline.html.markdown +++ b/website/docs/d/cd_tekton_pipeline.html.markdown @@ -38,7 +38,9 @@ In addition to all argument references listed, you can access the following attr * `definitions` - (List) Definition list. * Constraints: The maximum length is `128` items. The minimum length is `0` items. Nested scheme for **definitions**: - * `id` - (String) UUID. + * `href` - (String) API URL for interacting with the definition. + * Constraints: The maximum length is `2048` characters. The minimum length is `10` characters. The value must match regular expression `/^http(s)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. + * `id` - (String) The aggregated definition ID. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[-0-9a-z]+$/`. * `source` - (List) Source repository containing the Tekton pipeline definition. Nested scheme for **source**: @@ -50,7 +52,7 @@ Nested scheme for **definitions**: * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. * `tag` - (String) A tag from the repo, specify one of branch or tag only. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_]{1,253}$/`. - * `tool` - (List) Reference to the repository tool, in the parent toolchain, that contains the pipeline definition. + * `tool` - (List) Reference to the repository tool in the parent toolchain. Nested scheme for **tool**: * `id` - (String) ID of the repository tool instance in the parent toolchain. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[-0-9a-z]+$/`. @@ -66,6 +68,9 @@ Nested scheme for **definitions**: * `enabled` - (Boolean) Flag whether this pipeline is enabled. * Constraints: The default value is `true`. +* `href` - (String) API URL for interacting with the pipeline. + * Constraints: The maximum length is `2048` characters. The minimum length is `10` characters. The value must match regular expression `/^http(s)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. + * `name` - (String) String. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][-0-9a-zA-Z_. ]{1,253}[a-zA-Z0-9]$/`. @@ -74,6 +79,8 @@ Nested scheme for **definitions**: Nested scheme for **properties**: * `enum` - (List) Options for `single_select` property type. Only needed when using `single_select` property type. * Constraints: The list items must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. The maximum length is `256` items. The minimum length is `0` items. + * `href` - (String) API URL for interacting with the property. + * Constraints: The maximum length is `2048` characters. The minimum length is `10` characters. The value must match regular expression `/^http(s)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. * `name` - (Forces new resource, String) Property name. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. * `path` - (String) A dot notation path for `integration` type properties only, that selects a value from the tool integration. If left blank the full tool integration data will be used. @@ -83,7 +90,7 @@ Nested scheme for **properties**: * `value` - (String) Property value. Any string value is valid. * Constraints: The maximum length is `4096` characters. The minimum length is `0` characters. The value must match regular expression `/^.*$/`. -* `resource_group` - (List) The ID of the resource group in which the pipeline was created. +* `resource_group` - (List) The resource group in which the pipeline was created. Nested scheme for **resource_group**: * `id` - (String) ID. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_]+$/`. @@ -111,10 +118,10 @@ Nested scheme for **triggers**: * `event_listener` - (String) Event listener name. The name of the event listener to which the trigger is associated. The event listeners are defined in the definition repositories of the Tekton pipeline. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. * `events` - (List) Only needed for Git triggers. List of events to which a Git trigger listens. Choose one or more from: 'push', 'pull_request' and 'pull_request_closed'. For SCM repositories that use 'merge request' events, such events map to the equivalent 'pull request' events. - * Constraints: Allowable list items are: `push`, `pull_request`, `pull_request_closed`. The list items must match regular expression `/^[-0-9a-zA-Z_,]+$/`. The maximum length is `3` items. The minimum length is `0` items. + * Constraints: Allowable list items are: `push`, `pull_request`, `pull_request_closed`. The maximum length is `3` items. The minimum length is `0` items. * `href` - (String) API URL for interacting with the trigger. Only included when fetching the list of pipeline triggers. * Constraints: The maximum length is `2048` characters. The minimum length is `10` characters. The value must match regular expression `/^http(s)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. - * `id` - (String) ID. + * `id` - (String) The Trigger ID. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[-0-9a-z]+$/`. * `max_concurrent_runs` - (Integer) Defines the maximum number of concurrent runs for this trigger. If omitted then the concurrency limit is disabled for this trigger. * `name` - (String) Trigger name. @@ -175,7 +182,7 @@ Nested scheme for **triggers**: * Constraints: The maximum length is `2048` characters. The minimum length is `10` characters. The value must match regular expression `/^http(s)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. * `worker` - (List) Worker used to run the trigger. If not specified the trigger will use the default pipeline worker. Nested scheme for **worker**: - * `id` - (Forces new resource, String) ID of the worker. + * `id` - (String) ID of the worker. * Constraints: The maximum length is `36` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z]{1,36}$/`. * `name` - (String) Name of the worker. Computed based on the worker ID. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_. \\(\\)\\[\\]]{1,253}$/`. @@ -186,7 +193,7 @@ Nested scheme for **triggers**: * `worker` - (List) Default pipeline worker used to run the pipeline. Nested scheme for **worker**: - * `id` - (Forces new resource, String) ID of the worker. + * `id` - (String) ID of the worker. * Constraints: The maximum length is `36` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z]{1,36}$/`. * `name` - (String) Name of the worker. Computed based on the worker ID. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_. \\(\\)\\[\\]]{1,253}$/`. diff --git a/website/docs/d/cd_tekton_pipeline_definition.html.markdown b/website/docs/d/cd_tekton_pipeline_definition.html.markdown index a2fa815540..50e4ca46d4 100644 --- a/website/docs/d/cd_tekton_pipeline_definition.html.markdown +++ b/website/docs/d/cd_tekton_pipeline_definition.html.markdown @@ -33,6 +33,9 @@ Review the argument reference that you can specify for your data source. In addition to all argument references listed, you can access the following attribute references after your data source is created. * `id` - The unique identifier of the cd_tekton_pipeline_definition. +* `href` - (String) API URL for interacting with the definition. + * Constraints: The maximum length is `2048` characters. The minimum length is `10` characters. The value must match regular expression `/^http(s)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. + * `source` - (List) Source repository containing the Tekton pipeline definition. Nested scheme for **source**: * `properties` - (List) Properties of the source, which define the URL of the repository and a branch or tag. @@ -43,7 +46,7 @@ Nested scheme for **source**: * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. * `tag` - (String) A tag from the repo, specify one of branch or tag only. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_]{1,253}$/`. - * `tool` - (List) Reference to the repository tool, in the parent toolchain, that contains the pipeline definition. + * `tool` - (List) Reference to the repository tool in the parent toolchain. Nested scheme for **tool**: * `id` - (String) ID of the repository tool instance in the parent toolchain. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[-0-9a-z]+$/`. diff --git a/website/docs/d/cd_tekton_pipeline_property.html.markdown b/website/docs/d/cd_tekton_pipeline_property.html.markdown index 6b4dcd9712..f9842269f5 100644 --- a/website/docs/d/cd_tekton_pipeline_property.html.markdown +++ b/website/docs/d/cd_tekton_pipeline_property.html.markdown @@ -36,6 +36,9 @@ In addition to all argument references listed, you can access the following attr * `enum` - (List) Options for `single_select` property type. Only needed when using `single_select` property type. * Constraints: The list items must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. The maximum length is `256` items. The minimum length is `0` items. +* `href` - (String) API URL for interacting with the property. + * Constraints: The maximum length is `2048` characters. The minimum length is `10` characters. The value must match regular expression `/^http(s)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. + * `name` - (Forces new resource, String) Property name. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. diff --git a/website/docs/d/cd_tekton_pipeline_trigger.html.markdown b/website/docs/d/cd_tekton_pipeline_trigger.html.markdown index 6f1edbdeb9..31f22ac915 100644 --- a/website/docs/d/cd_tekton_pipeline_trigger.html.markdown +++ b/website/docs/d/cd_tekton_pipeline_trigger.html.markdown @@ -43,7 +43,7 @@ In addition to all argument references listed, you can access the following attr * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. * `events` - (List) Only needed for Git triggers. List of events to which a Git trigger listens. Choose one or more from: 'push', 'pull_request' and 'pull_request_closed'. For SCM repositories that use 'merge request' events, such events map to the equivalent 'pull request' events. - * Constraints: Allowable list items are: `push`, `pull_request`, `pull_request_closed`. The list items must match regular expression `/^[-0-9a-zA-Z_,]+$/`. The maximum length is `3` items. The minimum length is `0` items. + * Constraints: Allowable list items are: `push`, `pull_request`, `pull_request_closed`. The maximum length is `3` items. The minimum length is `0` items. * `href` - (String) API URL for interacting with the trigger. Only included when fetching the list of pipeline triggers. * Constraints: The maximum length is `2048` characters. The minimum length is `10` characters. The value must match regular expression `/^http(s)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. @@ -116,7 +116,7 @@ Nested scheme for **source**: * `worker` - (List) Worker used to run the trigger. If not specified the trigger will use the default pipeline worker. Nested scheme for **worker**: - * `id` - (Forces new resource, String) ID of the worker. + * `id` - (String) ID of the worker. * Constraints: The maximum length is `36` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z]{1,36}$/`. * `name` - (String) Name of the worker. Computed based on the worker ID. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_. \\(\\)\\[\\]]{1,253}$/`. diff --git a/website/docs/d/cd_tekton_pipeline_trigger_property.html.markdown b/website/docs/d/cd_tekton_pipeline_trigger_property.html.markdown index d2660b214f..53e8b87ed7 100644 --- a/website/docs/d/cd_tekton_pipeline_trigger_property.html.markdown +++ b/website/docs/d/cd_tekton_pipeline_trigger_property.html.markdown @@ -39,6 +39,9 @@ In addition to all argument references listed, you can access the following attr * `enum` - (List) Options for `single_select` property type. Only needed for `single_select` property type. * Constraints: The list items must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. The maximum length is `256` items. The minimum length is `0` items. +* `href` - (String) API URL for interacting with the trigger property. + * Constraints: The maximum length is `2048` characters. The minimum length is `10` characters. The value must match regular expression `/^http(s)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. + * `name` - (Forces new resource, String) Property name. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. diff --git a/website/docs/r/cd_tekton_pipeline.html.markdown b/website/docs/r/cd_tekton_pipeline.html.markdown index 083352530b..a0a3da3b41 100644 --- a/website/docs/r/cd_tekton_pipeline.html.markdown +++ b/website/docs/r/cd_tekton_pipeline.html.markdown @@ -13,7 +13,7 @@ Provides a resource for cd_tekton_pipeline. This allows cd_tekton_pipeline to be ## Example Usage ```hcl -resource "ibm_cd_tekton_pipeline" "cd_tekton_pipeline" { +resource "ibm_cd_tekton_pipeline" "cd_tekton_pipeline_instance" { pipeline_id = "94619026-912b-4d92-8f51-6c74f0692d90" worker { id = "public" @@ -33,7 +33,7 @@ Review the argument reference that you can specify for your resource. * Constraints: The default value is `false`. * `worker` - (Optional, List) Worker object containing worker ID only. If omitted the IBM Managed shared workers are used by default. Nested scheme for **worker**: - * `id` - (Required, String) ID of the worker. + * `id` - (Required, Forces new resource, String) ID of the worker. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z]{1,253}$/`. ## Attribute Reference @@ -47,7 +47,9 @@ In addition to all argument references listed, you can access the following attr * `definitions` - (List) Definition list. * Constraints: The maximum length is `128` items. The minimum length is `0` items. Nested scheme for **definitions**: - * `id` - (String) UUID. + * `href` - (String) API URL for interacting with the definition. + * Constraints: The maximum length is `2048` characters. The minimum length is `10` characters. The value must match regular expression `/^http(s)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. + * `id` - (String) The aggregated definition ID. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[-0-9a-z]+$/`. * `source` - (List) Source repository containing the Tekton pipeline definition. Nested scheme for **source**: @@ -59,7 +61,7 @@ Nested scheme for **definitions**: * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. * `tag` - (String) A tag from the repo, specify one of branch or tag only. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_]{1,253}$/`. - * `tool` - (List) Reference to the repository tool, in the parent toolchain, that contains the pipeline definition. + * `tool` - (List) Reference to the repository tool in the parent toolchain. Nested scheme for **tool**: * `id` - (String) ID of the repository tool instance in the parent toolchain. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[-0-9a-z]+$/`. @@ -69,6 +71,8 @@ Nested scheme for **definitions**: * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^git$/`. * `enabled` - (Boolean) Flag whether this pipeline is enabled. * Constraints: The default value is `true`. +* `href` - (String) API URL for interacting with the pipeline. + * Constraints: The maximum length is `2048` characters. The minimum length is `10` characters. The value must match regular expression `/^http(s)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. * `name` - (String) String. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][-0-9a-zA-Z_. ]{1,253}[a-zA-Z0-9]$/`. * `properties` - (List) Tekton pipeline's environment properties. @@ -76,6 +80,8 @@ Nested scheme for **definitions**: Nested scheme for **properties**: * `enum` - (List) Options for `single_select` property type. Only needed when using `single_select` property type. * Constraints: The list items must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. The maximum length is `256` items. The minimum length is `0` items. + * `href` - (String) API URL for interacting with the property. + * Constraints: The maximum length is `2048` characters. The minimum length is `10` characters. The value must match regular expression `/^http(s)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. * `name` - (Forces new resource, String) Property name. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. * `path` - (String) A dot notation path for `integration` type properties only, that selects a value from the tool integration. If left blank the full tool integration data will be used. @@ -84,7 +90,7 @@ Nested scheme for **properties**: * Constraints: Allowable values are: `secure`, `text`, `integration`, `single_select`, `appconfig`. * `value` - (String) Property value. Any string value is valid. * Constraints: The maximum length is `4096` characters. The minimum length is `0` characters. The value must match regular expression `/^.*$/`. -* `resource_group` - (List) The ID of the resource group in which the pipeline was created. +* `resource_group` - (List) The resource group in which the pipeline was created. Nested scheme for **resource_group**: * `id` - (String) ID. * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_]+$/`. @@ -108,10 +114,10 @@ Nested scheme for **triggers**: * `event_listener` - (String) Event listener name. The name of the event listener to which the trigger is associated. The event listeners are defined in the definition repositories of the Tekton pipeline. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. * `events` - (List) Only needed for Git triggers. List of events to which a Git trigger listens. Choose one or more from: 'push', 'pull_request' and 'pull_request_closed'. For SCM repositories that use 'merge request' events, such events map to the equivalent 'pull request' events. - * Constraints: Allowable list items are: `push`, `pull_request`, `pull_request_closed`. The list items must match regular expression `/^[-0-9a-zA-Z_,]+$/`. The maximum length is `3` items. The minimum length is `0` items. + * Constraints: Allowable list items are: `push`, `pull_request`, `pull_request_closed`. The maximum length is `3` items. The minimum length is `0` items. * `href` - (String) API URL for interacting with the trigger. Only included when fetching the list of pipeline triggers. * Constraints: The maximum length is `2048` characters. The minimum length is `10` characters. The value must match regular expression `/^http(s)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. - * `id` - (String) ID. + * `id` - (String) The Trigger ID. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[-0-9a-z]+$/`. * `max_concurrent_runs` - (Integer) Defines the maximum number of concurrent runs for this trigger. If omitted then the concurrency limit is disabled for this trigger. * `name` - (String) Trigger name. @@ -172,7 +178,7 @@ Nested scheme for **triggers**: * Constraints: The maximum length is `2048` characters. The minimum length is `10` characters. The value must match regular expression `/^http(s)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. * `worker` - (List) Worker used to run the trigger. If not specified the trigger will use the default pipeline worker. Nested scheme for **worker**: - * `id` - (Forces new resource, String) ID of the worker. + * `id` - (String) ID of the worker. * Constraints: The maximum length is `36` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z]{1,36}$/`. * `name` - (String) Name of the worker. Computed based on the worker ID. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_. \\(\\)\\[\\]]{1,253}$/`. diff --git a/website/docs/r/cd_tekton_pipeline_definition.html.markdown b/website/docs/r/cd_tekton_pipeline_definition.html.markdown index b81fe8413b..7f916fae4a 100644 --- a/website/docs/r/cd_tekton_pipeline_definition.html.markdown +++ b/website/docs/r/cd_tekton_pipeline_definition.html.markdown @@ -13,7 +13,7 @@ Provides a resource for cd_tekton_pipeline_definition. This allows cd_tekton_pip ## Example Usage ```hcl -resource "ibm_cd_tekton_pipeline_definition" "cd_tekton_pipeline_definition" { +resource "ibm_cd_tekton_pipeline_definition" "cd_tekton_pipeline_definition_instance" { pipeline_id = "94619026-912b-4d92-8f51-6c74f0692d90" source { type = "git" @@ -36,7 +36,7 @@ Review the argument reference that you can specify for your resource. * `pipeline_id` - (Required, Forces new resource, String) The Tekton pipeline ID. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[-0-9a-z]+$/`. -* `source` - (Optional, List) Source repository containing the Tekton pipeline definition. +* `source` - (Required, List) Source repository containing the Tekton pipeline definition. Nested scheme for **source**: * `properties` - (Required, List) Properties of the source, which define the URL of the repository and a branch or tag. Nested scheme for **properties**: @@ -46,9 +46,9 @@ Nested scheme for **source**: * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. * `tag` - (Optional, String) A tag from the repo, specify one of branch or tag only. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_]{1,253}$/`. - * `tool` - (Optional, List) Reference to the repository tool, in the parent toolchain, that contains the pipeline definition. + * `tool` - (Optional, List) Reference to the repository tool in the parent toolchain. Nested scheme for **tool**: - * `id` - (Optional, String) ID of the repository tool instance in the parent toolchain. + * `id` - (Computed, String) ID of the repository tool instance in the parent toolchain. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[-0-9a-z]+$/`. * `url` - (Required, Forces new resource, String) URL of the definition repository. * Constraints: The maximum length is `2048` characters. The minimum length is `10` characters. The value must match regular expression `/^http(s)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. @@ -60,8 +60,10 @@ Nested scheme for **source**: In addition to all argument references listed, you can access the following attribute references after your resource is created. * `id` - The unique identifier of the cd_tekton_pipeline_definition. -* `definition_id` - (String) UUID. +* `definition_id` - (String) The aggregated definition ID. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[-0-9a-z]+$/`. +* `href` - (String) API URL for interacting with the definition. + * Constraints: The maximum length is `2048` characters. The minimum length is `10` characters. The value must match regular expression `/^http(s)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. ## Provider Configuration diff --git a/website/docs/r/cd_tekton_pipeline_property.html.markdown b/website/docs/r/cd_tekton_pipeline_property.html.markdown index 83cee48307..66b730ae22 100644 --- a/website/docs/r/cd_tekton_pipeline_property.html.markdown +++ b/website/docs/r/cd_tekton_pipeline_property.html.markdown @@ -13,7 +13,7 @@ Provides a resource for cd_tekton_pipeline_property. This allows cd_tekton_pipel ## Example Usage ```hcl -resource "ibm_cd_tekton_pipeline_property" "cd_tekton_pipeline_property" { +resource "ibm_cd_tekton_pipeline_property" "cd_tekton_pipeline_property_instance" { name = "prop1" pipeline_id = "94619026-912b-4d92-8f51-6c74f0692d90" type = "text" @@ -27,13 +27,13 @@ Review the argument reference that you can specify for your resource. * `enum` - (Optional, List) Options for `single_select` property type. Only needed when using `single_select` property type. * Constraints: The list items must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. The maximum length is `256` items. The minimum length is `0` items. -* `name` - (Optional, Forces new resource, String) Property name. +* `name` - (Required, Forces new resource, String) Property name. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. * `path` - (Optional, String) A dot notation path for `integration` type properties only, to select a value from the tool integration. If left blank the full tool integration data will be used. * Constraints: The maximum length is `4096` characters. The minimum length is `0` characters. The value must match regular expression `/^[-0-9a-zA-Z_.]*$/`. * `pipeline_id` - (Required, Forces new resource, String) The Tekton pipeline ID. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[-0-9a-z]+$/`. -* `type` - (Optional, String) Property type. +* `type` - (Required, String) Property type. * Constraints: Allowable values are: `secure`, `text`, `integration`, `single_select`, `appconfig`. * `value` - (Optional, String) Property value. Any string value is valid. * Constraints: The maximum length is `4096` characters. The minimum length is `0` characters. The value must match regular expression `/^.*$/`. @@ -43,6 +43,8 @@ Review the argument reference that you can specify for your resource. In addition to all argument references listed, you can access the following attribute references after your resource is created. * `id` - The unique identifier of the cd_tekton_pipeline_property. +* `href` - (String) API URL for interacting with the property. + * Constraints: The maximum length is `2048` characters. The minimum length is `10` characters. The value must match regular expression `/^http(s)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. ## Provider Configuration diff --git a/website/docs/r/cd_tekton_pipeline_trigger.html.markdown b/website/docs/r/cd_tekton_pipeline_trigger.html.markdown index a2ad1c74bd..352e0e3d8d 100644 --- a/website/docs/r/cd_tekton_pipeline_trigger.html.markdown +++ b/website/docs/r/cd_tekton_pipeline_trigger.html.markdown @@ -13,7 +13,7 @@ Provides a resource for cd_tekton_pipeline_trigger. This allows cd_tekton_pipeli ## Example Usage ```hcl -resource "ibm_cd_tekton_pipeline_trigger" "cd_tekton_pipeline_trigger" { +resource "ibm_cd_tekton_pipeline_trigger" "cd_tekton_pipeline_trigger_instance" { event_listener = "pr-listener" events = ["push", "pull_request" ] max_concurrent_runs = 3 @@ -42,12 +42,12 @@ Review the argument reference that you can specify for your resource. * Constraints: The maximum length is `253` characters. The minimum length is `5` characters. The value must match regular expression `/^(\\*|([0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9])|\\*\/([0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9])) (\\*|([0-9]|1[0-9]|2[0-3])|\\*\/([0-9]|1[0-9]|2[0-3])) (\\*|([1-9]|1[0-9]|2[0-9]|3[0-1])|\\*\/([1-9]|1[0-9]|2[0-9]|3[0-1])) (\\*|([1-9]|1[0-2])|\\*\/([1-9]|1[0-2])) (\\*|([0-6])|\\*\/([0-6]))$/`. * `enabled` - (Optional, Boolean) Flag whether the trigger is enabled. If omitted the trigger is enabled by default. * Constraints: The default value is `true`. -* `event_listener` - (Optional, String) Event listener name. The name of the event listener to which the trigger is associated. The event listeners are defined in the definition repositories of the Tekton pipeline. +* `event_listener` - (Required, String) Event listener name. The name of the event listener to which the trigger is associated. The event listeners are defined in the definition repositories of the Tekton pipeline. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. * `events` - (Optional, List) Only needed for Git triggers. List of events to which a Git trigger listens. Choose one or more from: 'push', 'pull_request' and 'pull_request_closed'. For SCM repositories that use 'merge request' events, such events map to the equivalent 'pull request' events. - * Constraints: Allowable list items are: `push`, `pull_request`, `pull_request_closed`. The list items must match regular expression `/^[-0-9a-zA-Z_,]+$/`. The maximum length is `3` items. The minimum length is `0` items. + * Constraints: Allowable list items are: `push`, `pull_request`, `pull_request_closed`. The maximum length is `3` items. The minimum length is `0` items. * `max_concurrent_runs` - (Optional, Integer) Defines the maximum number of concurrent runs for this trigger. If omitted then the concurrency limit is disabled for this trigger. -* `name` - (Optional, String) Trigger name. +* `name` - (Required, String) Trigger name. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9][-0-9a-zA-Z_. ]{1,253}[a-zA-Z0-9]$/`. * `pipeline_id` - (Required, Forces new resource, String) The Tekton pipeline ID. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[-0-9a-z]+$/`. @@ -67,17 +67,10 @@ Nested scheme for **secret**: Nested scheme for **source**: * `properties` - (Required, List) Properties of the source, which define the URL of the repository and a branch or pattern. Nested scheme for **properties**: - * `blind_connection` - (Optional, Boolean) True if the repository server is not addressable on the public internet. IBM Cloud will not be able to validate the connection details you provide. * `branch` - (Optional, String) Name of a branch from the repo. One of branch or pattern must be specified, but only one or the other. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. - * `hook_id` - (Optional, String) ID of the webhook from the repo. Computed upon creation of the trigger. - * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. * `pattern` - (Optional, String) Git branch or tag pattern to listen to, specify one of branch or pattern only. When specifying a tag to listen to, you can also specify a simple glob pattern such as '!test' or '*master' to match against multiple tags/branches in the repository. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_.!*]*$/`. - * `tool` - (Optional, List) Reference to the repository tool in the parent toolchain. - Nested scheme for **tool**: - * `id` - (Optional, String) ID of the repository tool instance in the parent toolchain. - * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[-0-9a-z]+$/`. * `url` - (Required, Forces new resource, String) URL of the repository to which the trigger is listening. * Constraints: The maximum length is `2048` characters. The minimum length is `10` characters. The value must match regular expression `/^http(s)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. * `type` - (Required, String) The only supported source type is "git", indicating that the source is a git repository. @@ -86,16 +79,12 @@ Nested scheme for **source**: * Constraints: The list items must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. The maximum length is `128` items. The minimum length is `0` items. * `timezone` - (Optional, String) Only used for timer triggers. Specify the timezone used for this timer trigger, which will ensure the cron activates this trigger relative to the specified timezone. If no timezone is specified, the default timezone used is UTC. Valid timezones are those listed in the IANA timezone database, https://www.iana.org/time-zones. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z+_., \/]{1,253}$/`. -* `type` - (Optional, String) Trigger type. +* `type` - (Required, String) Trigger type. * Constraints: Allowable values are: `manual`, `scm`, `timer`, `generic`. * `worker` - (Optional, List) Worker used to run the trigger. If not specified the trigger will use the default pipeline worker. Nested scheme for **worker**: * `id` - (Required, Forces new resource, String) ID of the worker. - * Constraints: The maximum length is `36` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z]{1,36}$/`. - * `name` - (Optional, String) Name of the worker. Computed based on the worker ID. - * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_. \\(\\)\\[\\]]{1,253}$/`. - * `type` - (Optional, String) Type of the worker. Computed based on the worker ID. - * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. + * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z]{1,253}$/`. ## Attribute Reference @@ -119,7 +108,7 @@ Nested scheme for **properties**: * Constraints: Allowable values are: `secure`, `text`, `integration`, `single_select`, `appconfig`. * `value` - (String) Property value. Any string value is valid. * Constraints: The maximum length is `4096` characters. The minimum length is `0` characters. The value must match regular expression `/^.*$/`. -* `trigger_id` - (String) ID. +* `trigger_id` - (String) The Trigger ID. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[-0-9a-z]+$/`. * `webhook_url` - (String) Webhook URL that can be used to trigger pipeline runs. * Constraints: The maximum length is `2048` characters. The minimum length is `10` characters. The value must match regular expression `/^http(s)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. diff --git a/website/docs/r/cd_tekton_pipeline_trigger_property.html.markdown b/website/docs/r/cd_tekton_pipeline_trigger_property.html.markdown index 01620a2aef..c9879143d8 100644 --- a/website/docs/r/cd_tekton_pipeline_trigger_property.html.markdown +++ b/website/docs/r/cd_tekton_pipeline_trigger_property.html.markdown @@ -13,7 +13,7 @@ Provides a resource for cd_tekton_pipeline_trigger_property. This allows cd_tekt ## Example Usage ```hcl -resource "ibm_cd_tekton_pipeline_trigger_property" "cd_tekton_pipeline_trigger_property" { +resource "ibm_cd_tekton_pipeline_trigger_property" "cd_tekton_pipeline_trigger_property_instance" { name = "prop1" pipeline_id = "94619026-912b-4d92-8f51-6c74f0692d90" trigger_id = "1bb892a1-2e04-4768-a369-b1159eace147" @@ -28,7 +28,7 @@ Review the argument reference that you can specify for your resource. * `enum` - (Optional, List) Options for `single_select` property type. Only needed for `single_select` property type. * Constraints: The list items must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. The maximum length is `256` items. The minimum length is `0` items. -* `name` - (Optional, Forces new resource, String) Property name. +* `name` - (Required, Forces new resource, String) Property name. * Constraints: The maximum length is `253` characters. The minimum length is `1` character. The value must match regular expression `/^[-0-9a-zA-Z_.]{1,253}$/`. * `path` - (Optional, String) A dot notation path for `integration` type properties only, to select a value from the tool integration. If left blank the full tool integration data will be used. * Constraints: The maximum length is `4096` characters. The minimum length is `0` characters. The value must match regular expression `/^[-0-9a-zA-Z_.]*$/`. @@ -36,7 +36,7 @@ Review the argument reference that you can specify for your resource. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[-0-9a-z]+$/`. * `trigger_id` - (Required, Forces new resource, String) The trigger ID. * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[-0-9a-z]+$/`. -* `type` - (Optional, String) Property type. +* `type` - (Required, String) Property type. * Constraints: Allowable values are: `secure`, `text`, `integration`, `single_select`, `appconfig`. * `value` - (Optional, String) Property value. Any string value is valid. * Constraints: The maximum length is `4096` characters. The minimum length is `0` characters. The value must match regular expression `/^.*$/`. @@ -46,6 +46,8 @@ Review the argument reference that you can specify for your resource. In addition to all argument references listed, you can access the following attribute references after your resource is created. * `id` - The unique identifier of the cd_tekton_pipeline_trigger_property. +* `href` - (String) API URL for interacting with the trigger property. + * Constraints: The maximum length is `2048` characters. The minimum length is `10` characters. The value must match regular expression `/^http(s)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. ## Provider Configuration