Skip to content

Commit

Permalink
Updates to tekton-pipeline support (#4235)
Browse files Browse the repository at this point in the history
* fix(tekton): pos-GA updates

* chore(tekton): update Go SDK version

* fix(tekton): finalise tekton updates

Signed-off-by: Brian Gleeson <brian.gleeson@ie.ibm.com>

* fix(tekton): Address Worker and href feedback

Signed-off-by: Brian Gleeson <brian.gleeson@ie.ibm.com>
  • Loading branch information
briangleeson authored Jan 18, 2023
1 parent 0f336d4 commit 445a4c3
Show file tree
Hide file tree
Showing 32 changed files with 466 additions and 581 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
173 changes: 49 additions & 124 deletions ibm/service/cdtektonpipeline/data_source_ibm_cd_tekton_pipeline.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand All @@ -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.",
},
},
},
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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.",
},
},
},
},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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))
}
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -799,14 +824,17 @@ 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
}
if model.Value != nil {
modelMap["value"] = *model.Value
}
if model.Href != nil {
modelMap["href"] = *model.Href
}
if model.Enum != nil {
modelMap["enum"] = model.Enum
}
Expand All @@ -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
}

Expand Down Expand Up @@ -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
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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
}
Expand All @@ -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 {
Expand All @@ -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
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Loading

0 comments on commit 445a4c3

Please sign in to comment.