From 056ef78ac1d3142b16e10380363e26c404bc4c18 Mon Sep 17 00:00:00 2001 From: Brian Gleeson Date: Wed, 17 Apr 2024 14:38:39 +0100 Subject: [PATCH] feat(tekton): add locked properties (#5274) * feat(tekton): add locked properties * Fix locked editing * Fix edit of locked properties --- examples/ibm-cd-tekton-pipeline/versions.tf | 2 +- go.mod | 14 +++++----- go.sum | 25 +++++++++-------- .../data_source_ibm_cd_tekton_pipeline.go | 18 ++++++++++++- ..._source_ibm_cd_tekton_pipeline_property.go | 11 +++++++- ...ce_ibm_cd_tekton_pipeline_property_test.go | 11 +++++--- ...a_source_ibm_cd_tekton_pipeline_trigger.go | 10 ++++++- ...ibm_cd_tekton_pipeline_trigger_property.go | 11 +++++++- ...d_tekton_pipeline_trigger_property_test.go | 11 +++++--- .../resource_ibm_cd_tekton_pipeline.go | 18 ++++++++++++- ...esource_ibm_cd_tekton_pipeline_property.go | 27 +++++++++++++++---- ...ce_ibm_cd_tekton_pipeline_property_test.go | 15 +++++++---- ...resource_ibm_cd_tekton_pipeline_trigger.go | 10 ++++++- ...ibm_cd_tekton_pipeline_trigger_property.go | 27 +++++++++++++++---- ...d_tekton_pipeline_trigger_property_test.go | 15 +++++++---- .../docs/d/cd_tekton_pipeline.html.markdown | 2 ++ .../cd_tekton_pipeline_property.html.markdown | 2 ++ .../cd_tekton_pipeline_trigger.html.markdown | 1 + ...on_pipeline_trigger_property.html.markdown | 2 ++ .../docs/r/cd_tekton_pipeline.html.markdown | 1 + .../cd_tekton_pipeline_property.html.markdown | 1 + .../cd_tekton_pipeline_trigger.html.markdown | 1 + ...on_pipeline_trigger_property.html.markdown | 1 + 23 files changed, 183 insertions(+), 53 deletions(-) diff --git a/examples/ibm-cd-tekton-pipeline/versions.tf b/examples/ibm-cd-tekton-pipeline/versions.tf index 9d4d20b5d6..b5b4f6cd4a 100644 --- a/examples/ibm-cd-tekton-pipeline/versions.tf +++ b/examples/ibm-cd-tekton-pipeline/versions.tf @@ -3,7 +3,7 @@ terraform { required_providers { ibm = { source = "IBM-Cloud/ibm" - version = ">=1.53.0" + version = ">=1.64.0" } } } diff --git a/go.mod b/go.mod index 33d45702b0..9b3f0c91f6 100644 --- a/go.mod +++ b/go.mod @@ -12,11 +12,11 @@ require ( github.com/IBM/cloudant-go-sdk v0.0.43 github.com/IBM/code-engine-go-sdk v0.0.0-20231106200405-99e81b3ee752 github.com/IBM/container-registry-go-sdk v1.1.0 - github.com/IBM/continuous-delivery-go-sdk v1.3.0 + github.com/IBM/continuous-delivery-go-sdk v1.5.0 github.com/IBM/event-notifications-go-admin-sdk v0.4.0 github.com/IBM/eventstreams-go-sdk v1.4.0 github.com/IBM/go-sdk-core/v3 v3.2.4 - github.com/IBM/go-sdk-core/v5 v5.16.3 + github.com/IBM/go-sdk-core/v5 v5.16.5 github.com/IBM/ibm-cos-sdk-go v1.10.1 github.com/IBM/ibm-cos-sdk-go-config/v2 v2.0.4 github.com/IBM/ibm-hpcs-tke-sdk v0.0.0-20211109141421-a4b61b05f7d1 @@ -52,7 +52,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/rook/rook v1.11.4 github.com/softlayer/softlayer-go v1.0.3 - golang.org/x/crypto v0.19.0 + golang.org/x/crypto v0.21.0 gopkg.in/yaml.v3 v3.0.1 gotest.tools v2.2.0+incompatible k8s.io/api v0.26.3 @@ -116,7 +116,7 @@ require ( github.com/go-ozzo/ozzo-validation/v4 v4.3.0 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.18.0 // indirect + github.com/go-playground/validator/v10 v10.19.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.4 // indirect @@ -208,10 +208,10 @@ require ( go.opentelemetry.io/otel/trace v1.14.0 // indirect go.uber.org/ratelimit v0.2.0 // indirect golang.org/x/mod v0.14.0 // indirect - golang.org/x/net v0.21.0 // indirect + golang.org/x/net v0.23.0 // indirect golang.org/x/oauth2 v0.7.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect diff --git a/go.sum b/go.sum index 8502039b83..3716310a95 100644 --- a/go.sum +++ b/go.sum @@ -124,8 +124,8 @@ github.com/IBM/code-engine-go-sdk v0.0.0-20231106200405-99e81b3ee752 h1:S5NT0aKK github.com/IBM/code-engine-go-sdk v0.0.0-20231106200405-99e81b3ee752/go.mod h1:noWxHQUgW9msjOrDpV17gnwWbTbUlSmWMGq7/Vi/n9I= github.com/IBM/container-registry-go-sdk v1.1.0 h1:sYyknIod8R4RJZQqAheiduP6wbSTphE9Ag8ho28yXjc= github.com/IBM/container-registry-go-sdk v1.1.0/go.mod h1:4TwsCnQtVfZ4Vkapy/KPvQBKFc3VOyUZYkwRU4FTPrs= -github.com/IBM/continuous-delivery-go-sdk v1.3.0 h1:WsILMVpNWD/5G40ltWeXbOj4y5ODQSq1hKXAnDJuNjw= -github.com/IBM/continuous-delivery-go-sdk v1.3.0/go.mod h1:oW51tS5/MDCcEM7lUvjK1H9GFC/oKsRbyYfmvGyMGmw= +github.com/IBM/continuous-delivery-go-sdk v1.5.0 h1:FHSRruNt9WK7SavpIVuV6N+xll90UgZsuQjZvQ+slB4= +github.com/IBM/continuous-delivery-go-sdk v1.5.0/go.mod h1:nZdKUnubXNLo+zo28R4Rd+TGDqiJ/xoE8WO/A3kLw1E= github.com/IBM/event-notifications-go-admin-sdk v0.4.0 h1:7nqtybv8GNVjuB5QBfx/kejI90lCXBnSuERNnJB4gZY= github.com/IBM/event-notifications-go-admin-sdk v0.4.0/go.mod h1:m6WD+q9AHJhybK929vOK8Kfx4BsKO7AmROKRpR2uQP8= github.com/IBM/eventstreams-go-sdk v1.4.0 h1:yS/Ns29sBOe8W2tynQmz9HTKqQZ0ckse4Py5Oy/F2rM= @@ -141,8 +141,8 @@ github.com/IBM/go-sdk-core/v5 v5.7.0/go.mod h1:+YbdhrjCHC84ls4MeBp+Hj4NZCni+tDAc github.com/IBM/go-sdk-core/v5 v5.9.2/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV0j68/rlZsE= github.com/IBM/go-sdk-core/v5 v5.9.5/go.mod h1:YlOwV9LeuclmT/qi/LAK2AsobbAP42veV0j68/rlZsE= github.com/IBM/go-sdk-core/v5 v5.10.2/go.mod h1:WZPFasUzsKab/2mzt29xPcfruSk5js2ywAPwW4VJjdI= -github.com/IBM/go-sdk-core/v5 v5.16.3 h1:GJI62GNAagX2xeTMpTACIqki5rDVO3YbxzMuIpAXSrQ= -github.com/IBM/go-sdk-core/v5 v5.16.3/go.mod h1:aojBkkq4HXkOYdn7YZ6ve8cjPWHdcB3tt8v0b9Cbac8= +github.com/IBM/go-sdk-core/v5 v5.16.5 h1:5ZltNcryRI8kVcuvNJGR2EXKqb7HtM4atA0Nm5QwAFE= +github.com/IBM/go-sdk-core/v5 v5.16.5/go.mod h1:GatGZpxlo1KaxiRN6E10/rNgWtUtx1hN/GoHSCaSPKA= github.com/IBM/ibm-cos-sdk-go v1.10.1 h1:vQCsu61OHRVF2lL6ah+m3AmUlhnYGkI1qogukCEFULs= github.com/IBM/ibm-cos-sdk-go v1.10.1/go.mod h1:zhcgfL2YG5DVaI5R2F6oYO2DYnvwW14vpcpFq+ybhXU= github.com/IBM/ibm-cos-sdk-go-config/v2 v2.0.4 h1:fvy/cMKn/3BngdxaL5dXaSlUuzTANY42VuVQuW0NEYE= @@ -580,8 +580,8 @@ github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+ github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.18.0 h1:BvolUXjp4zuvkZ5YN5t7ebzbhlUtPsPm2S9NAZ5nl9U= -github.com/go-playground/validator/v10 v10.18.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= +github.com/go-playground/validator/v10 v10.19.0 h1:ol+5Fu+cSq9JD7SoSqe04GMI92cbn0+wvQ3bZ8b/AU4= +github.com/go-playground/validator/v10 v10.19.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= @@ -1636,8 +1636,9 @@ golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98y golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1762,8 +1763,8 @@ golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190130055435-99b60b757ec1/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1908,8 +1909,9 @@ golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1926,8 +1928,9 @@ golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 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 795840c514..4e116e6254 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. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline @@ -179,6 +179,11 @@ func DataSourceIBMCdTektonPipeline() *schema.Resource { Computed: true, Description: "Property type.", }, + "locked": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "When true, this property cannot be overridden by a trigger property or at runtime. Attempting to override it will result in run requests being rejected. The default is false.", + }, "path": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -267,6 +272,11 @@ 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.", }, + "locked": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "When true, this property cannot be overridden at runtime. Attempting to override it will result in run requests being rejected. The default is false.", + }, }, }, }, @@ -724,6 +734,9 @@ func dataSourceIBMCdTektonPipelinePropertyToMap(model *cdtektonpipelinev2.Proper modelMap["enum"] = model.Enum } modelMap["type"] = model.Type + if model.Locked != nil { + modelMap["locked"] = model.Locked + } if model.Path != nil { modelMap["path"] = model.Path } @@ -835,6 +848,9 @@ func dataSourceIBMCdTektonPipelineTriggerPropertyToMap(model *cdtektonpipelinev2 if model.Path != nil { modelMap["path"] = model.Path } + if model.Locked != nil { + modelMap["locked"] = model.Locked + } return modelMap, nil } 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 dbb849eff8..5d1b739bd4 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. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline @@ -58,6 +58,11 @@ func DataSourceIBMCdTektonPipelineProperty() *schema.Resource { Computed: true, Description: "Property type.", }, + "locked": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "When true, this property cannot be overridden by a trigger property or at runtime. Attempting to override it will result in run requests being rejected. The default is false.", + }, "path": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -102,6 +107,10 @@ func dataSourceIBMCdTektonPipelinePropertyRead(context context.Context, d *schem return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) } + if err = d.Set("locked", property.Locked); err != nil { + return diag.FromErr(fmt.Errorf("Error setting locked: %s", err)) + } + if err = d.Set("path", property.Path); err != nil { return diag.FromErr(fmt.Errorf("Error setting path: %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 e18d3744b2..039e66f382 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. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline_test @@ -39,6 +39,7 @@ 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" + propertyLocked := "true" propertyPath := fmt.Sprintf("tf_path_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ @@ -46,7 +47,7 @@ func TestAccIBMCdTektonPipelinePropertyDataSourceAllArgs(t *testing.T) { Providers: acc.TestAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIBMCdTektonPipelinePropertyDataSourceConfig("", propertyName, propertyValue, propertyType, propertyPath), + Config: testAccCheckIBMCdTektonPipelinePropertyDataSourceConfig("", propertyName, propertyValue, propertyType, propertyLocked, 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"), @@ -55,6 +56,7 @@ func TestAccIBMCdTektonPipelinePropertyDataSourceAllArgs(t *testing.T) { 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"), + resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "locked"), ), }, }, @@ -104,7 +106,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, propertyValue string, propertyType string, propertyLocked string, propertyPath string) string { rgName := acc.CdResourceGroupName tcName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) return fmt.Sprintf(` @@ -136,6 +138,7 @@ func testAccCheckIBMCdTektonPipelinePropertyDataSourceConfig(propertyPipelineID name = "%s" type = "text" value = "%s" + locked = "%s" depends_on = [ ibm_cd_tekton_pipeline.cd_tekton_pipeline ] @@ -144,5 +147,5 @@ func testAccCheckIBMCdTektonPipelinePropertyDataSourceConfig(propertyPipelineID pipeline_id = ibm_cd_tekton_pipeline.cd_tekton_pipeline.pipeline_id property_name = ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property.name } - `, rgName, tcName, propertyName, propertyValue) + `, rgName, tcName, propertyName, propertyValue, propertyLocked) } 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 7654d47da5..78b5908680 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. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline @@ -90,6 +90,11 @@ 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.", }, + "locked": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "When true, this property cannot be overridden at runtime. Attempting to override it will result in run requests being rejected. The default is false.", + }, }, }, }, @@ -404,6 +409,9 @@ func dataSourceIBMCdTektonPipelineTriggerTriggerPropertyToMap(model *cdtektonpip if model.Path != nil { modelMap["path"] = model.Path } + if model.Locked != nil { + modelMap["locked"] = model.Locked + } return modelMap, nil } 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 5774b468ba..fe5ed84978 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. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline @@ -68,6 +68,11 @@ func DataSourceIBMCdTektonPipelineTriggerProperty() *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.", }, + "locked": &schema.Schema{ + Type: schema.TypeBool, + Computed: true, + Description: "When true, this property cannot be overridden at runtime. Attempting to override it will result in run requests being rejected. The default is false.", + }, }, } } @@ -112,6 +117,10 @@ func dataSourceIBMCdTektonPipelineTriggerPropertyRead(context context.Context, d return diag.FromErr(fmt.Errorf("Error setting path: %s", err)) } + if err = d.Set("locked", triggerProperty.Locked); err != nil { + return diag.FromErr(fmt.Errorf("Error setting locked: %s", err)) + } + if triggerProperty.Enum != nil { if err = d.Set("enum", triggerProperty.Enum); err != nil { return diag.FromErr(fmt.Errorf("Error setting enum: %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 a72c36c17e..8446b940c4 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. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline_test @@ -39,13 +39,14 @@ func TestAccIBMCdTektonPipelineTriggerPropertyDataSourceAllArgs(t *testing.T) { triggerPropertyValue := fmt.Sprintf("tf_value_%d", acctest.RandIntRange(10, 100)) triggerPropertyType := "text" triggerPropertyPath := fmt.Sprintf("tf_path_%d", acctest.RandIntRange(10, 100)) + triggerPropertyLocked := "true" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIBMCdTektonPipelineTriggerPropertyDataSourceConfig("", "", triggerPropertyName, triggerPropertyValue, triggerPropertyType, triggerPropertyPath), + Config: testAccCheckIBMCdTektonPipelineTriggerPropertyDataSourceConfig("", "", triggerPropertyName, triggerPropertyValue, triggerPropertyType, triggerPropertyPath, triggerPropertyLocked), 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"), @@ -53,6 +54,7 @@ func TestAccIBMCdTektonPipelineTriggerPropertyDataSourceAllArgs(t *testing.T) { 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"), + resource.TestCheckResourceAttrSet("data.ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "locked"), ), }, }, @@ -133,7 +135,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, triggerPropertyValue string, triggerPropertyType string, triggerPropertyPath string, triggerPropertyLocked string) string { rgName := acc.CdResourceGroupName tcName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) return fmt.Sprintf(` @@ -198,11 +200,12 @@ func testAccCheckIBMCdTektonPipelineTriggerPropertyDataSourceConfig(triggerPrope name = "%s" type = "%s" value = "%s" + locked = "%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, triggerPropertyType, triggerPropertyValue, triggerPropertyName) + `, rgName, tcName, triggerPropertyName, triggerPropertyType, triggerPropertyValue, triggerPropertyLocked, triggerPropertyName) } diff --git a/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline.go b/ibm/service/cdtektonpipeline/resource_ibm_cd_tekton_pipeline.go index 78e39e3861..f202c024b9 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. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline @@ -234,6 +234,11 @@ func ResourceIBMCdTektonPipeline() *schema.Resource { ForceNew: true, Description: "Property type.", }, + "locked": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Description: "When true, this property cannot be overridden by a trigger property or at runtime. Attempting to override it will result in run requests being rejected. The default is false.", + }, "path": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -323,6 +328,11 @@ 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.", }, + "locked": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Description: "When true, this property cannot be overridden at runtime. Attempting to override it will result in run requests being rejected. The default is false.", + }, }, }, }, @@ -872,6 +882,9 @@ func resourceIBMCdTektonPipelinePropertyToMap(model *cdtektonpipelinev2.Property modelMap["enum"] = model.Enum } modelMap["type"] = model.Type + if model.Locked != nil { + modelMap["locked"] = model.Locked + } if model.Path != nil { modelMap["path"] = model.Path } @@ -983,6 +996,9 @@ func resourceIBMCdTektonPipelineTriggerPropertyToMap(model *cdtektonpipelinev2.T if model.Path != nil { modelMap["path"] = model.Path } + if model.Locked != nil { + modelMap["locked"] = model.Locked + } return modelMap, nil } 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 0be5e231d2..064aaafd7a 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. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline @@ -61,6 +61,12 @@ func ResourceIBMCdTektonPipelineProperty() *schema.Resource { ValidateFunc: validate.InvokeValidator("ibm_cd_tekton_pipeline_property", "type"), Description: "Property type.", }, + "locked": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "When true, this property cannot be overridden by a trigger property or at runtime. Attempting to override it will result in run requests being rejected. The default is false.", + }, "path": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -150,6 +156,9 @@ func resourceIBMCdTektonPipelinePropertyCreate(context context.Context, d *schem } createTektonPipelinePropertiesOptions.SetEnum(enum) } + if _, ok := d.GetOk("locked"); ok { + createTektonPipelinePropertiesOptions.SetLocked(d.Get("locked").(bool)) + } if _, ok := d.GetOk("path"); ok { createTektonPipelinePropertiesOptions.SetPath(d.Get("path").(string)) } @@ -210,6 +219,11 @@ func resourceIBMCdTektonPipelinePropertyRead(context context.Context, d *schema. if err = d.Set("type", property.Type); err != nil { return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) } + if !core.IsNil(property.Locked) { + if err = d.Set("locked", property.Locked); err != nil { + return diag.FromErr(fmt.Errorf("Error setting locked: %s", err)) + } + } if !core.IsNil(property.Path) { if err = d.Set("path", property.Path); err != nil { return diag.FromErr(fmt.Errorf("Error setting path: %s", err)) @@ -256,15 +270,18 @@ 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.", "type")) } - + if d.HasChange("locked") { + replaceTektonPipelinePropertyOptions.SetLocked(d.Get("locked").(bool)) + hasChange = true + } if d.Get("type").(string) == "integration" { - if d.HasChange("value") || d.HasChange("path") { + if d.HasChange("value") || d.HasChange("path") || d.HasChange("locked") { replaceTektonPipelinePropertyOptions.SetValue(d.Get("value").(string)) replaceTektonPipelinePropertyOptions.SetPath(d.Get("path").(string)) hasChange = true } } else if d.Get("type").(string) == "single_select" { - if d.HasChange("enum") || d.HasChange("value") { + if d.HasChange("enum") || d.HasChange("value") || d.HasChange("locked") { var enum []string for _, v := range d.Get("enum").([]interface{}) { enumItem := v.(string) @@ -275,7 +292,7 @@ func resourceIBMCdTektonPipelinePropertyUpdate(context context.Context, d *schem hasChange = true } } else { - if d.HasChange("value") { + if d.HasChange("value") || d.HasChange("locked") { replaceTektonPipelinePropertyOptions.SetValue(d.Get("value").(string)) hasChange = true } 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 c23c1e8389..0cf2bd361d 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. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline_test @@ -43,8 +43,10 @@ func TestAccIBMCdTektonPipelinePropertyAllArgs(t *testing.T) { name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) value := fmt.Sprintf("tf_value_%d", acctest.RandIntRange(10, 100)) typeVar := "text" + locked := "true" path := fmt.Sprintf("tf_path_%d", acctest.RandIntRange(10, 100)) valueUpdate := fmt.Sprintf("tf_value_%d", acctest.RandIntRange(10, 100)) + lockedUpdate := "false" pathUpdate := fmt.Sprintf("tf_path_%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ @@ -53,20 +55,22 @@ func TestAccIBMCdTektonPipelinePropertyAllArgs(t *testing.T) { CheckDestroy: testAccCheckIBMCdTektonPipelinePropertyDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIBMCdTektonPipelinePropertyConfig("", name, value, typeVar, path), + Config: testAccCheckIBMCdTektonPipelinePropertyConfig("", name, value, typeVar, locked, 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", "locked", locked), ), }, resource.TestStep{ - Config: testAccCheckIBMCdTektonPipelinePropertyConfig("", name, valueUpdate, typeVar, pathUpdate), + Config: testAccCheckIBMCdTektonPipelinePropertyConfig("", name, valueUpdate, typeVar, lockedUpdate, 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", typeVar), + resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_property.cd_tekton_pipeline_property", "locked", lockedUpdate), ), }, resource.TestStep{ @@ -117,7 +121,7 @@ func testAccCheckIBMCdTektonPipelinePropertyConfigBasic(pipelineID string, name `, rgName, tcName) } -func testAccCheckIBMCdTektonPipelinePropertyConfig(pipelineID string, name string, value string, typeVar string, path string) string { +func testAccCheckIBMCdTektonPipelinePropertyConfig(pipelineID string, name string, value string, typeVar string, locked string, path string) string { rgName := acc.CdResourceGroupName tcName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) return fmt.Sprintf(` @@ -149,11 +153,12 @@ func testAccCheckIBMCdTektonPipelinePropertyConfig(pipelineID string, name strin name = "%s" type = "text" value = "%s" + locked = "%s" depends_on = [ ibm_cd_tekton_pipeline.cd_tekton_pipeline ] } - `, rgName, tcName, name, value) + `, rgName, tcName, name, value, locked) } func testAccCheckIBMCdTektonPipelinePropertyExists(n string, obj cdtektonpipelinev2.Property) resource.TestCheckFunc { 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 319b4963ba..47378fd1bd 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. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline @@ -267,6 +267,11 @@ 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.", }, + "locked": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Description: "When true, this property cannot be overridden at runtime. Attempting to override it will result in run requests being rejected. The default is false.", + }, }, }, }, @@ -836,5 +841,8 @@ func resourceIBMCdTektonPipelineTriggerTriggerPropertyToMap(model *cdtektonpipel if model.Path != nil { modelMap["path"] = model.Path } + if model.Locked != nil { + modelMap["locked"] = model.Locked + } 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 7de7108c3a..6bc7117888 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. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline @@ -74,6 +74,12 @@ func ResourceIBMCdTektonPipelineTriggerProperty() *schema.Resource { ValidateFunc: validate.InvokeValidator("ibm_cd_tekton_pipeline_trigger_property", "path"), 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.", }, + "locked": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "When true, this property cannot be overridden at runtime. Attempting to override it will result in run requests being rejected. The default is false.", + }, "href": &schema.Schema{ Type: schema.TypeString, Computed: true, @@ -170,6 +176,9 @@ func resourceIBMCdTektonPipelineTriggerPropertyCreate(context context.Context, d if _, ok := d.GetOk("path"); ok { createTektonPipelineTriggerPropertiesOptions.SetPath(d.Get("path").(string)) } + if _, ok := d.GetOk("locked"); ok { + createTektonPipelineTriggerPropertiesOptions.SetLocked(d.Get("locked").(bool)) + } triggerProperty, response, err := cdTektonPipelineClient.CreateTektonPipelineTriggerPropertiesWithContext(context, createTektonPipelineTriggerPropertiesOptions) if err != nil { @@ -236,6 +245,11 @@ func resourceIBMCdTektonPipelineTriggerPropertyRead(context context.Context, d * return diag.FromErr(fmt.Errorf("Error setting path: %s", err)) } } + if !core.IsNil(triggerProperty.Locked) { + if err = d.Set("locked", triggerProperty.Locked); err != nil { + return diag.FromErr(fmt.Errorf("Error setting locked: %s", err)) + } + } if !core.IsNil(triggerProperty.Href) { if err = d.Set("href", triggerProperty.Href); err != nil { return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) @@ -282,15 +296,18 @@ 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.", "type")) } - + if d.HasChange("locked") { + replaceTektonPipelineTriggerPropertyOptions.SetLocked(d.Get("locked").(bool)) + hasChange = true + } if d.Get("type").(string) == "integration" { - if d.HasChange("value") || d.HasChange("path") { + if d.HasChange("value") || d.HasChange("path") || d.HasChange("locked") { replaceTektonPipelineTriggerPropertyOptions.SetValue(d.Get("value").(string)) replaceTektonPipelineTriggerPropertyOptions.SetPath(d.Get("path").(string)) hasChange = true } } else if d.Get("type").(string) == "single_select" { - if d.HasChange("enum") || d.HasChange("value") { + if d.HasChange("enum") || d.HasChange("value") || d.HasChange("locked") { var enum []string for _, v := range d.Get("enum").([]interface{}) { enumItem := v.(string) @@ -301,7 +318,7 @@ func resourceIBMCdTektonPipelineTriggerPropertyUpdate(context context.Context, d hasChange = true } } else { - if d.HasChange("value") { + if d.HasChange("value") || d.HasChange("locked") { replaceTektonPipelineTriggerPropertyOptions.SetValue(d.Get("value").(string)) hasChange = true } 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 12d6185ffc..a734ff057d 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. 2023 All Rights Reserved. +// Copyright IBM Corp. 2024 All Rights Reserved. // Licensed under the Mozilla Public License v2.0 package cdtektonpipeline_test @@ -44,8 +44,10 @@ func TestAccIBMCdTektonPipelineTriggerPropertyAllArgs(t *testing.T) { value := fmt.Sprintf("tf_value_%d", acctest.RandIntRange(10, 100)) typeVar := "text" path := fmt.Sprintf("tf_path_%d", acctest.RandIntRange(10, 100)) + locked := "true" valueUpdate := fmt.Sprintf("tf_value_%d", acctest.RandIntRange(10, 100)) pathUpdate := fmt.Sprintf("tf_path_%d", acctest.RandIntRange(10, 100)) + lockedUpdate := "false" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, @@ -53,20 +55,22 @@ func TestAccIBMCdTektonPipelineTriggerPropertyAllArgs(t *testing.T) { CheckDestroy: testAccCheckIBMCdTektonPipelineTriggerPropertyDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccCheckIBMCdTektonPipelineTriggerPropertyConfig("", "", name, value, typeVar, path), + Config: testAccCheckIBMCdTektonPipelineTriggerPropertyConfig("", "", name, value, typeVar, path, locked), 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", "locked", locked), ), }, resource.TestStep{ - Config: testAccCheckIBMCdTektonPipelineTriggerPropertyConfig("", "", name, valueUpdate, typeVar, pathUpdate), + Config: testAccCheckIBMCdTektonPipelineTriggerPropertyConfig("", "", name, valueUpdate, typeVar, pathUpdate, lockedUpdate), 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", typeVar), + resource.TestCheckResourceAttr("ibm_cd_tekton_pipeline_trigger_property.cd_tekton_pipeline_trigger_property", "locked", lockedUpdate), ), }, resource.TestStep{ @@ -147,7 +151,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, value string, typeVar string, path string, locked string) string { rgName := acc.CdResourceGroupName tcName := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) return fmt.Sprintf(` @@ -212,8 +216,9 @@ func testAccCheckIBMCdTektonPipelineTriggerPropertyConfig(pipelineID string, tri name = "%s" type = "%s" value = "%s" + locked = "%s" } - `, rgName, tcName, name, typeVar, value) + `, rgName, tcName, name, typeVar, value, locked) } func testAccCheckIBMCdTektonPipelineTriggerPropertyExists(n string, obj cdtektonpipelinev2.TriggerProperty) resource.TestCheckFunc { diff --git a/website/docs/d/cd_tekton_pipeline.html.markdown b/website/docs/d/cd_tekton_pipeline.html.markdown index f2448c5d44..ea9ec48c00 100644 --- a/website/docs/d/cd_tekton_pipeline.html.markdown +++ b/website/docs/d/cd_tekton_pipeline.html.markdown @@ -84,6 +84,7 @@ Nested schema for **properties**: * 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)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. + * `locked` - (Boolean) When true, this property cannot be overridden by a trigger property or at runtime. Attempting to override it will result in run requests being rejected. The default is false. * `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. @@ -138,6 +139,7 @@ Nested schema for **triggers**: * 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)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. + * `locked` - (Boolean) When true, this property cannot be overridden at runtime. Attempting to override it will result in run requests being rejected. The default is false. * `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. diff --git a/website/docs/d/cd_tekton_pipeline_property.html.markdown b/website/docs/d/cd_tekton_pipeline_property.html.markdown index df95ebdf7e..820be2a01b 100644 --- a/website/docs/d/cd_tekton_pipeline_property.html.markdown +++ b/website/docs/d/cd_tekton_pipeline_property.html.markdown @@ -39,6 +39,8 @@ After your data source is created, you can read values from the following attrib * `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)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. +* `locked` - (Boolean) When true, this property cannot be overridden by a trigger property or at runtime. Attempting to override it will result in run requests being rejected. The default is false. + * `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 4b6c4dc819..c3daa65898 100644 --- a/website/docs/d/cd_tekton_pipeline_trigger.html.markdown +++ b/website/docs/d/cd_tekton_pipeline_trigger.html.markdown @@ -63,6 +63,7 @@ Nested schema for **properties**: * 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)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. + * `locked` - (Boolean) When true, this property cannot be overridden at runtime. Attempting to override it will result in run requests being rejected. The default is false. * `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. 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 84ec63d87d..8e39c53fe6 100644 --- a/website/docs/d/cd_tekton_pipeline_trigger_property.html.markdown +++ b/website/docs/d/cd_tekton_pipeline_trigger_property.html.markdown @@ -42,6 +42,8 @@ After your data source is created, you can read values from the following attrib * `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)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. +* `locked` - (Boolean) When true, this property cannot be overridden at runtime. Attempting to override it will result in run requests being rejected. The default is false. + * `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 7edc76f72e..11bcae1503 100644 --- a/website/docs/r/cd_tekton_pipeline.html.markdown +++ b/website/docs/r/cd_tekton_pipeline.html.markdown @@ -135,6 +135,7 @@ Nested schema for **triggers**: * 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)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. + * `locked` - (Boolean) When true, this property cannot be overridden at runtime. Attempting to override it will result in run requests being rejected. The default is false. * `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. diff --git a/website/docs/r/cd_tekton_pipeline_property.html.markdown b/website/docs/r/cd_tekton_pipeline_property.html.markdown index 7f39bd0315..129d14c545 100644 --- a/website/docs/r/cd_tekton_pipeline_property.html.markdown +++ b/website/docs/r/cd_tekton_pipeline_property.html.markdown @@ -27,6 +27,7 @@ You can specify the following arguments for this 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. +* `locked` - (Optional, Boolean) When true, this property cannot be overridden by a trigger property or at runtime. Attempting to override it will result in run requests being rejected. The default is false. * `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, that selects a value from the tool integration. If left blank the full tool integration data will be used. diff --git a/website/docs/r/cd_tekton_pipeline_trigger.html.markdown b/website/docs/r/cd_tekton_pipeline_trigger.html.markdown index 123e19dc6e..b76499e23d 100644 --- a/website/docs/r/cd_tekton_pipeline_trigger.html.markdown +++ b/website/docs/r/cd_tekton_pipeline_trigger.html.markdown @@ -104,6 +104,7 @@ Nested schema for **properties**: * 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)?:\/\/([^\/?#]*)([^?#]*)(\\?([^#]*))?(#(.*))?$/`. + * `locked` - (Boolean) When true, this property cannot be overridden at runtime. Attempting to override it will result in run requests being rejected. The default is false. * `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. 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 6dfca9cad2..efe2d54c08 100644 --- a/website/docs/r/cd_tekton_pipeline_trigger_property.html.markdown +++ b/website/docs/r/cd_tekton_pipeline_trigger_property.html.markdown @@ -28,6 +28,7 @@ You can specify the following arguments for this 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. +* `locked` - (Optional, Boolean) When true, this property cannot be overridden at runtime. Attempting to override it will result in run requests being rejected. The default is false. * `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, that selects a value from the tool integration. If left blank the full tool integration data will be used.